@aztec/foundation 3.0.0-canary.a9708bd → 3.0.0-devnet.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/dest/collection/object.d.ts +4 -0
- package/dest/collection/object.d.ts.map +1 -1
- package/dest/collection/object.js +6 -0
- package/dest/config/env_var.d.ts +1 -1
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +2 -0
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +2 -1
- package/dest/config/network_config.d.ts +42 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +9 -0
- package/dest/config/network_name.d.ts +1 -1
- package/dest/config/network_name.d.ts.map +1 -1
- package/dest/config/network_name.js +10 -2
- package/dest/crypto/aes128/index.d.ts.map +1 -1
- package/dest/crypto/aes128/index.js +23 -6
- package/dest/crypto/ecdsa/index.d.ts.map +1 -1
- package/dest/crypto/ecdsa/index.js +66 -48
- package/dest/crypto/grumpkin/index.d.ts.map +1 -1
- package/dest/crypto/grumpkin/index.js +64 -43
- package/dest/crypto/keys/index.js +9 -4
- package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -1
- package/dest/crypto/pedersen/pedersen.wasm.js +29 -13
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +42 -17
- package/dest/crypto/schnorr/index.d.ts.map +1 -1
- package/dest/crypto/schnorr/index.js +35 -37
- package/dest/crypto/secp256k1/index.d.ts.map +1 -1
- package/dest/crypto/secp256k1/index.js +29 -18
- package/dest/crypto/secp256k1-signer/utils.d.ts +8 -0
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
- package/dest/crypto/secp256k1-signer/utils.js +14 -0
- package/dest/crypto/sync/index.js +3 -1
- package/dest/crypto/sync/pedersen/index.d.ts.map +1 -1
- package/dest/crypto/sync/pedersen/index.js +17 -10
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/sync/poseidon/index.js +27 -12
- package/dest/eth-address/index.d.ts +2 -2
- package/dest/eth-address/index.d.ts.map +1 -1
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/eth-signature/eth_signature.js +2 -4
- package/dest/fields/bls12_point.d.ts +7 -7
- package/dest/fields/bls12_point.js +7 -7
- package/dest/fields/fields.d.ts.map +1 -1
- package/dest/fields/fields.js +9 -10
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.js +9 -0
- package/dest/log/log_fn.d.ts +1 -1
- package/dest/log/log_fn.d.ts.map +1 -1
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +0 -1
- package/dest/profiler/index.d.ts +2 -0
- package/dest/profiler/index.d.ts.map +1 -0
- package/dest/profiler/index.js +1 -0
- package/dest/profiler/profiler.d.ts +8 -0
- package/dest/profiler/profiler.d.ts.map +1 -0
- package/dest/profiler/profiler.js +97 -0
- package/dest/serialize/buffer_reader.d.ts +2 -0
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +3 -0
- package/dest/string/index.d.ts.map +1 -1
- package/dest/string/index.js +18 -1
- package/dest/testing/formatting.d.ts +4 -0
- package/dest/testing/formatting.d.ts.map +1 -0
- package/dest/testing/formatting.js +3 -0
- package/dest/testing/index.d.ts +1 -0
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +1 -0
- package/dest/timer/index.d.ts +1 -1
- package/dest/timer/index.d.ts.map +1 -1
- package/dest/timer/index.js +1 -1
- package/dest/timer/timeout.d.ts +2 -0
- package/dest/timer/timeout.d.ts.map +1 -1
- package/dest/timer/timeout.js +9 -0
- package/dest/trees/unbalanced_merkle_tree.d.ts +0 -1
- package/dest/trees/unbalanced_merkle_tree.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree.js +1 -1
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +25 -22
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_calculator.js +124 -94
- package/dest/trees/unbalanced_tree_store.d.ts +1 -0
- package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
- package/dest/trees/unbalanced_tree_store.js +6 -0
- package/package.json +5 -4
- package/src/collection/object.ts +8 -0
- package/src/config/env_var.ts +19 -20
- package/src/config/index.ts +3 -1
- package/src/config/network_config.ts +16 -0
- package/src/config/network_name.ts +18 -3
- package/src/crypto/aes128/index.ts +19 -10
- package/src/crypto/ecdsa/index.ts +40 -37
- package/src/crypto/grumpkin/index.ts +29 -31
- package/src/crypto/keys/index.ts +5 -5
- package/src/crypto/pedersen/pedersen.wasm.ts +22 -18
- package/src/crypto/poseidon/index.ts +32 -24
- package/src/crypto/schnorr/index.ts +20 -17
- package/src/crypto/secp256k1/index.ts +15 -11
- package/src/crypto/secp256k1-signer/utils.ts +16 -0
- package/src/crypto/sync/index.ts +1 -1
- package/src/crypto/sync/pedersen/index.ts +16 -15
- package/src/crypto/sync/poseidon/index.ts +27 -22
- package/src/eth-address/index.ts +2 -2
- package/src/eth-signature/eth_signature.ts +2 -4
- package/src/fields/bls12_point.ts +7 -7
- package/src/fields/fields.ts +5 -6
- package/src/index.ts +1 -0
- package/src/json-rpc/client/safe_json_rpc_client.ts +9 -0
- package/src/log/log_fn.ts +1 -1
- package/src/log/pino-logger.ts +0 -1
- package/src/profiler/index.ts +1 -0
- package/src/profiler/profiler.ts +125 -0
- package/src/serialize/buffer_reader.ts +5 -0
- package/src/string/index.ts +21 -1
- package/src/testing/formatting.ts +3 -0
- package/src/testing/index.ts +1 -0
- package/src/timer/index.ts +1 -1
- package/src/timer/timeout.ts +13 -0
- package/src/trees/unbalanced_merkle_tree.ts +1 -1
- package/src/trees/unbalanced_merkle_tree_calculator.ts +140 -92
- package/src/trees/unbalanced_tree_store.ts +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pedersen.wasm.d.ts","sourceRoot":"","sources":["../../../src/crypto/pedersen/pedersen.wasm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,8BAA8B,CAAC;AAEjF;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,SAAI,
|
|
1
|
+
{"version":3,"file":"pedersen.wasm.d.ts","sourceRoot":"","sources":["../../../src/crypto/pedersen/pedersen.wasm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,8BAA8B,CAAC;AAEjF;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,SAAI,kCAY/D;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,EAAE,CAAC,CAS7E;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,gCAQhE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BarretenbergSync
|
|
1
|
+
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
import { Fr } from '../../fields/fields.js';
|
|
3
3
|
import { serializeToFields } from '../../serialize/serialize.js';
|
|
4
4
|
/**
|
|
@@ -12,13 +12,17 @@ import { serializeToFields } from '../../serialize/serialize.js';
|
|
|
12
12
|
Buffer.alloc(32 - i.length, 0),
|
|
13
13
|
i
|
|
14
14
|
]) : i);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
await BarretenbergSync.initSingleton({
|
|
16
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
17
|
+
});
|
|
18
|
+
const api = BarretenbergSync.getSingleton();
|
|
19
|
+
const response = api.pedersenCommit({
|
|
20
|
+
inputs: input,
|
|
21
|
+
hashIndex: offset
|
|
22
|
+
});
|
|
19
23
|
return [
|
|
20
|
-
Buffer.from(point.x
|
|
21
|
-
Buffer.from(point.y
|
|
24
|
+
Buffer.from(response.point.x),
|
|
25
|
+
Buffer.from(response.point.y)
|
|
22
26
|
];
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
@@ -28,14 +32,26 @@ import { serializeToFields } from '../../serialize/serialize.js';
|
|
|
28
32
|
* @returns The pedersen hash.
|
|
29
33
|
*/ export async function pedersenHash(input, index = 0) {
|
|
30
34
|
const inputFields = serializeToFields(input);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
await BarretenbergSync.initSingleton({
|
|
36
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
37
|
+
});
|
|
38
|
+
const api = BarretenbergSync.getSingleton();
|
|
39
|
+
const response = api.pedersenHash({
|
|
40
|
+
inputs: inputFields.map((i)=>i.toBuffer()),
|
|
41
|
+
hashIndex: index
|
|
42
|
+
});
|
|
43
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
34
44
|
}
|
|
35
45
|
/**
|
|
36
46
|
* Create a pedersen hash from an arbitrary length buffer.
|
|
37
47
|
*/ export async function pedersenHashBuffer(input, index = 0) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
await BarretenbergSync.initSingleton({
|
|
49
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
50
|
+
});
|
|
51
|
+
const api = BarretenbergSync.getSingleton();
|
|
52
|
+
const response = api.pedersenHashBuffer({
|
|
53
|
+
input,
|
|
54
|
+
hashIndex: index
|
|
55
|
+
});
|
|
56
|
+
return Buffer.from(response.hash);
|
|
41
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/poseidon/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,8BAA8B,CAAC;AAEjF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/poseidon/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,8BAA8B,CAAC;AAEjF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAQnE;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CASnG;AAED,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAQ7E;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAY5E;AAED,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAkBnE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BarretenbergSync
|
|
1
|
+
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
import { Fr } from '../../fields/fields.js';
|
|
3
3
|
import { serializeToFields } from '../../serialize/serialize.js';
|
|
4
4
|
/**
|
|
@@ -7,9 +7,14 @@ import { serializeToFields } from '../../serialize/serialize.js';
|
|
|
7
7
|
* @returns The poseidon hash.
|
|
8
8
|
*/ export async function poseidon2Hash(input) {
|
|
9
9
|
const inputFields = serializeToFields(input);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
await BarretenbergSync.initSingleton({
|
|
11
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
12
|
+
});
|
|
13
|
+
const api = BarretenbergSync.getSingleton();
|
|
14
|
+
const response = api.poseidon2Hash({
|
|
15
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
16
|
+
});
|
|
17
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* Create a poseidon hash (field) from an array of input fields and a domain separator.
|
|
@@ -19,15 +24,25 @@ import { serializeToFields } from '../../serialize/serialize.js';
|
|
|
19
24
|
*/ export async function poseidon2HashWithSeparator(input, separator) {
|
|
20
25
|
const inputFields = serializeToFields(input);
|
|
21
26
|
inputFields.unshift(new Fr(separator));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
await BarretenbergSync.initSingleton({
|
|
28
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
29
|
+
});
|
|
30
|
+
const api = BarretenbergSync.getSingleton();
|
|
31
|
+
const response = api.poseidon2Hash({
|
|
32
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
33
|
+
});
|
|
34
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
25
35
|
}
|
|
26
36
|
export async function poseidon2HashAccumulate(input) {
|
|
27
37
|
const inputFields = serializeToFields(input);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
await BarretenbergSync.initSingleton({
|
|
39
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
40
|
+
});
|
|
41
|
+
const api = BarretenbergSync.getSingleton();
|
|
42
|
+
const response = api.poseidon2HashAccumulate({
|
|
43
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
44
|
+
});
|
|
45
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
31
46
|
}
|
|
32
47
|
/**
|
|
33
48
|
* Runs a Poseidon2 permutation.
|
|
@@ -37,11 +52,16 @@ export async function poseidon2HashAccumulate(input) {
|
|
|
37
52
|
const inputFields = serializeToFields(input);
|
|
38
53
|
// We'd like this assertion but it's not possible to use it in the browser.
|
|
39
54
|
// assert(input.length === 4, 'Input state must be of size 4');
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
await BarretenbergSync.initSingleton({
|
|
56
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
57
|
+
});
|
|
58
|
+
const api = BarretenbergSync.getSingleton();
|
|
59
|
+
const response = api.poseidon2Permutation({
|
|
60
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
61
|
+
});
|
|
42
62
|
// We'd like this assertion but it's not possible to use it in the browser.
|
|
43
|
-
// assert(
|
|
44
|
-
return
|
|
63
|
+
// assert(response.outputs.length === 4, 'Output state must be of size 4');
|
|
64
|
+
return response.outputs.map((o)=>Fr.fromBuffer(Buffer.from(o)));
|
|
45
65
|
}
|
|
46
66
|
export async function poseidon2HashBytes(input) {
|
|
47
67
|
const inputFields = [];
|
|
@@ -52,7 +72,12 @@ export async function poseidon2HashBytes(input) {
|
|
|
52
72
|
fieldBytes.reverse();
|
|
53
73
|
inputFields.push(Fr.fromBuffer(fieldBytes));
|
|
54
74
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
await BarretenbergSync.initSingleton({
|
|
76
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
77
|
+
});
|
|
78
|
+
const api = BarretenbergSync.getSingleton();
|
|
79
|
+
const response = api.poseidon2Hash({
|
|
80
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
81
|
+
});
|
|
82
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
58
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/schnorr/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/schnorr/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,cAAc,gBAAgB,CAAC;AAE/B;;GAEG;AACH,qBAAa,OAAO;IAClB;;;;OAIG;IACU,gBAAgB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;IAOzE;;;;;OAKG;IACU,kBAAkB,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc;IAU3E;;;;;;OAMG;IACU,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,gBAAgB;CAWnF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
import { Point } from '@aztec/foundation/fields';
|
|
3
|
-
import { numToInt32BE } from '@aztec/foundation/serialize';
|
|
4
|
-
import { concatenateUint8Arrays } from '../serialize.js';
|
|
5
3
|
import { SchnorrSignature } from './signature.js';
|
|
6
4
|
export * from './signature.js';
|
|
7
5
|
/**
|
|
@@ -12,13 +10,17 @@ export * from './signature.js';
|
|
|
12
10
|
* @param privateKey - The private key.
|
|
13
11
|
* @returns A grumpkin public key.
|
|
14
12
|
*/ async computePublicKey(privateKey) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
await BarretenbergSync.initSingleton({
|
|
14
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
15
|
+
});
|
|
16
|
+
const api = BarretenbergSync.getSingleton();
|
|
17
|
+
const response = api.schnorrComputePublicKey({
|
|
18
|
+
privateKey: privateKey.toBuffer()
|
|
19
|
+
});
|
|
20
|
+
return Point.fromBuffer(Buffer.concat([
|
|
21
|
+
Buffer.from(response.publicKey.x),
|
|
22
|
+
Buffer.from(response.publicKey.y)
|
|
23
|
+
]));
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Constructs a Schnorr signature given a msg and a private key.
|
|
@@ -26,21 +28,17 @@ export * from './signature.js';
|
|
|
26
28
|
* @param privateKey - The private key of the signer.
|
|
27
29
|
* @returns A Schnorr signature of the form (s, e).
|
|
28
30
|
*/ async constructSignature(msg, privateKey) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
], [
|
|
38
|
-
32,
|
|
39
|
-
32
|
|
40
|
-
]);
|
|
31
|
+
await BarretenbergSync.initSingleton({
|
|
32
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
33
|
+
});
|
|
34
|
+
const api = BarretenbergSync.getSingleton();
|
|
35
|
+
const response = api.schnorrConstructSignature({
|
|
36
|
+
message: msg,
|
|
37
|
+
privateKey: privateKey.toBuffer()
|
|
38
|
+
});
|
|
41
39
|
return new SchnorrSignature(Buffer.from([
|
|
42
|
-
...s,
|
|
43
|
-
...e
|
|
40
|
+
...response.s,
|
|
41
|
+
...response.e
|
|
44
42
|
]));
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
@@ -50,19 +48,19 @@ export * from './signature.js';
|
|
|
50
48
|
* @param sig - The Schnorr signature.
|
|
51
49
|
* @returns True or false.
|
|
52
50
|
*/ async verifySignature(msg, pubKey, sig) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
51
|
+
await BarretenbergSync.initSingleton({
|
|
52
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
53
|
+
});
|
|
54
|
+
const api = BarretenbergSync.getSingleton();
|
|
55
|
+
const response = api.schnorrVerifySignature({
|
|
56
|
+
message: msg,
|
|
57
|
+
publicKey: {
|
|
58
|
+
x: pubKey.x.toBuffer(),
|
|
59
|
+
y: pubKey.y.toBuffer()
|
|
60
|
+
},
|
|
61
|
+
s: sig.s,
|
|
62
|
+
e: sig.e
|
|
63
|
+
});
|
|
64
|
+
return response.verified;
|
|
67
65
|
}
|
|
68
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/secp256k1/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,SAAS;IAEpB,MAAM,CAAC,SAAS,sBAKb;IAEH;;;OAGG;IACI,SAAS,IAAI,MAAM;IAI1B;;;;;OAKG;IACU,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crypto/secp256k1/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,SAAS;IAEpB,MAAM,CAAC,SAAS,sBAKb;IAEH;;;OAGG;IACI,SAAS,IAAI,MAAM;IAI1B;;;;;OAKG;IACU,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU;IAUtD;;;OAGG;IACU,WAAW;IAOxB;;;;OAIG;IACU,mBAAmB,CAAC,UAAU,EAAE,MAAM;CAMpD"}
|
|
@@ -81,36 +81,47 @@ import { BarretenbergSync } from '@aztec/bb.js';
|
|
|
81
81
|
* @param scalar - Scalar to multiply by.
|
|
82
82
|
* @returns Result of the multiplication.
|
|
83
83
|
*/ async mul(point, scalar) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
await BarretenbergSync.initSingleton({
|
|
85
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
86
|
+
});
|
|
87
|
+
const api = BarretenbergSync.getSingleton();
|
|
88
|
+
const response = api.secp256k1Mul({
|
|
89
|
+
point: {
|
|
90
|
+
x: point.subarray(0, 32),
|
|
91
|
+
y: point.subarray(32, 64)
|
|
92
|
+
},
|
|
87
93
|
scalar
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
});
|
|
95
|
+
return Buffer.concat([
|
|
96
|
+
Buffer.from(response.point.x),
|
|
97
|
+
Buffer.from(response.point.y)
|
|
90
98
|
]);
|
|
91
|
-
return Buffer.from(result);
|
|
92
99
|
}
|
|
93
100
|
/**
|
|
94
101
|
* Gets a random field element.
|
|
95
102
|
* @returns Random field element.
|
|
96
103
|
*/ async getRandomFr() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
await BarretenbergSync.initSingleton({
|
|
105
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
106
|
+
});
|
|
107
|
+
const api = BarretenbergSync.getSingleton();
|
|
108
|
+
const response = api.secp256k1GetRandomFr({
|
|
109
|
+
dummy: 0
|
|
110
|
+
});
|
|
111
|
+
return Buffer.from(response.value);
|
|
102
112
|
}
|
|
103
113
|
/**
|
|
104
114
|
* Converts a 512 bits long buffer to a field.
|
|
105
115
|
* @param uint512Buf - The buffer to convert.
|
|
106
116
|
* @returns Buffer representation of the field element.
|
|
107
117
|
*/ async reduce512BufferToFr(uint512Buf) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
await BarretenbergSync.initSingleton({
|
|
119
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
120
|
+
});
|
|
121
|
+
const api = BarretenbergSync.getSingleton();
|
|
122
|
+
const response = api.secp256k1Reduce512({
|
|
123
|
+
input: uint512Buf
|
|
124
|
+
});
|
|
125
|
+
return Buffer.from(response.value);
|
|
115
126
|
}
|
|
116
127
|
}
|
|
@@ -19,8 +19,16 @@ export declare function addressFromPrivateKey(privateKey: Buffer): EthAddress;
|
|
|
19
19
|
* @param hash - The hash to recover the address from.
|
|
20
20
|
* @param signature - The signature to recover the address from.
|
|
21
21
|
* @returns The address.
|
|
22
|
+
* @throws Error if signature recovery fails.
|
|
22
23
|
*/
|
|
23
24
|
export declare function recoverAddress(hash: Buffer32, signature: Signature): EthAddress;
|
|
25
|
+
/**
|
|
26
|
+
* Safely attempts to recover an address from a hash and a signature.
|
|
27
|
+
* @param hash - The hash to recover the address from.
|
|
28
|
+
* @param signature - The signature to recover the address from.
|
|
29
|
+
* @returns The address if recovery succeeds, undefined otherwise.
|
|
30
|
+
*/
|
|
31
|
+
export declare function tryRecoverAddress(hash: Buffer32, signature: Signature): EthAddress | undefined;
|
|
24
32
|
/**
|
|
25
33
|
* @attribution - viem
|
|
26
34
|
* Converts a yParityOrV value to a recovery bit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/crypto/secp256k1-signer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAMjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAG7D;AAYD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAGpE;AAED
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/crypto/secp256k1-signer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAMjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAG7D;AAYD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAGpE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAS/E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAO9F;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,SAW/C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAGhE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAM7E"}
|
|
@@ -40,6 +40,7 @@ export function makeEthSignDigest(message) {
|
|
|
40
40
|
* @param hash - The hash to recover the address from.
|
|
41
41
|
* @param signature - The signature to recover the address from.
|
|
42
42
|
* @returns The address.
|
|
43
|
+
* @throws Error if signature recovery fails.
|
|
43
44
|
*/ export function recoverAddress(hash, signature) {
|
|
44
45
|
try {
|
|
45
46
|
const publicKey = recoverPublicKey(hash, signature);
|
|
@@ -48,6 +49,19 @@ export function makeEthSignDigest(message) {
|
|
|
48
49
|
throw new Error(`Error recovering Ethereum address from hash ${hash.toString()} and signature ${signature.toString()}: ${err}`);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Safely attempts to recover an address from a hash and a signature.
|
|
54
|
+
* @param hash - The hash to recover the address from.
|
|
55
|
+
* @param signature - The signature to recover the address from.
|
|
56
|
+
* @returns The address if recovery succeeds, undefined otherwise.
|
|
57
|
+
*/ export function tryRecoverAddress(hash, signature) {
|
|
58
|
+
try {
|
|
59
|
+
const publicKey = recoverPublicKey(hash, signature);
|
|
60
|
+
return publicKeyToAddress(publicKey);
|
|
61
|
+
} catch {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
51
65
|
/**
|
|
52
66
|
* @attribution - viem
|
|
53
67
|
* Converts a yParityOrV value to a recovery bit.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
export * from './poseidon/index.js';
|
|
3
3
|
export * from './pedersen/index.js';
|
|
4
|
-
await BarretenbergSync.initSingleton(
|
|
4
|
+
await BarretenbergSync.initSingleton({
|
|
5
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
6
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/crypto/sync/pedersen/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,iCAAiC,CAAC;AAEpF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,SAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/crypto/sync/pedersen/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,iCAAiC,CAAC;AAEpF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,SAAI,yBAUzD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,SAAI,GAAG,EAAE,CAO9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,uBAM1D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BarretenbergSync
|
|
1
|
+
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
import { Fr } from '../../../fields/fields.js';
|
|
3
3
|
import { serializeToFields } from '../../../serialize/serialize.js';
|
|
4
4
|
/**
|
|
@@ -12,12 +12,13 @@ import { serializeToFields } from '../../../serialize/serialize.js';
|
|
|
12
12
|
Buffer.alloc(32 - i.length, 0),
|
|
13
13
|
i
|
|
14
14
|
]) : i);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const response = BarretenbergSync.getSingleton().pedersenCommit({
|
|
16
|
+
inputs: input,
|
|
17
|
+
hashIndex: offset
|
|
18
|
+
});
|
|
18
19
|
return [
|
|
19
|
-
Buffer.from(point.x
|
|
20
|
-
Buffer.from(point.y
|
|
20
|
+
Buffer.from(response.point.x),
|
|
21
|
+
Buffer.from(response.point.y)
|
|
21
22
|
];
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
@@ -27,12 +28,18 @@ import { serializeToFields } from '../../../serialize/serialize.js';
|
|
|
27
28
|
* @returns The pedersen hash.
|
|
28
29
|
*/ export function pedersenHash(input, index = 0) {
|
|
29
30
|
const inputFields = serializeToFields(input);
|
|
30
|
-
const
|
|
31
|
-
|
|
31
|
+
const response = BarretenbergSync.getSingleton().pedersenHash({
|
|
32
|
+
inputs: inputFields.map((i)=>i.toBuffer()),
|
|
33
|
+
hashIndex: index
|
|
34
|
+
});
|
|
35
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* Create a pedersen hash from an arbitrary length buffer.
|
|
35
39
|
*/ export function pedersenHashBuffer(input, index = 0) {
|
|
36
|
-
const
|
|
37
|
-
|
|
40
|
+
const response = BarretenbergSync.getSingleton().pedersenHashBuffer({
|
|
41
|
+
input,
|
|
42
|
+
hashIndex: index
|
|
43
|
+
});
|
|
44
|
+
return Buffer.from(response.hash);
|
|
38
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/crypto/sync/poseidon/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,iCAAiC,CAAC;AAEpF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/crypto/sync/poseidon/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,iCAAiC,CAAC;AAEpF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAOpD;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,EAAE,CASpF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAO9D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,CAW7D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,CAiBpD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BarretenbergSync
|
|
1
|
+
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
import { Fr } from '../../../fields/fields.js';
|
|
3
3
|
import { serializeToFields } from '../../../serialize/serialize.js';
|
|
4
4
|
/**
|
|
@@ -7,8 +7,11 @@ import { serializeToFields } from '../../../serialize/serialize.js';
|
|
|
7
7
|
* @returns The poseidon hash.
|
|
8
8
|
*/ export function poseidon2Hash(input) {
|
|
9
9
|
const inputFields = serializeToFields(input);
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const api = BarretenbergSync.getSingleton();
|
|
11
|
+
const response = api.poseidon2Hash({
|
|
12
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
13
|
+
});
|
|
14
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
12
15
|
}
|
|
13
16
|
/**
|
|
14
17
|
* Create a poseidon hash (field) from an array of input fields and a domain separator.
|
|
@@ -18,13 +21,19 @@ import { serializeToFields } from '../../../serialize/serialize.js';
|
|
|
18
21
|
*/ export function poseidon2HashWithSeparator(input, separator) {
|
|
19
22
|
const inputFields = serializeToFields(input);
|
|
20
23
|
inputFields.unshift(new Fr(separator));
|
|
21
|
-
const
|
|
22
|
-
|
|
24
|
+
const api = BarretenbergSync.getSingleton();
|
|
25
|
+
const response = api.poseidon2Hash({
|
|
26
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
27
|
+
});
|
|
28
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
23
29
|
}
|
|
24
30
|
export function poseidon2HashAccumulate(input) {
|
|
25
31
|
const inputFields = serializeToFields(input);
|
|
26
|
-
const
|
|
27
|
-
|
|
32
|
+
const api = BarretenbergSync.getSingleton();
|
|
33
|
+
const response = api.poseidon2HashAccumulate({
|
|
34
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
35
|
+
});
|
|
36
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* Runs a Poseidon2 permutation.
|
|
@@ -34,10 +43,13 @@ export function poseidon2HashAccumulate(input) {
|
|
|
34
43
|
const inputFields = serializeToFields(input);
|
|
35
44
|
// We'd like this assertion but it's not possible to use it in the browser.
|
|
36
45
|
// assert(input.length === 4, 'Input state must be of size 4');
|
|
37
|
-
const
|
|
46
|
+
const api = BarretenbergSync.getSingleton();
|
|
47
|
+
const response = api.poseidon2Permutation({
|
|
48
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
49
|
+
});
|
|
38
50
|
// We'd like this assertion but it's not possible to use it in the browser.
|
|
39
|
-
// assert(
|
|
40
|
-
return
|
|
51
|
+
// assert(response.outputs.length === 4, 'Output state must be of size 4');
|
|
52
|
+
return response.outputs.map((o)=>Fr.fromBuffer(Buffer.from(o)));
|
|
41
53
|
}
|
|
42
54
|
export function poseidon2HashBytes(input) {
|
|
43
55
|
const inputFields = [];
|
|
@@ -48,6 +60,9 @@ export function poseidon2HashBytes(input) {
|
|
|
48
60
|
fieldBytes.reverse();
|
|
49
61
|
inputFields.push(Fr.fromBuffer(fieldBytes));
|
|
50
62
|
}
|
|
51
|
-
const
|
|
52
|
-
|
|
63
|
+
const api = BarretenbergSync.getSingleton();
|
|
64
|
+
const response = api.poseidon2Hash({
|
|
65
|
+
inputs: inputFields.map((i)=>i.toBuffer())
|
|
66
|
+
});
|
|
67
|
+
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
53
68
|
}
|
|
@@ -67,7 +67,7 @@ export declare class EthAddress {
|
|
|
67
67
|
* @param address - The Ethereum address as a hex-encoded string.
|
|
68
68
|
* @returns The Ethereum address in its checksum format.
|
|
69
69
|
*/
|
|
70
|
-
static toChecksumAddress(address: string): string
|
|
70
|
+
static toChecksumAddress(address: string): `0x${string}`;
|
|
71
71
|
/**
|
|
72
72
|
* Checks whether the given EthAddress instance is equal to the current instance.
|
|
73
73
|
* Equality is determined by comparing the underlying byte buffers of both instances.
|
|
@@ -92,7 +92,7 @@ export declare class EthAddress {
|
|
|
92
92
|
*
|
|
93
93
|
* @returns A checksummed Ethereum address string.
|
|
94
94
|
*/
|
|
95
|
-
toChecksumString(): string
|
|
95
|
+
toChecksumString(): `0x${string}`;
|
|
96
96
|
/**
|
|
97
97
|
* Returns a 20-byte buffer representation of the Ethereum address.
|
|
98
98
|
* @returns A 20-byte Buffer containing the Ethereum address.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eth-address/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAI/B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIlE;;;;;GAKG;AACH,qBAAa,UAAU;IAMT,OAAO,CAAC,MAAM;IAL1B,gDAAgD;IAChD,OAAc,aAAa,SAAM;IACjC,0EAA0E;IAC1E,OAAc,IAAI,aAA0D;gBAExD,MAAM,EAAE,MAAM;IAMlC;;;;;;;OAOG;WACW,UAAU,CAAC,OAAO,EAAE,MAAM;IAOxC;;;;;;OAMG;WACW,MAAM;IAIpB;;;;;;;;OAQG;WACW,SAAS,CAAC,OAAO,EAAE,MAAM;IAYvC;;;;;OAKG;IACI,MAAM;IAIb;;;;;;;OAOG;WACW,oBAAoB,CAAC,OAAO,EAAE,MAAM;IAgBlD;;;;;;;;;OASG;WACW,iBAAiB,CAAC,OAAO,EAAE,MAAM;IAoB/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eth-address/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAI/B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIlE;;;;;GAKG;AACH,qBAAa,UAAU;IA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AAG,SAAS;IAUhD,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,SAAS;IAIvD,MAAM,CAAC,4BAA4B,CAAC,GAAG,EAAE,wBAAwB,GAAG,SAAS;IAI7E,MAAM,CAAC,MAAM,IAAI,SAAS;IAI1B,MAAM,CAAC,KAAK,IAAI,SAAS;IAIzB,OAAO,IAAI,OAAO;IAIlB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;IAIjC,QAAQ,IAAI,MAAM;IAIlB,OAAO,IAAI,MAAM;IAUjB,QAAQ,IAAI,KAAK,MAAM,EAAE;IAIzB;;OAEG;IACH,eAAe,IAAI,aAAa;IAQhC;;OAEG;IACH,0BAA0B,IAAI,wBAAwB;IAWtD,MAAM;IAIN,MAAM,KAAK,MAAM,2HAMhB;CACF"}
|
|
@@ -46,7 +46,7 @@ import { hasHexPrefix, hexToBuffer } from '../string/index.js';
|
|
|
46
46
|
return new Signature(Buffer32.fromBuffer(hexToBuffer(sig.r)), Buffer32.fromBuffer(hexToBuffer(sig.s)), sig.yParity);
|
|
47
47
|
}
|
|
48
48
|
static random() {
|
|
49
|
-
return new Signature(Buffer32.random(), Buffer32.random(),
|
|
49
|
+
return new Signature(Buffer32.random(), Buffer32.random(), 1);
|
|
50
50
|
}
|
|
51
51
|
static empty() {
|
|
52
52
|
return new Signature(Buffer32.ZERO, Buffer32.ZERO, 0);
|
|
@@ -58,13 +58,11 @@ import { hasHexPrefix, hexToBuffer } from '../string/index.js';
|
|
|
58
58
|
return this.r.equals(other.r) && this.s.equals(other.s) && this.v === other.v && this.empty === other.empty;
|
|
59
59
|
}
|
|
60
60
|
toBuffer() {
|
|
61
|
-
|
|
61
|
+
return serializeToBuffer([
|
|
62
62
|
this.r,
|
|
63
63
|
this.s,
|
|
64
64
|
this.v
|
|
65
65
|
]);
|
|
66
|
-
this.size = buffer.length;
|
|
67
|
-
return buffer;
|
|
68
66
|
}
|
|
69
67
|
getSize() {
|
|
70
68
|
// We cache size to avoid recalculating it
|
|
@@ -89,13 +89,13 @@ export declare class BLS12Point {
|
|
|
89
89
|
*/
|
|
90
90
|
static decompress(buffer: Buffer): BLS12Point;
|
|
91
91
|
/**
|
|
92
|
-
* Converts a Point to two BN254 Fr elements by storing its compressed form as:
|
|
93
|
-
*
|
|
94
|
-
* |
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* |
|
|
98
|
-
*
|
|
92
|
+
* Converts a Point to two BN254 Fr elements by storing its compressed form (48 bytes) as:
|
|
93
|
+
* +-------------------+------------------------+
|
|
94
|
+
* | 31 bytes | 17 bytes |
|
|
95
|
+
* +-------------------+------------------------+
|
|
96
|
+
* | Field Element 1 | Field Element 2 |
|
|
97
|
+
* | [0][bytes 0-30] | [0...0][bytes 31-47] |
|
|
98
|
+
* +-------------------+------------------------+
|
|
99
99
|
* Used in the rollup circuits to store blob commitments in the native field type. See blob.ts.
|
|
100
100
|
* @param point - A BLS12Point instance.
|
|
101
101
|
* @returns The point fields.
|