@noble/curves 1.9.2 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +186 -206
- package/_shortw_utils.d.ts +1 -0
- package/_shortw_utils.d.ts.map +1 -1
- package/_shortw_utils.js +1 -0
- package/_shortw_utils.js.map +1 -1
- package/abstract/bls.d.ts +87 -62
- package/abstract/bls.d.ts.map +1 -1
- package/abstract/bls.js +170 -163
- package/abstract/bls.js.map +1 -1
- package/abstract/curve.d.ts +109 -23
- package/abstract/curve.d.ts.map +1 -1
- package/abstract/curve.js +158 -156
- package/abstract/curve.js.map +1 -1
- package/abstract/edwards.d.ts +124 -70
- package/abstract/edwards.d.ts.map +1 -1
- package/abstract/edwards.js +212 -62
- package/abstract/edwards.js.map +1 -1
- package/abstract/hash-to-curve.d.ts +8 -4
- package/abstract/hash-to-curve.d.ts.map +1 -1
- package/abstract/hash-to-curve.js +23 -11
- package/abstract/hash-to-curve.js.map +1 -1
- package/abstract/modular.d.ts +8 -3
- package/abstract/modular.d.ts.map +1 -1
- package/abstract/modular.js +79 -35
- package/abstract/modular.js.map +1 -1
- package/abstract/montgomery.d.ts +17 -4
- package/abstract/montgomery.d.ts.map +1 -1
- package/abstract/montgomery.js +19 -3
- package/abstract/montgomery.js.map +1 -1
- package/abstract/tower.d.ts +3 -3
- package/abstract/tower.d.ts.map +1 -1
- package/abstract/tower.js.map +1 -1
- package/abstract/weierstrass.d.ts +142 -116
- package/abstract/weierstrass.d.ts.map +1 -1
- package/abstract/weierstrass.js +414 -335
- package/abstract/weierstrass.js.map +1 -1
- package/bls12-381.d.ts.map +1 -1
- package/bls12-381.js +4 -4
- package/bls12-381.js.map +1 -1
- package/ed25519.d.ts +52 -66
- package/ed25519.d.ts.map +1 -1
- package/ed25519.js +128 -155
- package/ed25519.js.map +1 -1
- package/ed448.d.ts +57 -58
- package/ed448.d.ts.map +1 -1
- package/ed448.js +114 -131
- package/ed448.js.map +1 -1
- package/esm/_shortw_utils.d.ts +1 -0
- package/esm/_shortw_utils.d.ts.map +1 -1
- package/esm/_shortw_utils.js +1 -0
- package/esm/_shortw_utils.js.map +1 -1
- package/esm/abstract/bls.d.ts +87 -62
- package/esm/abstract/bls.d.ts.map +1 -1
- package/esm/abstract/bls.js +171 -164
- package/esm/abstract/bls.js.map +1 -1
- package/esm/abstract/curve.d.ts +109 -23
- package/esm/abstract/curve.d.ts.map +1 -1
- package/esm/abstract/curve.js +156 -155
- package/esm/abstract/curve.js.map +1 -1
- package/esm/abstract/edwards.d.ts +124 -70
- package/esm/abstract/edwards.d.ts.map +1 -1
- package/esm/abstract/edwards.js +210 -62
- package/esm/abstract/edwards.js.map +1 -1
- package/esm/abstract/hash-to-curve.d.ts +8 -4
- package/esm/abstract/hash-to-curve.d.ts.map +1 -1
- package/esm/abstract/hash-to-curve.js +22 -11
- package/esm/abstract/hash-to-curve.js.map +1 -1
- package/esm/abstract/modular.d.ts +8 -3
- package/esm/abstract/modular.d.ts.map +1 -1
- package/esm/abstract/modular.js +79 -35
- package/esm/abstract/modular.js.map +1 -1
- package/esm/abstract/montgomery.d.ts +17 -4
- package/esm/abstract/montgomery.d.ts.map +1 -1
- package/esm/abstract/montgomery.js +19 -3
- package/esm/abstract/montgomery.js.map +1 -1
- package/esm/abstract/tower.d.ts +3 -3
- package/esm/abstract/tower.d.ts.map +1 -1
- package/esm/abstract/tower.js.map +1 -1
- package/esm/abstract/weierstrass.d.ts +142 -116
- package/esm/abstract/weierstrass.d.ts.map +1 -1
- package/esm/abstract/weierstrass.js +411 -333
- package/esm/abstract/weierstrass.js.map +1 -1
- package/esm/bls12-381.d.ts.map +1 -1
- package/esm/bls12-381.js +4 -4
- package/esm/bls12-381.js.map +1 -1
- package/esm/ed25519.d.ts +52 -66
- package/esm/ed25519.d.ts.map +1 -1
- package/esm/ed25519.js +131 -157
- package/esm/ed25519.js.map +1 -1
- package/esm/ed448.d.ts +57 -58
- package/esm/ed448.d.ts.map +1 -1
- package/esm/ed448.js +116 -132
- package/esm/ed448.js.map +1 -1
- package/esm/index.js +7 -9
- package/esm/index.js.map +1 -1
- package/esm/jubjub.d.ts +3 -3
- package/esm/jubjub.d.ts.map +1 -1
- package/esm/jubjub.js +3 -3
- package/esm/jubjub.js.map +1 -1
- package/esm/misc.d.ts +3 -5
- package/esm/misc.d.ts.map +1 -1
- package/esm/misc.js +0 -3
- package/esm/misc.js.map +1 -1
- package/esm/nist.d.ts +0 -6
- package/esm/nist.d.ts.map +1 -1
- package/esm/nist.js +31 -15
- package/esm/nist.js.map +1 -1
- package/esm/p256.d.ts +4 -0
- package/esm/p256.d.ts.map +1 -1
- package/esm/p256.js +4 -0
- package/esm/p256.js.map +1 -1
- package/esm/p384.d.ts +4 -1
- package/esm/p384.d.ts.map +1 -1
- package/esm/p384.js +4 -1
- package/esm/p384.js.map +1 -1
- package/esm/p521.d.ts +4 -0
- package/esm/p521.d.ts.map +1 -1
- package/esm/p521.js +4 -0
- package/esm/p521.js.map +1 -1
- package/esm/secp256k1.d.ts +32 -15
- package/esm/secp256k1.d.ts.map +1 -1
- package/esm/secp256k1.js +72 -67
- package/esm/secp256k1.js.map +1 -1
- package/esm/utils.d.ts +1 -1
- package/esm/utils.js +1 -1
- package/index.js +7 -9
- package/index.js.map +1 -1
- package/jubjub.d.ts +3 -3
- package/jubjub.d.ts.map +1 -1
- package/jubjub.js +3 -3
- package/jubjub.js.map +1 -1
- package/misc.d.ts +3 -5
- package/misc.d.ts.map +1 -1
- package/misc.js +0 -3
- package/misc.js.map +1 -1
- package/nist.d.ts +0 -6
- package/nist.d.ts.map +1 -1
- package/nist.js +31 -15
- package/nist.js.map +1 -1
- package/p256.d.ts +4 -0
- package/p256.d.ts.map +1 -1
- package/p256.js +4 -0
- package/p256.js.map +1 -1
- package/p384.d.ts +4 -1
- package/p384.d.ts.map +1 -1
- package/p384.js +4 -1
- package/p384.js.map +1 -1
- package/p521.d.ts +4 -0
- package/p521.d.ts.map +1 -1
- package/p521.js +4 -0
- package/p521.js.map +1 -1
- package/package.json +4 -2
- package/secp256k1.d.ts +32 -15
- package/secp256k1.d.ts.map +1 -1
- package/secp256k1.js +70 -65
- package/secp256k1.js.map +1 -1
- package/src/_shortw_utils.ts +1 -0
- package/src/abstract/bls.ts +319 -257
- package/src/abstract/curve.ts +226 -170
- package/src/abstract/edwards.ts +350 -139
- package/src/abstract/hash-to-curve.ts +33 -16
- package/src/abstract/modular.ts +86 -35
- package/src/abstract/montgomery.ts +36 -9
- package/src/abstract/tower.ts +4 -4
- package/src/abstract/weierstrass.ts +567 -474
- package/src/bls12-381.ts +28 -20
- package/src/ed25519.ts +161 -179
- package/src/ed448.ts +150 -156
- package/src/index.ts +7 -9
- package/src/jubjub.ts +3 -3
- package/src/misc.ts +3 -7
- package/src/nist.ts +40 -16
- package/src/p256.ts +4 -0
- package/src/p384.ts +4 -2
- package/src/p521.ts +4 -0
- package/src/secp256k1.ts +91 -73
- package/src/utils.ts +1 -1
- package/utils.d.ts +1 -1
- package/utils.js +1 -1
package/ed448.d.ts
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
import type { AffinePoint
|
|
2
|
-
import { type CurveFn, type
|
|
3
|
-
import { type H2CHasher, type H2CMethod, type htfBasicOpts } from './abstract/hash-to-curve.ts';
|
|
4
|
-
import { type
|
|
1
|
+
import type { AffinePoint } from './abstract/curve.ts';
|
|
2
|
+
import { PrimeEdwardsPoint, type CurveFn, type EdwardsPoint, type EdwardsPointCons } from './abstract/edwards.ts';
|
|
3
|
+
import { type H2CHasher, type H2CHasherBase, type H2CMethod, type htfBasicOpts } from './abstract/hash-to-curve.ts';
|
|
4
|
+
import { type IField } from './abstract/modular.ts';
|
|
5
|
+
import { type MontgomeryECDH as XCurveFn } from './abstract/montgomery.ts';
|
|
5
6
|
import { type Hex } from './utils.ts';
|
|
6
|
-
export declare const E448: ExtPointConstructor;
|
|
7
7
|
/**
|
|
8
8
|
* ed448 EdDSA curve and methods.
|
|
9
9
|
* @example
|
|
10
10
|
* import { ed448 } from '@noble/curves/ed448';
|
|
11
|
-
* const
|
|
12
|
-
* const
|
|
13
|
-
* const
|
|
14
|
-
* const
|
|
15
|
-
* ed448.verify(sig, msg, pub);
|
|
11
|
+
* const { secretKey, publicKey } = ed448.keygen();
|
|
12
|
+
* const msg = new TextEncoder().encode('hello');
|
|
13
|
+
* const sig = ed448.sign(msg, secretKey);
|
|
14
|
+
* const isValid = ed448.verify(sig, msg, publicKey);
|
|
16
15
|
*/
|
|
17
16
|
export declare const ed448: CurveFn;
|
|
17
|
+
/** Prehashed version of ed448. Accepts already-hashed messages in sign() and verify(). */
|
|
18
18
|
export declare const ed448ph: CurveFn;
|
|
19
|
+
/**
|
|
20
|
+
* E448 curve, defined by NIST.
|
|
21
|
+
* E448 != edwards448 used in ed448.
|
|
22
|
+
* E448 is birationally equivalent to edwards448.
|
|
23
|
+
*/
|
|
24
|
+
export declare const E448: EdwardsPointCons;
|
|
19
25
|
/**
|
|
20
26
|
* ECDH using curve448 aka x448.
|
|
21
27
|
* x448 has 56-byte keys as per RFC 7748, while
|
|
22
28
|
* ed448 has 57-byte keys as per RFC 8032.
|
|
23
29
|
*/
|
|
24
30
|
export declare const x448: XCurveFn;
|
|
25
|
-
/**
|
|
26
|
-
* Converts edwards448 public key to x448 public key. Uses formula:
|
|
27
|
-
* * `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)`
|
|
28
|
-
* * `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))`
|
|
29
|
-
* @example
|
|
30
|
-
* const aPub = ed448.getPublicKey(utils.randomPrivateKey());
|
|
31
|
-
* x448.getSharedSecret(edwardsToMontgomery(aPub), edwardsToMontgomery(someonesPub))
|
|
32
|
-
*/
|
|
31
|
+
/** @deprecated use `ed448.utils.toMontgomery` */
|
|
33
32
|
export declare function edwardsToMontgomeryPub(edwardsPub: string | Uint8Array): Uint8Array;
|
|
33
|
+
/** @deprecated use `ed448.utils.toMontgomery` */
|
|
34
34
|
export declare const edwardsToMontgomery: typeof edwardsToMontgomeryPub;
|
|
35
|
+
/** Hashing / encoding to ed448 points / field. RFC 9380 methods. */
|
|
35
36
|
export declare const ed448_hasher: H2CHasher<bigint>;
|
|
36
|
-
|
|
37
|
-
export declare const encodeToCurve: H2CMethod<bigint>;
|
|
38
|
-
type ExtendedPoint = ExtPointType;
|
|
37
|
+
type ExtendedPoint = EdwardsPoint;
|
|
39
38
|
/**
|
|
40
39
|
* Each ed448/ExtendedPoint has 4 different equivalent points. This can be
|
|
41
40
|
* a source of bugs for protocols like ring signatures. Decaf was created to solve this.
|
|
@@ -43,60 +42,60 @@ type ExtendedPoint = ExtPointType;
|
|
|
43
42
|
* but it should work in its own namespace: do not combine those two.
|
|
44
43
|
* See [RFC9496](https://www.rfc-editor.org/rfc/rfc9496).
|
|
45
44
|
*/
|
|
46
|
-
declare class
|
|
47
|
-
static BASE:
|
|
48
|
-
static ZERO:
|
|
49
|
-
|
|
45
|
+
declare class _DecafPoint extends PrimeEdwardsPoint<_DecafPoint> {
|
|
46
|
+
static BASE: _DecafPoint;
|
|
47
|
+
static ZERO: _DecafPoint;
|
|
48
|
+
static Fp: IField<bigint>;
|
|
49
|
+
static Fn: IField<bigint>;
|
|
50
50
|
constructor(ep: ExtendedPoint);
|
|
51
|
-
static fromAffine(ap: AffinePoint<bigint>):
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* and [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-element-derivation-2).
|
|
58
|
-
* @param hex 112-byte output of a hash function
|
|
59
|
-
*/
|
|
60
|
-
static hashToCurve(hex: Hex): DcfPoint;
|
|
61
|
-
static fromBytes(bytes: Uint8Array): DcfPoint;
|
|
51
|
+
static fromAffine(ap: AffinePoint<bigint>): _DecafPoint;
|
|
52
|
+
protected assertSame(other: _DecafPoint): void;
|
|
53
|
+
protected init(ep: EdwardsPoint): _DecafPoint;
|
|
54
|
+
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
55
|
+
static hashToCurve(hex: Hex): _DecafPoint;
|
|
56
|
+
static fromBytes(bytes: Uint8Array): _DecafPoint;
|
|
62
57
|
/**
|
|
63
58
|
* Converts decaf-encoded string to decaf point.
|
|
64
59
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode-2).
|
|
65
60
|
* @param hex Decaf-encoded 56 bytes. Not every 56-byte string is valid decaf encoding
|
|
66
61
|
*/
|
|
67
|
-
static fromHex(hex: Hex):
|
|
68
|
-
|
|
62
|
+
static fromHex(hex: Hex): _DecafPoint;
|
|
63
|
+
/** @deprecated use `import { pippenger } from '@noble/curves/abstract/curve.js';` */
|
|
64
|
+
static msm(points: _DecafPoint[], scalars: bigint[]): _DecafPoint;
|
|
69
65
|
/**
|
|
70
66
|
* Encodes decaf point to Uint8Array.
|
|
71
67
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-encode-2).
|
|
72
68
|
*/
|
|
73
69
|
toBytes(): Uint8Array;
|
|
74
|
-
/** @deprecated use `toBytes` */
|
|
75
|
-
toRawBytes(): Uint8Array;
|
|
76
|
-
toHex(): string;
|
|
77
|
-
toString(): string;
|
|
78
70
|
/**
|
|
79
71
|
* Compare one point to another.
|
|
80
72
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-equals-2).
|
|
81
73
|
*/
|
|
82
|
-
equals(other:
|
|
83
|
-
|
|
84
|
-
subtract(other: DcfPoint): DcfPoint;
|
|
85
|
-
multiply(scalar: bigint): DcfPoint;
|
|
86
|
-
multiplyUnsafe(scalar: bigint): DcfPoint;
|
|
87
|
-
double(): DcfPoint;
|
|
88
|
-
negate(): DcfPoint;
|
|
74
|
+
equals(other: _DecafPoint): boolean;
|
|
75
|
+
is0(): boolean;
|
|
89
76
|
}
|
|
77
|
+
/** @deprecated use `decaf448.Point` */
|
|
78
|
+
export declare const DecafPoint: typeof _DecafPoint;
|
|
79
|
+
export declare const decaf448: {
|
|
80
|
+
Point: typeof _DecafPoint;
|
|
81
|
+
};
|
|
82
|
+
/** Hashing to decaf448 points / field. RFC 9380 methods. */
|
|
83
|
+
export declare const decaf448_hasher: H2CHasherBase<bigint>;
|
|
84
|
+
type DcfHasher = (msg: Uint8Array, options: htfBasicOpts) => _DecafPoint;
|
|
85
|
+
/** @deprecated use `import { ed448_hasher } from '@noble/curves/ed448.js';` */
|
|
86
|
+
export declare const hashToCurve: H2CMethod<bigint>;
|
|
87
|
+
/** @deprecated use `import { ed448_hasher } from '@noble/curves/ed448.js';` */
|
|
88
|
+
export declare const encodeToCurve: H2CMethod<bigint>;
|
|
89
|
+
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
90
|
+
export declare const hashToDecaf448: DcfHasher;
|
|
91
|
+
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
92
|
+
export declare const hash_to_decaf448: DcfHasher;
|
|
90
93
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* hash-to-curve for decaf448.
|
|
97
|
-
* Described in [RFC9380](https://www.rfc-editor.org/rfc/rfc9380#appendix-C).
|
|
94
|
+
* Weird / bogus points, useful for debugging.
|
|
95
|
+
* Unlike ed25519, there is no ed448 generator point which can produce full T subgroup.
|
|
96
|
+
* Instead, there is a Klein four-group, which spans over 2 independent 2-torsion points:
|
|
97
|
+
* (0, 1), (0, -1), (-1, 0), (1, 0).
|
|
98
98
|
*/
|
|
99
|
-
export declare const
|
|
100
|
-
export declare const hash_to_decaf448: typeof hashToDecaf448;
|
|
99
|
+
export declare const ED448_TORSION_SUBGROUP: string[];
|
|
101
100
|
export {};
|
|
102
101
|
//# sourceMappingURL=ed448.d.ts.map
|
package/ed448.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ed448.d.ts","sourceRoot":"","sources":["src/ed448.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"ed448.d.ts","sourceRoot":"","sources":["src/ed448.ts"],"names":[],"mappings":"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"}
|
package/ed448.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ED448_TORSION_SUBGROUP = exports.hash_to_decaf448 = exports.hashToDecaf448 = exports.encodeToCurve = exports.hashToCurve = exports.decaf448_hasher = exports.decaf448 = exports.DecafPoint = exports.ed448_hasher = exports.edwardsToMontgomery = exports.x448 = exports.E448 = exports.ed448ph = exports.ed448 = void 0;
|
|
4
4
|
exports.edwardsToMontgomeryPub = edwardsToMontgomeryPub;
|
|
5
5
|
/**
|
|
6
6
|
* Edwards448 (not Ed448-Goldilocks) curve with following addons:
|
|
@@ -19,6 +19,7 @@ const hash_to_curve_ts_1 = require("./abstract/hash-to-curve.js");
|
|
|
19
19
|
const modular_ts_1 = require("./abstract/modular.js");
|
|
20
20
|
const montgomery_ts_1 = require("./abstract/montgomery.js");
|
|
21
21
|
const utils_ts_1 = require("./utils.js");
|
|
22
|
+
// edwards448 curve
|
|
22
23
|
// a = 1n
|
|
23
24
|
// d = Fp.neg(39081n)
|
|
24
25
|
// Finite field 2n**448n - 2n**224n - 1n
|
|
@@ -33,9 +34,7 @@ const ed448_CURVE = {
|
|
|
33
34
|
Gx: BigInt('0x4f1970c66bed0ded221d15a622bf36da9e146570470f1767ea6de324a3d3a46412ae1af72ab66511433b80e18b00938e2626a82bc70cc05e'),
|
|
34
35
|
Gy: BigInt('0x693f46716eb6bc248876203756c9c7624bea73736ca3984087789c1e05a0c2d73ad3ff1ce67c39c4fdbd132c4ed7c8ad9808795bf230fa14'),
|
|
35
36
|
};
|
|
36
|
-
// E448
|
|
37
|
-
// E448 is defined by NIST
|
|
38
|
-
// It's birationally equivalent to edwards448
|
|
37
|
+
// E448 NIST curve is identical to edwards448, except for:
|
|
39
38
|
// d = 39082/39081
|
|
40
39
|
// Gx = 3/2
|
|
41
40
|
const E448_CURVE = Object.assign({}, ed448_CURVE, {
|
|
@@ -43,7 +42,6 @@ const E448_CURVE = Object.assign({}, ed448_CURVE, {
|
|
|
43
42
|
Gx: BigInt('0x79a70b2b70400553ae7c9df416c792c61128751ac92969240c25a07d728bdc93e21f7787ed6972249de732f38496cd11698713093e9c04fc'),
|
|
44
43
|
Gy: BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000000000000000000000000000000000000000000001'),
|
|
45
44
|
});
|
|
46
|
-
exports.E448 = (0, edwards_ts_1.edwards)(E448_CURVE);
|
|
47
45
|
const shake256_114 = /* @__PURE__ */ (0, utils_js_1.createHasher)(() => sha3_js_1.shake256.create({ dkLen: 114 }));
|
|
48
46
|
const shake256_64 = /* @__PURE__ */ (0, utils_js_1.createHasher)(() => sha3_js_1.shake256.create({ dkLen: 64 }));
|
|
49
47
|
// prettier-ignore
|
|
@@ -101,13 +99,15 @@ function uvRatio(u, v) {
|
|
|
101
99
|
return { isValid: (0, modular_ts_1.mod)(x2 * v, P) === u, value: x };
|
|
102
100
|
}
|
|
103
101
|
// Finite field 2n**448n - 2n**224n - 1n
|
|
104
|
-
const Fp = /* @__PURE__ */ (() => (0, modular_ts_1.Field)(ed448_CURVE.p, 456, true))();
|
|
102
|
+
const Fp = /* @__PURE__ */ (() => (0, modular_ts_1.Field)(ed448_CURVE.p, { BITS: 456, isLE: true }))();
|
|
105
103
|
// RFC 7748 has 56-byte keys, RFC 8032 has 57-byte keys
|
|
104
|
+
const Fn = /* @__PURE__ */ (() => (0, modular_ts_1.Field)(ed448_CURVE.n, { BITS: 448, isLE: true }))();
|
|
105
|
+
// const Fn456 = /* @__PURE__ */ (() => Field(ed448_CURVE.n, { BITS: 456, isLE: true }))();
|
|
106
106
|
// SHAKE256(dom4(phflag,context)||x, 114)
|
|
107
107
|
const ED448_DEF = /* @__PURE__ */ (() => ({
|
|
108
108
|
...ed448_CURVE,
|
|
109
109
|
Fp,
|
|
110
|
-
|
|
110
|
+
Fn,
|
|
111
111
|
hash: shake256_114,
|
|
112
112
|
adjustScalarBytes,
|
|
113
113
|
// dom4
|
|
@@ -122,18 +122,24 @@ const ED448_DEF = /* @__PURE__ */ (() => ({
|
|
|
122
122
|
* ed448 EdDSA curve and methods.
|
|
123
123
|
* @example
|
|
124
124
|
* import { ed448 } from '@noble/curves/ed448';
|
|
125
|
-
* const
|
|
126
|
-
* const
|
|
127
|
-
* const
|
|
128
|
-
* const
|
|
129
|
-
* ed448.verify(sig, msg, pub);
|
|
125
|
+
* const { secretKey, publicKey } = ed448.keygen();
|
|
126
|
+
* const msg = new TextEncoder().encode('hello');
|
|
127
|
+
* const sig = ed448.sign(msg, secretKey);
|
|
128
|
+
* const isValid = ed448.verify(sig, msg, publicKey);
|
|
130
129
|
*/
|
|
131
130
|
exports.ed448 = (0, edwards_ts_1.twistedEdwards)(ED448_DEF);
|
|
132
|
-
//
|
|
131
|
+
// There is no ed448ctx, since ed448 supports ctx by default
|
|
132
|
+
/** Prehashed version of ed448. Accepts already-hashed messages in sign() and verify(). */
|
|
133
133
|
exports.ed448ph = (() => (0, edwards_ts_1.twistedEdwards)({
|
|
134
134
|
...ED448_DEF,
|
|
135
135
|
prehash: shake256_64,
|
|
136
136
|
}))();
|
|
137
|
+
/**
|
|
138
|
+
* E448 curve, defined by NIST.
|
|
139
|
+
* E448 != edwards448 used in ed448.
|
|
140
|
+
* E448 is birationally equivalent to edwards448.
|
|
141
|
+
*/
|
|
142
|
+
exports.E448 = (0, edwards_ts_1.edwards)(E448_CURVE);
|
|
137
143
|
/**
|
|
138
144
|
* ECDH using curve448 aka x448.
|
|
139
145
|
* x448 has 56-byte keys as per RFC 7748, while
|
|
@@ -152,22 +158,12 @@ exports.x448 = (() => {
|
|
|
152
158
|
adjustScalarBytes,
|
|
153
159
|
});
|
|
154
160
|
})();
|
|
155
|
-
/**
|
|
156
|
-
* Converts edwards448 public key to x448 public key. Uses formula:
|
|
157
|
-
* * `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)`
|
|
158
|
-
* * `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))`
|
|
159
|
-
* @example
|
|
160
|
-
* const aPub = ed448.getPublicKey(utils.randomPrivateKey());
|
|
161
|
-
* x448.getSharedSecret(edwardsToMontgomery(aPub), edwardsToMontgomery(someonesPub))
|
|
162
|
-
*/
|
|
161
|
+
/** @deprecated use `ed448.utils.toMontgomery` */
|
|
163
162
|
function edwardsToMontgomeryPub(edwardsPub) {
|
|
164
|
-
|
|
165
|
-
const { y } = exports.ed448.Point.fromHex(bpub);
|
|
166
|
-
const _1n = BigInt(1);
|
|
167
|
-
return Fp.toBytes(Fp.create((y - _1n) * Fp.inv(y + _1n)));
|
|
163
|
+
return exports.ed448.utils.toMontgomery((0, utils_ts_1.ensureBytes)('pub', edwardsPub));
|
|
168
164
|
}
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
/** @deprecated use `ed448.utils.toMontgomery` */
|
|
166
|
+
exports.edwardsToMontgomery = edwardsToMontgomeryPub;
|
|
171
167
|
// Hash To Curve Elligator2 Map
|
|
172
168
|
const ELL2_C1 = /* @__PURE__ */ (() => (Fp.ORDER - BigInt(3)) / BigInt(4))(); // 1. c1 = (q - 3) / 4 # Integer arithmetic
|
|
173
169
|
const ELL2_J = /* @__PURE__ */ BigInt(156326);
|
|
@@ -241,6 +237,7 @@ function map_to_curve_elligator2_edwards448(u) {
|
|
|
241
237
|
const inv = (0, modular_ts_1.FpInvertBatch)(Fp, [xEd, yEd], true); // batch division
|
|
242
238
|
return { x: Fp.mul(xEn, inv[0]), y: Fp.mul(yEn, inv[1]) }; // 38. return (xEn, xEd, yEn, yEd)
|
|
243
239
|
}
|
|
240
|
+
/** Hashing / encoding to ed448 points / field. RFC 9380 methods. */
|
|
244
241
|
exports.ed448_hasher = (() => (0, hash_to_curve_ts_1.createHasher)(exports.ed448.Point, (scalars) => map_to_curve_elligator2_edwards448(scalars[0]), {
|
|
245
242
|
DST: 'edwards448_XOF:SHAKE256_ELL2_RO_',
|
|
246
243
|
encodeDST: 'edwards448_XOF:SHAKE256_ELL2_NU_',
|
|
@@ -250,12 +247,6 @@ exports.ed448_hasher = (() => (0, hash_to_curve_ts_1.createHasher)(exports.ed448
|
|
|
250
247
|
expand: 'xof',
|
|
251
248
|
hash: sha3_js_1.shake256,
|
|
252
249
|
}))();
|
|
253
|
-
exports.hashToCurve = (() => exports.ed448_hasher.hashToCurve)();
|
|
254
|
-
exports.encodeToCurve = (() => exports.ed448_hasher.encodeToCurve)();
|
|
255
|
-
function adecafp(other) {
|
|
256
|
-
if (!(other instanceof DcfPoint))
|
|
257
|
-
throw new Error('DecafPoint expected');
|
|
258
|
-
}
|
|
259
250
|
// 1-d
|
|
260
251
|
const ONE_MINUS_D = /* @__PURE__ */ BigInt('39082');
|
|
261
252
|
// 1-2d
|
|
@@ -298,6 +289,14 @@ function calcElligatorDecafMap(r0) {
|
|
|
298
289
|
const W3 = mod(v_prime * s * (r - _1n) * ONE_MINUS_TWO_D + sgn); // 11
|
|
299
290
|
return new exports.ed448.Point(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));
|
|
300
291
|
}
|
|
292
|
+
function decaf448_map(bytes) {
|
|
293
|
+
(0, utils_js_1.abytes)(bytes, 112);
|
|
294
|
+
const r1 = bytes448ToNumberLE(bytes.slice(0, 56));
|
|
295
|
+
const R1 = calcElligatorDecafMap(r1);
|
|
296
|
+
const r2 = bytes448ToNumberLE(bytes.slice(56, 112));
|
|
297
|
+
const R2 = calcElligatorDecafMap(r2);
|
|
298
|
+
return new _DecafPoint(R1.add(R2));
|
|
299
|
+
}
|
|
301
300
|
/**
|
|
302
301
|
* Each ed448/ExtendedPoint has 4 different equivalent points. This can be
|
|
303
302
|
* a source of bugs for protocols like ring signatures. Decaf was created to solve this.
|
|
@@ -305,51 +304,34 @@ function calcElligatorDecafMap(r0) {
|
|
|
305
304
|
* but it should work in its own namespace: do not combine those two.
|
|
306
305
|
* See [RFC9496](https://www.rfc-editor.org/rfc/rfc9496).
|
|
307
306
|
*/
|
|
308
|
-
class
|
|
309
|
-
// Private property to discourage combining ExtendedPoint + DecafPoint
|
|
310
|
-
// Always use Decaf encoding/decoding instead.
|
|
307
|
+
class _DecafPoint extends edwards_ts_1.PrimeEdwardsPoint {
|
|
311
308
|
constructor(ep) {
|
|
312
|
-
|
|
309
|
+
super(ep);
|
|
313
310
|
}
|
|
314
311
|
static fromAffine(ap) {
|
|
315
|
-
return new
|
|
312
|
+
return new _DecafPoint(exports.ed448.Point.fromAffine(ap));
|
|
316
313
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
314
|
+
assertSame(other) {
|
|
315
|
+
if (!(other instanceof _DecafPoint))
|
|
316
|
+
throw new Error('DecafPoint expected');
|
|
317
|
+
}
|
|
318
|
+
init(ep) {
|
|
319
|
+
return new _DecafPoint(ep);
|
|
320
|
+
}
|
|
321
|
+
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
325
322
|
static hashToCurve(hex) {
|
|
326
|
-
|
|
327
|
-
const r1 = bytes448ToNumberLE(hex.slice(0, 56));
|
|
328
|
-
const R1 = calcElligatorDecafMap(r1);
|
|
329
|
-
const r2 = bytes448ToNumberLE(hex.slice(56, 112));
|
|
330
|
-
const R2 = calcElligatorDecafMap(r2);
|
|
331
|
-
return new DcfPoint(R1.add(R2));
|
|
323
|
+
return decaf448_map((0, utils_ts_1.ensureBytes)('decafHash', hex, 112));
|
|
332
324
|
}
|
|
333
325
|
static fromBytes(bytes) {
|
|
334
|
-
(0, utils_js_1.abytes)(bytes);
|
|
335
|
-
return this.fromHex(bytes);
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Converts decaf-encoded string to decaf point.
|
|
339
|
-
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode-2).
|
|
340
|
-
* @param hex Decaf-encoded 56 bytes. Not every 56-byte string is valid decaf encoding
|
|
341
|
-
*/
|
|
342
|
-
static fromHex(hex) {
|
|
343
|
-
hex = (0, utils_ts_1.ensureBytes)('decafHex', hex, 56);
|
|
326
|
+
(0, utils_js_1.abytes)(bytes, 56);
|
|
344
327
|
const { d } = exports.ed448.CURVE;
|
|
345
328
|
const P = Fp.ORDER;
|
|
346
329
|
const mod = Fp.create;
|
|
347
|
-
const
|
|
348
|
-
const s = bytes448ToNumberLE(hex);
|
|
330
|
+
const s = bytes448ToNumberLE(bytes);
|
|
349
331
|
// 1. Check that s_bytes is the canonical encoding of a field element, or else abort.
|
|
350
332
|
// 2. Check that s is non-negative, or else abort
|
|
351
|
-
if (!(0, utils_ts_1.equalBytes)((0, utils_ts_1.numberToBytesLE)(s, 56),
|
|
352
|
-
throw new Error(
|
|
333
|
+
if (!(0, utils_ts_1.equalBytes)((0, utils_ts_1.numberToBytesLE)(s, 56), bytes) || (0, modular_ts_1.isNegativeLE)(s, P))
|
|
334
|
+
throw new Error('invalid decaf448 encoding 1');
|
|
353
335
|
const s2 = mod(s * s); // 1
|
|
354
336
|
const u1 = mod(_1n + s2); // 2
|
|
355
337
|
const u1sq = mod(u1 * u1);
|
|
@@ -362,100 +344,101 @@ class DcfPoint {
|
|
|
362
344
|
const y = mod((_1n - s2) * invsqrt * u1); // 7
|
|
363
345
|
const t = mod(x * y); // 8
|
|
364
346
|
if (!isValid)
|
|
365
|
-
throw new Error(
|
|
366
|
-
return new
|
|
347
|
+
throw new Error('invalid decaf448 encoding 2');
|
|
348
|
+
return new _DecafPoint(new exports.ed448.Point(x, y, _1n, t));
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Converts decaf-encoded string to decaf point.
|
|
352
|
+
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode-2).
|
|
353
|
+
* @param hex Decaf-encoded 56 bytes. Not every 56-byte string is valid decaf encoding
|
|
354
|
+
*/
|
|
355
|
+
static fromHex(hex) {
|
|
356
|
+
return _DecafPoint.fromBytes((0, utils_ts_1.ensureBytes)('decafHex', hex, 56));
|
|
367
357
|
}
|
|
358
|
+
/** @deprecated use `import { pippenger } from '@noble/curves/abstract/curve.js';` */
|
|
368
359
|
static msm(points, scalars) {
|
|
369
|
-
|
|
370
|
-
return (0, curve_ts_1.pippenger)(DcfPoint, Fn, points, scalars);
|
|
360
|
+
return (0, curve_ts_1.pippenger)(_DecafPoint, Fn, points, scalars);
|
|
371
361
|
}
|
|
372
362
|
/**
|
|
373
363
|
* Encodes decaf point to Uint8Array.
|
|
374
364
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-encode-2).
|
|
375
365
|
*/
|
|
376
366
|
toBytes() {
|
|
377
|
-
|
|
367
|
+
const { X, Z, T } = this.ep;
|
|
378
368
|
const P = Fp.ORDER;
|
|
379
369
|
const mod = Fp.create;
|
|
380
|
-
const u1 = mod(mod(
|
|
381
|
-
const x2 = mod(
|
|
370
|
+
const u1 = mod(mod(X + T) * mod(X - T)); // 1
|
|
371
|
+
const x2 = mod(X * X);
|
|
382
372
|
const { value: invsqrt } = invertSqrt(mod(u1 * ONE_MINUS_D * x2)); // 2
|
|
383
373
|
let ratio = mod(invsqrt * u1 * SQRT_MINUS_D); // 3
|
|
384
374
|
if ((0, modular_ts_1.isNegativeLE)(ratio, P))
|
|
385
375
|
ratio = mod(-ratio);
|
|
386
|
-
const u2 = mod(INVSQRT_MINUS_D * ratio *
|
|
387
|
-
let s = mod(ONE_MINUS_D * invsqrt *
|
|
376
|
+
const u2 = mod(INVSQRT_MINUS_D * ratio * Z - T); // 4
|
|
377
|
+
let s = mod(ONE_MINUS_D * invsqrt * X * u2); // 5
|
|
388
378
|
if ((0, modular_ts_1.isNegativeLE)(s, P))
|
|
389
379
|
s = mod(-s);
|
|
390
380
|
return (0, utils_ts_1.numberToBytesLE)(s, 56);
|
|
391
381
|
}
|
|
392
|
-
/** @deprecated use `toBytes` */
|
|
393
|
-
toRawBytes() {
|
|
394
|
-
return this.toBytes();
|
|
395
|
-
}
|
|
396
|
-
toHex() {
|
|
397
|
-
return (0, utils_ts_1.bytesToHex)(this.toBytes());
|
|
398
|
-
}
|
|
399
|
-
toString() {
|
|
400
|
-
return this.toHex();
|
|
401
|
-
}
|
|
402
382
|
/**
|
|
403
383
|
* Compare one point to another.
|
|
404
384
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-equals-2).
|
|
405
385
|
*/
|
|
406
386
|
equals(other) {
|
|
407
|
-
|
|
408
|
-
const {
|
|
409
|
-
const {
|
|
387
|
+
this.assertSame(other);
|
|
388
|
+
const { X: X1, Y: Y1 } = this.ep;
|
|
389
|
+
const { X: X2, Y: Y2 } = other.ep;
|
|
410
390
|
const mod = Fp.create;
|
|
411
391
|
// (x1 * y2 == y1 * x2)
|
|
412
392
|
return mod(X1 * Y2) === mod(Y1 * X2);
|
|
413
393
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
return new DcfPoint(this.ep.add(other.ep));
|
|
417
|
-
}
|
|
418
|
-
subtract(other) {
|
|
419
|
-
adecafp(other);
|
|
420
|
-
return new DcfPoint(this.ep.subtract(other.ep));
|
|
421
|
-
}
|
|
422
|
-
multiply(scalar) {
|
|
423
|
-
return new DcfPoint(this.ep.multiply(scalar));
|
|
424
|
-
}
|
|
425
|
-
multiplyUnsafe(scalar) {
|
|
426
|
-
return new DcfPoint(this.ep.multiplyUnsafe(scalar));
|
|
427
|
-
}
|
|
428
|
-
double() {
|
|
429
|
-
return new DcfPoint(this.ep.double());
|
|
430
|
-
}
|
|
431
|
-
negate() {
|
|
432
|
-
return new DcfPoint(this.ep.negate());
|
|
394
|
+
is0() {
|
|
395
|
+
return this.equals(_DecafPoint.ZERO);
|
|
433
396
|
}
|
|
434
397
|
}
|
|
398
|
+
// The following gymnastics is done because typescript strips comments otherwise
|
|
399
|
+
// prettier-ignore
|
|
400
|
+
_DecafPoint.BASE =
|
|
401
|
+
/* @__PURE__ */ (() => new _DecafPoint(exports.ed448.Point.BASE).multiplyUnsafe(_2n))();
|
|
402
|
+
// prettier-ignore
|
|
403
|
+
_DecafPoint.ZERO =
|
|
404
|
+
/* @__PURE__ */ (() => new _DecafPoint(exports.ed448.Point.ZERO))();
|
|
405
|
+
// prettier-ignore
|
|
406
|
+
_DecafPoint.Fp =
|
|
407
|
+
/* @__PURE__ */ Fp;
|
|
408
|
+
// prettier-ignore
|
|
409
|
+
_DecafPoint.Fn =
|
|
410
|
+
/* @__PURE__ */ Fn;
|
|
411
|
+
/** @deprecated use `decaf448.Point` */
|
|
412
|
+
exports.DecafPoint = _DecafPoint;
|
|
413
|
+
exports.decaf448 = { Point: _DecafPoint };
|
|
414
|
+
/** Hashing to decaf448 points / field. RFC 9380 methods. */
|
|
415
|
+
exports.decaf448_hasher = {
|
|
416
|
+
hashToCurve(msg, options) {
|
|
417
|
+
const DST = options?.DST || 'decaf448_XOF:SHAKE256_D448MAP_RO_';
|
|
418
|
+
return decaf448_map((0, hash_to_curve_ts_1.expand_message_xof)(msg, DST, 112, 224, sha3_js_1.shake256));
|
|
419
|
+
},
|
|
420
|
+
hashToScalar(msg, options = { DST: hash_to_curve_ts_1._DST_scalar }) {
|
|
421
|
+
return Fn.create((0, utils_ts_1.bytesToNumberLE)((0, hash_to_curve_ts_1.expand_message_xof)(msg, options.DST, 64, 256, sha3_js_1.shake256)));
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
/** @deprecated use `import { ed448_hasher } from '@noble/curves/ed448.js';` */
|
|
425
|
+
exports.hashToCurve = (() => exports.ed448_hasher.hashToCurve)();
|
|
426
|
+
/** @deprecated use `import { ed448_hasher } from '@noble/curves/ed448.js';` */
|
|
427
|
+
exports.encodeToCurve = (() => exports.ed448_hasher.encodeToCurve)();
|
|
428
|
+
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
429
|
+
exports.hashToDecaf448 = (() => exports.decaf448_hasher.hashToCurve)();
|
|
430
|
+
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
431
|
+
exports.hash_to_decaf448 = (() => exports.decaf448_hasher.hashToCurve)();
|
|
435
432
|
/**
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
// decaf448 base point is ed448 base x 2
|
|
441
|
-
// https://github.com/dalek-cryptography/curve25519-dalek/blob/59837c6ecff02b77b9d5ff84dbc239d0cf33ef90/vendor/ristretto.sage#L699
|
|
442
|
-
if (!DcfPoint.BASE)
|
|
443
|
-
DcfPoint.BASE = new DcfPoint(exports.ed448.Point.BASE).multiply(_2n);
|
|
444
|
-
if (!DcfPoint.ZERO)
|
|
445
|
-
DcfPoint.ZERO = new DcfPoint(exports.ed448.Point.ZERO);
|
|
446
|
-
return DcfPoint;
|
|
447
|
-
})();
|
|
448
|
-
/**
|
|
449
|
-
* hash-to-curve for decaf448.
|
|
450
|
-
* Described in [RFC9380](https://www.rfc-editor.org/rfc/rfc9380#appendix-C).
|
|
433
|
+
* Weird / bogus points, useful for debugging.
|
|
434
|
+
* Unlike ed25519, there is no ed448 generator point which can produce full T subgroup.
|
|
435
|
+
* Instead, there is a Klein four-group, which spans over 2 independent 2-torsion points:
|
|
436
|
+
* (0, 1), (0, -1), (-1, 0), (1, 0).
|
|
451
437
|
*/
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
};
|
|
459
|
-
exports.hashToDecaf448 = hashToDecaf448;
|
|
460
|
-
exports.hash_to_decaf448 = exports.hashToDecaf448; // legacy
|
|
438
|
+
exports.ED448_TORSION_SUBGROUP = [
|
|
439
|
+
'010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
440
|
+
'fefffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffff00',
|
|
441
|
+
'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
442
|
+
'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080',
|
|
443
|
+
];
|
|
461
444
|
//# sourceMappingURL=ed448.js.map
|