mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
Add code comment for impossible error (#86)
This commit is contained in:
@@ -20,6 +20,14 @@ function deriveScalar(bytes, discrim?: number) {
|
||||
return key
|
||||
}
|
||||
}
|
||||
/* This error is practically impossible to reach.
|
||||
* The order of the curve describes the (finite) amount of points on the curve
|
||||
* https://github.com/indutny/elliptic/blob/master/lib/elliptic/curves.js#L182
|
||||
* How often will an (essentially) random number generated by Sha512 be larger than that?
|
||||
* There's 2^32 chances (the for loop) to get a number smaller than the order,
|
||||
* so it's rare that you'll even get past the first loop iteration.
|
||||
* Note that in TypeScript we actually need the throw, otherwise the function signature would be BN | undefined
|
||||
*/
|
||||
/* istanbul ignore next */
|
||||
throw new Error('impossible unicorn ;)')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user