SrsSec / SrsPass-pwa

A secure deterministic password generator with properties resulting in a statelessly capable password manager
https://app.srspass.com
GNU Affero General Public License v3.0
5 stars 1 forks source link

fix: BigUint64Array lacks Apple/Safari/IE compatibility #23

Closed D-Nice closed 3 years ago

D-Nice commented 3 years ago

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array for compat

1.1 ideal

  1. 2 less ideal
    • [ ] create polyfill

1.3 fallback downgrade to using uin32array, which all browsers support... would technically increase the probability of certain characters appearing more than others, based on their index, however, should still be negligible enough

2.1 must

2.2 must

D-Nice commented 3 years ago

Completed research on this problem, to rule out 1.3 as an appropriate solution.

This research will be re-used in the protocol spec. Finding essentially yielded an equation to calculate the maximum bias potential for a specific bit size with the algorithm in place. It concluded that 64-bits would require every person (8B assumed) to generate over 200k passwords each, before even 1 of these, yields a password with a 1 character bias, with a probability of 50%, and that is assuming the most biased alphabet set being used, and 20 characters per password. WolframAlpha calculation (59 denotes the character possibilities of bias in comparison to non-biased characters which is the huge second number)

These were derived using the following hand-crafted mathematica equation: Maximize[{FractionalPart[x/y]/Floor[x/y], x == 2^32 && 2 <= y <= 255 && Element[x | y, Integers]}, {x, y}]

or in traditional notation

image

The 32 can be exchanged with 64 or whatever bits you want to search the maximum possible bias for, and in a more formal format should be rewritten as variable a or the like.

On the other hand, 32-bit, would yield 17881 passwords with a probability of 50% of already having been biased (containing 1 biased character), under the previous assumptions, thereby it cannot be considered insignificant and is being thrown out as a solution. WolframAlpha calculation

D-Nice commented 3 years ago

Other useful resources on randomness/mod bias

https://en.wikipedia.org/wiki/Randomness_extractor#Von_Neumann_extractor https://news.ycombinator.com/item?id=25499164#25500272 https://enacademic.com/dic.nsf/enwiki/13538 https://en.wikipedia.org/wiki/Negligible_function consider the viability of constructing a neglibile function proof? https://dev-notes.eu/2020/06/Pseudo-Random-Numbers-in-a-Range-and-Modulo-Bias/ we essentially achieve an implied discard, by making it probabilistically neglible of occurring. This should avoid a need for this odd special condistion set. However, if the whole world uses it, and avg user generates thousands of passwords, we will have more than enough resources to sufficiently upgrade this implied protection with 128-bit numbers or some other bias nullifier