@noble/curves
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -54,8 +54,9 @@ import { randomBytes } from '@noble/hashes/utils'; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
}>; | ||
export {}; |
@@ -161,6 +161,7 @@ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ | ||
utils: { | ||
_normalizePrivateKey: (key: PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: PrivKey): boolean; | ||
hashToPrivateKey: (hash: Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number, point?: ProjPointType<bigint>) => ProjPointType<bigint>; | ||
}; | ||
@@ -167,0 +168,0 @@ }; |
@@ -711,3 +711,3 @@ "use strict"; | ||
}, | ||
_normalizePrivateKey: normalizePrivateKey, | ||
normPrivateKeyToScalar: normalizePrivateKey, | ||
/** | ||
@@ -846,3 +846,11 @@ * Converts some bytes to a valid private key. Needs at least (nBitLength+64) bytes. | ||
return; | ||
const s = modN(ik * modN(m + modN(d * r))); // s = k^-1(m + rd) mod n | ||
// X blinding according to https://tches.iacr.org/index.php/TCHES/article/view/7337/6509 | ||
// b * m + b * r * d ∈ [0,q−1] exposed via side-channel, but d (private scalar) is not. | ||
// NOTE: there is still probable some leak in multiplication, since it is not constant-time | ||
const b = ut.bytesToNumberBE(utils.randomPrivateKey()); // random scalar, b ∈ [1,q−1] | ||
const bi = invN(b); // b^-1 | ||
const bdr = modN(b * d * r); // b * d * r | ||
const bm = modN(b * m); // b * m | ||
const mrx = modN(bi * modN(bdr + bm)); // b^-1(bm + bdr) -> m + rd | ||
const s = modN(ik * mrx); // s = k^-1(m + rd) mod n | ||
if (s === _0n) | ||
@@ -849,0 +857,0 @@ return; |
@@ -707,3 +707,3 @@ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ | ||
}, | ||
_normalizePrivateKey: normalizePrivateKey, | ||
normPrivateKeyToScalar: normalizePrivateKey, | ||
/** | ||
@@ -842,3 +842,11 @@ * Converts some bytes to a valid private key. Needs at least (nBitLength+64) bytes. | ||
return; | ||
const s = modN(ik * modN(m + modN(d * r))); // s = k^-1(m + rd) mod n | ||
// X blinding according to https://tches.iacr.org/index.php/TCHES/article/view/7337/6509 | ||
// b * m + b * r * d ∈ [0,q−1] exposed via side-channel, but d (private scalar) is not. | ||
// NOTE: there is still probable some leak in multiplication, since it is not constant-time | ||
const b = ut.bytesToNumberBE(utils.randomPrivateKey()); // random scalar, b ∈ [1,q−1] | ||
const bi = invN(b); // b^-1 | ||
const bdr = modN(b * d * r); // b * d * r | ||
const bm = modN(b * m); // b * m | ||
const mrx = modN(bi * modN(bdr + bm)); // b^-1(bm + bdr) -> m + rd | ||
const s = modN(ik * mrx); // s = k^-1(m + rd) mod n | ||
if (s === _0n) | ||
@@ -845,0 +853,0 @@ return; |
@@ -45,6 +45,7 @@ export declare const P192: Readonly<{ | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
@@ -96,7 +97,8 @@ }>; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
}>; |
@@ -45,6 +45,7 @@ export declare const P224: Readonly<{ | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
@@ -96,7 +97,8 @@ }>; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
}>; |
@@ -46,6 +46,7 @@ import * as htf from './abstract/hash-to-curve.js'; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
@@ -97,6 +98,7 @@ }>; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
@@ -103,0 +105,0 @@ }>; |
@@ -46,6 +46,7 @@ import * as htf from './abstract/hash-to-curve.js'; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
@@ -97,6 +98,7 @@ }>; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
@@ -103,0 +105,0 @@ }>; |
@@ -46,6 +46,7 @@ import * as htf from './abstract/hash-to-curve.js'; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
@@ -97,6 +98,7 @@ }>; | ||
utils: { | ||
_normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean; | ||
hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: import("./abstract/weierstrass.js").ProjPointType<bigint> | undefined) => import("./abstract/weierstrass.js").ProjPointType<bigint>; | ||
}; | ||
@@ -103,0 +105,0 @@ }>; |
@@ -49,6 +49,7 @@ import { mod } from './abstract/modular.js'; | ||
utils: { | ||
_normalizePrivateKey: (key: PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: PrivKey): boolean; | ||
hashToPrivateKey: (hash: Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: PointType<bigint> | undefined) => PointType<bigint>; | ||
}; | ||
@@ -55,0 +56,0 @@ }>; |
@@ -43,6 +43,7 @@ import { ProjPointType } from './abstract/weierstrass.js'; | ||
export declare const utils: { | ||
_normalizePrivateKey: (key: cutils.PrivKey) => bigint; | ||
normPrivateKeyToScalar: (key: cutils.PrivKey) => bigint; | ||
isValidPrivateKey(privateKey: cutils.PrivKey): boolean; | ||
hashToPrivateKey: (hash: cutils.Hex) => Uint8Array; | ||
randomPrivateKey: () => Uint8Array; | ||
precompute: (windowSize?: number | undefined, point?: ProjPointType<bigint> | undefined) => ProjPointType<bigint>; | ||
}; | ||
@@ -49,0 +50,0 @@ export { CURVE, Signature, ProjectivePoint, getPublicKey0x as getPublicKey, getSharedSecret0x as getSharedSecret, sign0x as sign, verify0x as verify, }; |
{ | ||
"name": "@noble/curves", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "Minimal, auditable JS implementation of elliptic curve cryptography", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
592048
12349