Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Jan 17, 2022
1 parent 4a3616a commit 64e9da7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
12 changes: 1 addition & 11 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,17 +601,7 @@ function mod(a: bigint, b: bigint = CURVE.P) {
return res >= _0n ? res : b + res;
}

function powMod(a: bigint, power: bigint, modulo: bigint): bigint {
let res = 1n;
while (power > 0n) {
if (power & 1n) res = (res * a) % modulo;
a = (a * a) % modulo;
power >>= 1n;
}
return res;
}

// Note: this egcd-based invert is faster than powMod-based one.
// Note: this egcd-based invert is 50% faster than powMod-based one.
// Inverses number over modulo
function invert(number: bigint, modulo: bigint = CURVE.P): bigint {
if (number === _0n || modulo <= _0n) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"signature",
"ecc",
"eddsa",
"ecdsa",
"RFC7748",
"RFC8032",
"cryptography",
"security"
],
Expand Down

0 comments on commit 64e9da7

Please sign in to comment.