Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand math fingerprinting #36

Closed
abrahamjuliot opened this issue Jul 21, 2020 · 7 comments
Closed

Expand math fingerprinting #36

abrahamjuliot opened this issue Jul 21, 2020 · 7 comments
Labels
enhancement New feature or request revisit

Comments

@abrahamjuliot
Copy link
Owner

abrahamjuliot commented Jul 21, 2020

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math

  • Include more static methods and properties
  • Show unique results separate from Chrome V8

tests: https://es6console.com/kcvb8uvr/

Diff Tester:
https://jsfiddle.net/w3cqtsj1/ (consumes memory)

Polyfills:
https://jsfiddle.net/gz48qutr/14/

@abrahamjuliot abrahamjuliot added the enhancement New feature or request label Jul 21, 2020
abrahamjuliot added a commit that referenced this issue Jul 21, 2020
@abrahamjuliot
Copy link
Owner Author

Math.sin() in some cases returns different results in Tor Browser and Firefox.

const bigN = 586084736227728400000000000000000000000
Math.sin(Math.PI)
// FF => 1.2246467991473532e-16
// TB => 1.2246063538223773e-16
Math.sin(bigN)
// FF => 0.994076732536068
// TB => -0.20876350121720488

@abrahamjuliot
Copy link
Owner Author

abrahamjuliot commented Aug 29, 2020

I've thought about using polyfills, but it appears there are some cases where the engine/arch/os computation differs from the polyfill.

Example:

// exmp1: false in Safari
(Math.exp(1) - 1) == Math.expm1(1)

// sinh: false in Safari
((Math.exp(Math.PI) - 1 / Math.exp(Math.PI)) / 2) == Math.sinh(Math.PI)

// atanh: false in Firefox, Chrome, Safari
n = 9e-8
(Math.log((1 + n) / (1 - n)) / 2) == Math.atanh(n)

// hypot from https://github.com/MaxArt2501/es6-math/blob/master/es6-math.js
// false in Chrome and Safari
function hypot(value1, value2) {
  let i, n = 0, args = arguments, len = args.length
  for (i = 0; i < len; i++) {
    n += args[i] * args[i]
  }
  return Math.sqrt(n)
}
let n = 5.860847362277284e+38
hypot(n, n) == Math.hypot(n, n)

@Thorin-Oakenpants
Copy link

it appears there are some cases where the engine/arch/os computation differs from the polyfill

That's exactly what we want to be doing - it adds more entropy :)

@abrahamjuliot
Copy link
Owner Author

...output the equation vs a polyfill (where applicable)
...create a list of the hashes as we find them and for each add the browser + version + build-bit + os-bit + OS-name and the results.

I like this idea.

abrahamjuliot added a commit that referenced this issue Aug 30, 2020
abrahamjuliot added a commit that referenced this issue Aug 30, 2020
abrahamjuliot added a commit that referenced this issue Aug 30, 2020
@abrahamjuliot
Copy link
Owner Author

abrahamjuliot commented Aug 30, 2020

Some interesting finds through attempts to mimic pow

expected = 2.5600000000000008e-62

// polyfill 1
// true in FF, Chrome, and Safari
x = 2e-8;[...Array(3)].forEach((val, i) => x*=x)
x == expected

// native Math.pow(2e-8,8)
// false in Chrome (yields 2.5600000000000003e-62)
Math.pow(2e-8, 8) == expected

// native exponentiation operator 2e-8**8
// ** is equivalent to Math.pow() and implementation-dependent
// false in Chrome (yields 2.5600000000000003e-62)
2e-8**8 == expected

// polyfill 2
// false in FF, Chrome, and Safari (yields 2.5600000000000003e-62)
2e-8*2e-8*2e-8*2e-8*2e-8*2e-8*2e-8*2e-8 == expected

// polyfill 3: altering the operation order changes the result
// true in FF, Chrome, and Safari
2e-8*2e-8*2e-8*2e-8*(2e-8*2e-8*2e-8*2e-8) == expected

abrahamjuliot added a commit that referenced this issue Aug 30, 2020
@abrahamjuliot
Copy link
Owner Author

abrahamjuliot commented Aug 30, 2020

...all three engines

((Math.exp(Math.PI) - 1 / Math.exp(Math.PI)) / 2) is the same in FF, Chrome, Safari, but Math.sinh(Math.PI) is different in Safari.

polyfills

From what I gather, the entropy obtained through a polyfill (if any) can be reduced to testing the implementation-dependent methods: log, pow, exp, sqrt etc. A polyfill free from native methods should yeild the same result across systems. Entropy is introduced when the calculation uses an implementation-dependent method or operator. This is just my limited observation, however.

@abrahamjuliot
Copy link
Owner Author

There's nice short list of es6 functions at https://github.com/MaxArt2501/es6-math/blob/master/README.md#usage

abrahamjuliot added a commit that referenced this issue Aug 31, 2020
abrahamjuliot added a commit that referenced this issue Aug 31, 2020
abrahamjuliot added a commit that referenced this issue Sep 1, 2020
abrahamjuliot added a commit that referenced this issue Sep 1, 2020
abrahamjuliot added a commit that referenced this issue Sep 2, 2020
abrahamjuliot added a commit that referenced this issue Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request revisit
Projects
None yet
Development

No branches or pull requests

2 participants