@noble/curves 0.7.1 → 0.7.2
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 +17 -12
- package/abstract/montgomery.d.ts +4 -0
- package/abstract/montgomery.d.ts.map +1 -1
- package/abstract/montgomery.js +1 -0
- package/abstract/montgomery.js.map +1 -1
- package/ed25519.d.ts.map +1 -1
- package/ed25519.js +1 -0
- package/ed25519.js.map +1 -1
- package/ed448.d.ts.map +1 -1
- package/ed448.js +1 -0
- package/ed448.js.map +1 -1
- package/esm/abstract/montgomery.js +1 -0
- package/esm/abstract/montgomery.js.map +1 -1
- package/esm/ed25519.js +1 -0
- package/esm/ed25519.js.map +1 -1
- package/esm/ed448.js +1 -0
- package/esm/ed448.js.map +1 -1
- package/esm/stark.js +75 -114
- package/esm/stark.js.map +1 -1
- package/package.json +2 -12
- package/src/abstract/montgomery.ts +3 -0
- package/src/ed25519.ts +1 -0
- package/src/ed448.ts +1 -0
- package/src/stark.ts +92 -130
- package/stark.d.ts +12 -17
- package/stark.d.ts.map +1 -1
- package/stark.js +81 -122
- package/stark.js.map +1 -1
- package/esm/p192.js +0 -22
- package/esm/p192.js.map +0 -1
- package/esm/p224.js +0 -22
- package/esm/p224.js.map +0 -1
- package/p192.d.ts +0 -101
- package/p192.d.ts.map +0 -1
- package/p192.js +0 -25
- package/p192.js.map +0 -1
- package/p224.d.ts +0 -101
- package/p224.d.ts.map +0 -1
- package/p224.js +0 -25
- package/p224.js.map +0 -1
- package/src/p192.ts +0 -25
- package/src/p224.ts +0 -25
package/src/stark.ts
CHANGED
|
@@ -1,164 +1,126 @@
|
|
|
1
1
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
2
|
import { keccak_256 } from '@noble/hashes/sha3';
|
|
3
3
|
import { sha256 } from '@noble/hashes/sha256';
|
|
4
|
-
import {
|
|
5
|
-
import * as cutils from './abstract/utils.js';
|
|
4
|
+
import { utf8ToBytes } from '@noble/hashes/utils';
|
|
6
5
|
import { Fp, mod, Field, validateField } from './abstract/modular.js';
|
|
6
|
+
import { poseidon } from './abstract/poseidon.js';
|
|
7
|
+
import { weierstrass, ProjPointType, SignatureType } from './abstract/weierstrass.js';
|
|
8
|
+
import {
|
|
9
|
+
Hex,
|
|
10
|
+
bitMask,
|
|
11
|
+
bytesToHex,
|
|
12
|
+
bytesToNumberBE,
|
|
13
|
+
concatBytes,
|
|
14
|
+
ensureBytes as ensureBytesOrig,
|
|
15
|
+
hexToBytes,
|
|
16
|
+
hexToNumber,
|
|
17
|
+
numberToVarBytesBE,
|
|
18
|
+
} from './abstract/utils.js';
|
|
7
19
|
import { getHash } from './_shortw_utils.js';
|
|
8
|
-
import * as poseidon from './abstract/poseidon.js';
|
|
9
|
-
import { utf8ToBytes } from '@noble/hashes/utils';
|
|
10
20
|
|
|
11
|
-
type ProjectivePoint = ProjPointType<bigint>;
|
|
12
21
|
// Stark-friendly elliptic curve
|
|
13
22
|
// https://docs.starkware.co/starkex/stark-curve.html
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
type ProjectivePoint = ProjPointType<bigint>;
|
|
25
|
+
const CURVE_ORDER = BigInt(
|
|
16
26
|
'3618502788666131213697322783095070105526743751716087489154079457884512865583'
|
|
17
27
|
);
|
|
18
28
|
const nBitLength = 252;
|
|
19
|
-
// Copy-pasted from weierstrass.ts
|
|
20
29
|
function bits2int(bytes: Uint8Array): bigint {
|
|
30
|
+
while (bytes[0] === 0) bytes = bytes.subarray(1); // strip leading 0s
|
|
31
|
+
// Copy-pasted from weierstrass.ts
|
|
21
32
|
const delta = bytes.length * 8 - nBitLength;
|
|
22
|
-
const num =
|
|
33
|
+
const num = bytesToNumberBE(bytes);
|
|
23
34
|
return delta > 0 ? num >> BigInt(delta) : num;
|
|
24
35
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
36
|
+
function hex0xToBytes(hex: string): Uint8Array {
|
|
37
|
+
if (typeof hex === 'string') {
|
|
38
|
+
hex = strip0x(hex); // allow 0x prefix
|
|
39
|
+
if (hex.length & 1) hex = '0' + hex; // allow unpadded hex
|
|
40
|
+
}
|
|
41
|
+
return hexToBytes(hex);
|
|
27
42
|
}
|
|
28
|
-
|
|
29
|
-
// Params: a, b
|
|
30
|
-
a: BigInt(1),
|
|
43
|
+
const curve = weierstrass({
|
|
44
|
+
a: BigInt(1), // Params: a, b
|
|
31
45
|
b: BigInt('3141592653589793238462643383279502884197169399375105820974944592307816406665'),
|
|
32
46
|
// Field over which we'll do calculations; 2n**251n + 17n * 2n**192n + 1n
|
|
33
47
|
// There is no efficient sqrt for field (P%4==1)
|
|
34
48
|
Fp: Fp(BigInt('0x800000000000011000000000000000000000000000000000000000000000001')),
|
|
35
|
-
// Curve order, total count of valid points in the field.
|
|
36
|
-
|
|
37
|
-
nBitLength: nBitLength, // len(bin(N).replace('0b',''))
|
|
49
|
+
n: CURVE_ORDER, // Curve order, total count of valid points in the field.
|
|
50
|
+
nBitLength, // len(bin(N).replace('0b',''))
|
|
38
51
|
// Base point (x, y) aka generator point
|
|
39
52
|
Gx: BigInt('874739451078007766457464989774322083649278607533249481151382481072868806602'),
|
|
40
53
|
Gy: BigInt('152666792071518830868575557812948353041420400780739481342941381225525861407'),
|
|
41
|
-
h: BigInt(1),
|
|
42
|
-
//
|
|
43
|
-
lowS: false,
|
|
54
|
+
h: BigInt(1), // cofactor
|
|
55
|
+
lowS: false, // Allow high-s signatures
|
|
44
56
|
...getHash(sha256),
|
|
45
57
|
// Custom truncation routines for stark curve
|
|
46
|
-
bits2int
|
|
47
|
-
while (bytes[0] === 0) bytes = bytes.subarray(1);
|
|
48
|
-
return bits2int(bytes);
|
|
49
|
-
},
|
|
58
|
+
bits2int,
|
|
50
59
|
bits2int_modN: (bytes: Uint8Array): bigint => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// Truncate zero bytes on left (compat with elliptic)
|
|
57
|
-
while (bytes[0] === 0) bytes = bytes.subarray(1);
|
|
58
|
-
return bits2int_modN(bytes);
|
|
60
|
+
// 2102820b232636d200cb21f1d330f20d096cae09d1bf3edb1cc333ddee11318 =>
|
|
61
|
+
// 2102820b232636d200cb21f1d330f20d096cae09d1bf3edb1cc333ddee113180
|
|
62
|
+
const hex = bytesToNumberBE(bytes).toString(16); // toHex unpadded
|
|
63
|
+
if (hex.length === 63) bytes = hex0xToBytes(hex + '0'); // append trailing 0
|
|
64
|
+
return mod(bits2int(bytes), CURVE_ORDER);
|
|
59
65
|
},
|
|
60
66
|
});
|
|
67
|
+
export const _starkCurve = curve;
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (typeof hex !== 'string') {
|
|
65
|
-
throw new Error('hexToBytes: expected string, got ' + typeof hex);
|
|
66
|
-
}
|
|
67
|
-
hex = strip0x(hex);
|
|
68
|
-
if (hex.length & 1) hex = '0' + hex; // padding
|
|
69
|
-
if (hex.length % 2) throw new Error('hexToBytes: received invalid unpadded hex ' + hex.length);
|
|
70
|
-
const array = new Uint8Array(hex.length / 2);
|
|
71
|
-
for (let i = 0; i < array.length; i++) {
|
|
72
|
-
const j = i * 2;
|
|
73
|
-
const hexByte = hex.slice(j, j + 2);
|
|
74
|
-
const byte = Number.parseInt(hexByte, 16);
|
|
75
|
-
if (Number.isNaN(byte) || byte < 0) throw new Error('Invalid byte sequence');
|
|
76
|
-
array[i] = byte;
|
|
77
|
-
}
|
|
78
|
-
return array;
|
|
79
|
-
}
|
|
80
|
-
function hexToNumber0x(hex: string): bigint {
|
|
81
|
-
if (typeof hex !== 'string') {
|
|
82
|
-
throw new Error('hexToNumber: expected string, got ' + typeof hex);
|
|
83
|
-
}
|
|
84
|
-
// Big Endian
|
|
85
|
-
// TODO: strip vs no strip?
|
|
86
|
-
return BigInt(`0x${strip0x(hex)}`);
|
|
87
|
-
}
|
|
88
|
-
function bytesToNumber0x(bytes: Uint8Array): bigint {
|
|
89
|
-
return hexToNumber0x(cutils.bytesToHex(bytes));
|
|
90
|
-
}
|
|
91
|
-
function ensureBytes0x(hex: Hex): Uint8Array {
|
|
92
|
-
// Uint8Array.from() instead of hash.slice() because node.js Buffer
|
|
93
|
-
// is instance of Uint8Array, and its slice() creates **mutable** copy
|
|
94
|
-
return hex instanceof Uint8Array ? Uint8Array.from(hex) : hexToBytes0x(hex);
|
|
69
|
+
function ensureBytes(hex: Hex): Uint8Array {
|
|
70
|
+
return ensureBytesOrig('', typeof hex === 'string' ? hex0xToBytes(hex) : hex);
|
|
95
71
|
}
|
|
96
72
|
|
|
97
|
-
function normPrivKey(privKey: Hex) {
|
|
98
|
-
return
|
|
73
|
+
function normPrivKey(privKey: Hex): string {
|
|
74
|
+
return bytesToHex(ensureBytes(privKey)).padStart(64, '0');
|
|
99
75
|
}
|
|
100
|
-
function
|
|
101
|
-
return
|
|
76
|
+
export function getPublicKey(privKey: Hex, isCompressed = false): Uint8Array {
|
|
77
|
+
return curve.getPublicKey(normPrivKey(privKey), isCompressed);
|
|
102
78
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
79
|
+
export function getSharedSecret(privKeyA: Hex, pubKeyB: Hex): Uint8Array {
|
|
80
|
+
return curve.getSharedSecret(normPrivKey(privKeyA), pubKeyB);
|
|
105
81
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (typeof privKey === 'string') privKey = strip0x(privKey).padStart(64, '0');
|
|
109
|
-
return starkCurve.sign(ensureBytes0x(msgHash), normPrivKey(privKey), opts);
|
|
82
|
+
export function sign(msgHash: Hex, privKey: Hex, opts?: any): SignatureType {
|
|
83
|
+
return curve.sign(ensureBytes(msgHash), normPrivKey(privKey), opts);
|
|
110
84
|
}
|
|
111
|
-
function
|
|
112
|
-
const sig = signature instanceof Signature ? signature :
|
|
113
|
-
return
|
|
85
|
+
export function verify(signature: SignatureType | Hex, msgHash: Hex, pubKey: Hex) {
|
|
86
|
+
const sig = signature instanceof Signature ? signature : ensureBytes(signature);
|
|
87
|
+
return curve.verify(sig, ensureBytes(msgHash), ensureBytes(pubKey));
|
|
114
88
|
}
|
|
115
89
|
|
|
116
|
-
const { CURVE, ProjectivePoint, Signature } =
|
|
117
|
-
export
|
|
118
|
-
export {
|
|
119
|
-
CURVE,
|
|
120
|
-
Signature,
|
|
121
|
-
ProjectivePoint,
|
|
122
|
-
getPublicKey0x as getPublicKey,
|
|
123
|
-
getSharedSecret0x as getSharedSecret,
|
|
124
|
-
sign0x as sign,
|
|
125
|
-
verify0x as verify,
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const stripLeadingZeros = (s: string) => s.replace(/^0+/gm, '');
|
|
129
|
-
export const bytesToHexEth = (uint8a: Uint8Array): string =>
|
|
130
|
-
`0x${stripLeadingZeros(cutils.bytesToHex(uint8a))}`;
|
|
131
|
-
export const strip0x = (hex: string) => hex.replace(/^0x/i, '');
|
|
132
|
-
export const numberToHexEth = (num: bigint | number) => `0x${num.toString(16)}`;
|
|
90
|
+
const { CURVE, ProjectivePoint, Signature, utils } = curve;
|
|
91
|
+
export { CURVE, ProjectivePoint, Signature, utils };
|
|
133
92
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
93
|
+
function extractX(bytes: Uint8Array): string {
|
|
94
|
+
const hex = bytesToHex(bytes.subarray(1));
|
|
95
|
+
const stripped = hex.replace(/^0+/gm, ''); // strip leading 0s
|
|
96
|
+
return `0x${stripped}`;
|
|
97
|
+
}
|
|
98
|
+
function strip0x(hex: string) {
|
|
99
|
+
return hex.replace(/^0x/i, '');
|
|
100
|
+
}
|
|
101
|
+
function numberTo0x16(num: bigint) {
|
|
102
|
+
// can't use utils.numberToHexUnpadded: adds leading 0 for even byte length
|
|
103
|
+
return `0x${num.toString(16)}`;
|
|
142
104
|
}
|
|
143
105
|
|
|
106
|
+
// seed generation
|
|
144
107
|
export function grindKey(seed: Hex) {
|
|
145
|
-
const _seed =
|
|
108
|
+
const _seed = ensureBytes(seed);
|
|
146
109
|
const sha256mask = 2n ** 256n;
|
|
147
|
-
|
|
148
|
-
const limit = sha256mask - mod(sha256mask, CURVE_N);
|
|
110
|
+
const limit = sha256mask - mod(sha256mask, CURVE_ORDER);
|
|
149
111
|
for (let i = 0; ; i++) {
|
|
150
|
-
const key =
|
|
151
|
-
// key should be in [0, limit)
|
|
152
|
-
if (
|
|
112
|
+
const key = sha256Num(concatBytes(_seed, numberToVarBytesBE(BigInt(i))));
|
|
113
|
+
if (key < limit) return mod(key, CURVE_ORDER).toString(16); // key should be in [0, limit)
|
|
114
|
+
if (i === 100000) throw new Error('grindKey is broken: tried 100k vals'); // prevent dos
|
|
153
115
|
}
|
|
154
116
|
}
|
|
155
117
|
|
|
156
|
-
export function getStarkKey(privateKey: Hex) {
|
|
157
|
-
return
|
|
118
|
+
export function getStarkKey(privateKey: Hex): string {
|
|
119
|
+
return extractX(getPublicKey(privateKey, true));
|
|
158
120
|
}
|
|
159
121
|
|
|
160
|
-
export function ethSigToPrivate(signature: string) {
|
|
161
|
-
signature = strip0x(signature
|
|
122
|
+
export function ethSigToPrivate(signature: string): string {
|
|
123
|
+
signature = strip0x(signature);
|
|
162
124
|
if (signature.length !== 130) throw new Error('Wrong ethereum signature');
|
|
163
125
|
return grindKey(signature.substring(0, 64));
|
|
164
126
|
}
|
|
@@ -170,15 +132,15 @@ export function getAccountPath(
|
|
|
170
132
|
application: string,
|
|
171
133
|
ethereumAddress: string,
|
|
172
134
|
index: number
|
|
173
|
-
) {
|
|
135
|
+
): string {
|
|
174
136
|
const layerNum = int31(sha256Num(layer));
|
|
175
137
|
const applicationNum = int31(sha256Num(application));
|
|
176
|
-
const eth =
|
|
138
|
+
const eth = hexToNumber(strip0x(ethereumAddress));
|
|
177
139
|
return `m/2645'/${layerNum}'/${applicationNum}'/${int31(eth)}'/${int31(eth >> 31n)}'/${index}`;
|
|
178
140
|
}
|
|
179
141
|
|
|
180
142
|
// https://docs.starkware.co/starkex/pedersen-hash-function.html
|
|
181
|
-
const
|
|
143
|
+
const PEDERSEN_POINTS = [
|
|
182
144
|
new ProjectivePoint(
|
|
183
145
|
2089986280348253421170679821480865132823066470938446095505822317253594081284n,
|
|
184
146
|
1713931329540660377023406109199410414810705867260802078187082345529207694986n,
|
|
@@ -205,8 +167,6 @@ const PEDERSEN_POINTS_AFFINE = [
|
|
|
205
167
|
1n
|
|
206
168
|
),
|
|
207
169
|
];
|
|
208
|
-
// for (const p of PEDERSEN_POINTS) p._setWindowSize(8);
|
|
209
|
-
const PEDERSEN_POINTS = PEDERSEN_POINTS_AFFINE;
|
|
210
170
|
|
|
211
171
|
function pedersenPrecompute(p1: ProjectivePoint, p2: ProjectivePoint): ProjectivePoint[] {
|
|
212
172
|
const out: ProjectivePoint[] = [];
|
|
@@ -230,14 +190,16 @@ const PEDERSEN_POINTS2 = pedersenPrecompute(PEDERSEN_POINTS[3], PEDERSEN_POINTS[
|
|
|
230
190
|
type PedersenArg = Hex | bigint | number;
|
|
231
191
|
function pedersenArg(arg: PedersenArg): bigint {
|
|
232
192
|
let value: bigint;
|
|
233
|
-
if (typeof arg === 'bigint')
|
|
234
|
-
|
|
193
|
+
if (typeof arg === 'bigint') {
|
|
194
|
+
value = arg;
|
|
195
|
+
} else if (typeof arg === 'number') {
|
|
235
196
|
if (!Number.isSafeInteger(arg)) throw new Error(`Invalid pedersenArg: ${arg}`);
|
|
236
197
|
value = BigInt(arg);
|
|
237
|
-
} else
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
198
|
+
} else {
|
|
199
|
+
value = bytesToNumberBE(ensureBytes(arg));
|
|
200
|
+
}
|
|
201
|
+
if (!(0n <= value && value < curve.CURVE.Fp.ORDER))
|
|
202
|
+
throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${value}`); // [0..Fp)
|
|
241
203
|
return value;
|
|
242
204
|
}
|
|
243
205
|
|
|
@@ -253,17 +215,17 @@ function pedersenSingle(point: ProjectivePoint, value: PedersenArg, constants: P
|
|
|
253
215
|
}
|
|
254
216
|
|
|
255
217
|
// shift_point + x_low * P_0 + x_high * P1 + y_low * P2 + y_high * P3
|
|
256
|
-
export function pedersen(x: PedersenArg, y: PedersenArg) {
|
|
218
|
+
export function pedersen(x: PedersenArg, y: PedersenArg): string {
|
|
257
219
|
let point: ProjectivePoint = PEDERSEN_POINTS[0];
|
|
258
220
|
point = pedersenSingle(point, x, PEDERSEN_POINTS1);
|
|
259
221
|
point = pedersenSingle(point, y, PEDERSEN_POINTS2);
|
|
260
|
-
return
|
|
222
|
+
return extractX(point.toRawBytes(true));
|
|
261
223
|
}
|
|
262
224
|
|
|
263
225
|
export function hashChain(data: PedersenArg[], fn = pedersen) {
|
|
264
226
|
if (!Array.isArray(data) || data.length < 1)
|
|
265
227
|
throw new Error('data should be array of at least 1 element');
|
|
266
|
-
if (data.length === 1) return
|
|
228
|
+
if (data.length === 1) return numberTo0x16(pedersenArg(data[0]));
|
|
267
229
|
return Array.from(data)
|
|
268
230
|
.reverse()
|
|
269
231
|
.reduce((acc, i) => fn(i, acc));
|
|
@@ -272,9 +234,9 @@ export function hashChain(data: PedersenArg[], fn = pedersen) {
|
|
|
272
234
|
export const computeHashOnElements = (data: PedersenArg[], fn = pedersen) =>
|
|
273
235
|
[0, ...data, data.length].reduce((x, y) => fn(x, y));
|
|
274
236
|
|
|
275
|
-
const MASK_250 =
|
|
276
|
-
export const keccak = (data: Uint8Array): bigint =>
|
|
277
|
-
const sha256Num = (data: Uint8Array | string): bigint =>
|
|
237
|
+
const MASK_250 = bitMask(250);
|
|
238
|
+
export const keccak = (data: Uint8Array): bigint => bytesToNumberBE(keccak_256(data)) & MASK_250;
|
|
239
|
+
const sha256Num = (data: Uint8Array | string): bigint => bytesToNumberBE(sha256(data));
|
|
278
240
|
|
|
279
241
|
// Poseidon hash
|
|
280
242
|
export const Fp253 = Fp(
|
|
@@ -330,7 +292,7 @@ export function poseidonBasic(opts: PoseidonOpts, mds: bigint[][]) {
|
|
|
330
292
|
for (let j = 0; j < m; j++) row.push(poseidonRoundConstant(opts.Fp, 'Hades', m * i + j));
|
|
331
293
|
roundConstants.push(row);
|
|
332
294
|
}
|
|
333
|
-
return poseidon
|
|
295
|
+
return poseidon({
|
|
334
296
|
...opts,
|
|
335
297
|
t: m,
|
|
336
298
|
sboxPower: 3,
|
package/stark.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ProjPointType } from './abstract/weierstrass.js';
|
|
2
|
-
import * as cutils from './abstract/utils.js';
|
|
3
1
|
import { Field } from './abstract/modular.js';
|
|
2
|
+
import { ProjPointType, SignatureType } from './abstract/weierstrass.js';
|
|
3
|
+
import { Hex } from './abstract/utils.js';
|
|
4
4
|
declare type ProjectivePoint = ProjPointType<bigint>;
|
|
5
|
-
export declare const
|
|
6
|
-
declare function
|
|
7
|
-
declare function
|
|
8
|
-
declare function
|
|
9
|
-
declare function
|
|
5
|
+
export declare const _starkCurve: import("./abstract/weierstrass.js").CurveFn;
|
|
6
|
+
export declare function getPublicKey(privKey: Hex, isCompressed?: boolean): Uint8Array;
|
|
7
|
+
export declare function getSharedSecret(privKeyA: Hex, pubKeyB: Hex): Uint8Array;
|
|
8
|
+
export declare function sign(msgHash: Hex, privKey: Hex, opts?: any): SignatureType;
|
|
9
|
+
export declare function verify(signature: SignatureType | Hex, msgHash: Hex, pubKey: Hex): boolean;
|
|
10
10
|
declare const CURVE: Readonly<{
|
|
11
11
|
readonly nBitLength: number;
|
|
12
12
|
readonly nByteLength: number;
|
|
@@ -32,24 +32,19 @@ declare const CURVE: Readonly<{
|
|
|
32
32
|
} | undefined;
|
|
33
33
|
readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: ProjPointType<bigint>) => boolean) | undefined;
|
|
34
34
|
readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: ProjPointType<bigint>) => ProjPointType<bigint>) | undefined;
|
|
35
|
-
readonly hash:
|
|
35
|
+
readonly hash: import("./abstract/utils.js").CHash;
|
|
36
36
|
readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
|
|
37
37
|
readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
|
|
38
38
|
lowS: boolean;
|
|
39
39
|
readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
|
|
40
40
|
readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
|
|
41
|
-
}>, ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>, Signature: import("./abstract/weierstrass.js").SignatureConstructor
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
isValidPrivateKey(privateKey: cutils.PrivKey): boolean;
|
|
41
|
+
}>, ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>, Signature: import("./abstract/weierstrass.js").SignatureConstructor, utils: {
|
|
42
|
+
normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint;
|
|
43
|
+
isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
|
|
45
44
|
randomPrivateKey: () => Uint8Array;
|
|
46
45
|
precompute: (windowSize?: number | undefined, point?: ProjPointType<bigint> | undefined) => ProjPointType<bigint>;
|
|
47
46
|
};
|
|
48
|
-
export { CURVE,
|
|
49
|
-
export declare const bytesToHexEth: (uint8a: Uint8Array) => string;
|
|
50
|
-
export declare const strip0x: (hex: string) => string;
|
|
51
|
-
export declare const numberToHexEth: (num: bigint | number) => string;
|
|
52
|
-
declare type Hex = Uint8Array | string;
|
|
47
|
+
export { CURVE, ProjectivePoint, Signature, utils };
|
|
53
48
|
export declare function grindKey(seed: Hex): string;
|
|
54
49
|
export declare function getStarkKey(privateKey: Hex): string;
|
|
55
50
|
export declare function ethSigToPrivate(signature: string): string;
|
package/stark.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stark.d.ts","sourceRoot":"","sources":["src/stark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