@aztec/foundation 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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/array/index.d.ts +2 -1
- package/dest/array/index.d.ts.map +1 -1
- package/dest/array/index.js +1 -0
- package/dest/array/sorted_array.d.ts +15 -0
- package/dest/array/sorted_array.d.ts.map +1 -0
- package/dest/array/sorted_array.js +109 -0
- package/dest/branded-types/block_number.d.ts +56 -0
- package/dest/branded-types/block_number.d.ts.map +1 -0
- package/dest/branded-types/block_number.js +78 -0
- package/dest/branded-types/checkpoint_number.d.ts +54 -0
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -0
- package/dest/branded-types/checkpoint_number.js +77 -0
- package/dest/branded-types/index.d.ts +4 -1
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +3 -0
- package/dest/branded-types/index_within_checkpoint.d.ts +42 -0
- package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -0
- package/dest/branded-types/index_within_checkpoint.js +59 -0
- package/dest/buffer/buffer16.d.ts +5 -2
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer16.js +4 -2
- package/dest/buffer/buffer32.d.ts +5 -2
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +4 -2
- package/dest/collection/array.d.ts +12 -1
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +51 -0
- package/dest/config/env_var.d.ts +2 -2
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +15 -4
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +32 -9
- package/dest/config/network_config.d.ts +13 -1
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +3 -1
- package/dest/config/network_name.d.ts +2 -2
- package/dest/config/network_name.d.ts.map +1 -1
- package/dest/config/network_name.js +2 -0
- package/dest/config/parse-env.d.ts +3 -0
- package/dest/config/parse-env.d.ts.map +1 -0
- package/dest/config/parse-env.js +7 -0
- package/dest/config/secret_value.js +3 -1
- package/dest/crypto/bls/bn254_keystore.js +1 -1
- package/dest/crypto/bls/index.js +1 -1
- package/dest/crypto/bn254/index.d.ts +35 -51
- package/dest/crypto/bn254/index.d.ts.map +1 -1
- package/dest/crypto/bn254/index.js +51 -140
- package/dest/crypto/ecdsa/signature.d.ts +11 -2
- package/dest/crypto/ecdsa/signature.d.ts.map +1 -1
- package/dest/crypto/ecdsa/signature.js +2 -2
- package/dest/crypto/grumpkin/index.d.ts +4 -2
- package/dest/crypto/grumpkin/index.d.ts.map +1 -1
- package/dest/crypto/grumpkin/index.js +2 -1
- package/dest/crypto/keys/index.d.ts +2 -2
- package/dest/crypto/keys/index.d.ts.map +1 -1
- package/dest/crypto/keys/index.js +1 -1
- package/dest/crypto/pedersen/pedersen.wasm.d.ts +2 -2
- package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -1
- package/dest/crypto/pedersen/pedersen.wasm.js +1 -1
- package/dest/crypto/poseidon/index.d.ts +2 -3
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +1 -10
- package/dest/crypto/random/randomness_singleton.d.ts +4 -3
- package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
- package/dest/crypto/random/randomness_singleton.js +5 -5
- package/dest/crypto/schnorr/index.d.ts +3 -2
- package/dest/crypto/schnorr/index.d.ts.map +1 -1
- package/dest/crypto/schnorr/index.js +1 -1
- package/dest/crypto/schnorr/signature.d.ts +2 -2
- package/dest/crypto/schnorr/signature.d.ts.map +1 -1
- package/dest/crypto/schnorr/signature.js +2 -2
- package/dest/crypto/sha256/index.d.ts +2 -2
- package/dest/crypto/sha256/index.d.ts.map +1 -1
- package/dest/crypto/sha256/index.js +1 -1
- package/dest/crypto/sha512/index.d.ts +2 -2
- package/dest/crypto/sha512/index.d.ts.map +1 -1
- package/dest/crypto/sha512/index.js +1 -1
- package/dest/crypto/signature/index.d.ts +2 -2
- package/dest/crypto/signature/index.d.ts.map +1 -1
- package/dest/crypto/sync/pedersen/index.d.ts +2 -2
- package/dest/crypto/sync/pedersen/index.d.ts.map +1 -1
- package/dest/crypto/sync/pedersen/index.js +1 -1
- package/dest/crypto/sync/poseidon/index.d.ts +2 -3
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/sync/poseidon/index.js +1 -9
- package/dest/{fields/bls12_fields.d.ts → curves/bls12/field.d.ts} +3 -3
- package/dest/curves/bls12/field.d.ts.map +1 -0
- package/dest/{fields/bls12_fields.js → curves/bls12/field.js} +12 -9
- package/dest/curves/bls12/index.d.ts +3 -0
- package/dest/curves/bls12/index.d.ts.map +1 -0
- package/dest/curves/bls12/index.js +2 -0
- package/dest/{fields/bls12_point.d.ts → curves/bls12/point.d.ts} +13 -4
- package/dest/curves/bls12/point.d.ts.map +1 -0
- package/dest/{fields/bls12_point.js → curves/bls12/point.js} +10 -8
- package/dest/{fields/fields.d.ts → curves/bn254/field.d.ts} +7 -15
- package/dest/curves/bn254/field.d.ts.map +1 -0
- package/dest/{fields/fields.js → curves/bn254/field.js} +35 -49
- package/dest/curves/bn254/index.d.ts +3 -0
- package/dest/curves/bn254/index.d.ts.map +1 -0
- package/dest/curves/bn254/index.js +2 -0
- package/dest/curves/bn254/point.d.ts +54 -0
- package/dest/curves/bn254/point.d.ts.map +1 -0
- package/dest/curves/bn254/point.js +143 -0
- package/dest/curves/grumpkin/index.d.ts +10 -0
- package/dest/curves/grumpkin/index.d.ts.map +1 -0
- package/dest/curves/grumpkin/index.js +3 -0
- package/dest/{fields → curves/grumpkin}/point.d.ts +13 -4
- package/dest/curves/grumpkin/point.d.ts.map +1 -0
- package/dest/{fields → curves/grumpkin}/point.js +7 -7
- package/dest/error/index.d.ts +4 -4
- package/dest/error/index.d.ts.map +1 -1
- package/dest/eth-address/index.d.ts +3 -2
- package/dest/eth-address/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +10 -3
- package/dest/eth-signature/eth_signature.d.ts +4 -1
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/iterator/filter.d.ts +3 -0
- package/dest/iterator/filter.d.ts.map +1 -0
- package/dest/iterator/filter.js +7 -0
- package/dest/iterator/index.d.ts +2 -0
- package/dest/iterator/index.d.ts.map +1 -0
- package/dest/iterator/index.js +1 -0
- package/dest/jest/setup.js +4 -1
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +2 -1
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.js +1 -1
- package/dest/json-rpc/client/undici.d.ts +1 -1
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +21 -4
- package/dest/json-rpc/fixtures/class_a.d.ts +3 -3
- package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/class_b.d.ts +3 -3
- package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -1
- package/dest/json-rpc/server/api_key_auth.d.ts +19 -0
- package/dest/json-rpc/server/api_key_auth.d.ts.map +1 -0
- package/dest/json-rpc/server/api_key_auth.js +57 -0
- package/dest/json-rpc/server/index.d.ts +2 -1
- package/dest/json-rpc/server/index.d.ts.map +1 -1
- package/dest/json-rpc/server/index.js +1 -0
- package/dest/json-rpc/server/safe_json_rpc_server.js +1 -1
- package/dest/log/bigint-utils.d.ts +5 -0
- package/dest/log/bigint-utils.d.ts.map +1 -0
- package/dest/log/bigint-utils.js +18 -0
- package/dest/log/gcloud-logger-config.d.ts +1 -1
- package/dest/log/gcloud-logger-config.d.ts.map +1 -1
- package/dest/log/gcloud-logger-config.js +3 -0
- package/dest/log/libp2p_logger.d.ts +5 -2
- package/dest/log/libp2p_logger.d.ts.map +1 -1
- package/dest/log/libp2p_logger.js +14 -4
- package/dest/log/log-filters.d.ts +17 -4
- package/dest/log/log-filters.d.ts.map +1 -1
- package/dest/log/log-filters.js +26 -12
- package/dest/log/pino-logger-server.d.ts +9 -0
- package/dest/log/pino-logger-server.d.ts.map +1 -0
- package/dest/log/pino-logger-server.js +18 -0
- package/dest/log/pino-logger.d.ts +37 -8
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +122 -29
- package/dest/queue/base_memory_queue.d.ts +2 -2
- package/dest/queue/base_memory_queue.d.ts.map +1 -1
- package/dest/queue/semaphore.d.ts +5 -1
- package/dest/queue/semaphore.d.ts.map +1 -1
- package/dest/retry/index.d.ts +11 -1
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +11 -0
- package/dest/schemas/schemas.d.ts +7 -3
- package/dest/schemas/schemas.d.ts.map +1 -1
- package/dest/schemas/schemas.js +9 -3
- package/dest/schemas/types.d.ts +31 -1
- package/dest/schemas/types.d.ts.map +1 -1
- package/dest/schemas/types.js +25 -1
- package/dest/serialize/buffer_reader.d.ts +14 -4
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +26 -4
- package/dest/serialize/field_reader.d.ts +2 -2
- package/dest/serialize/field_reader.d.ts.map +1 -1
- package/dest/serialize/field_reader.js +1 -1
- package/dest/serialize/free_funcs.d.ts +2 -2
- package/dest/serialize/free_funcs.d.ts.map +1 -1
- package/dest/serialize/free_funcs.js +1 -1
- package/dest/serialize/serialize.d.ts +20 -2
- package/dest/serialize/serialize.d.ts.map +1 -1
- package/dest/serialize/serialize.js +32 -1
- package/dest/sleep/index.d.ts +3 -1
- package/dest/sleep/index.d.ts.map +1 -1
- package/dest/sleep/index.js +4 -0
- package/dest/timer/date.d.ts +26 -1
- package/dest/timer/date.d.ts.map +1 -1
- package/dest/timer/date.js +36 -0
- package/dest/trees/balanced_merkle_tree_root.d.ts +17 -0
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{balanced_merkle_tree.js → balanced_merkle_tree_root.js} +2 -15
- package/dest/trees/hasher.d.ts +3 -1
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/hasher.js +10 -5
- package/dest/trees/index.d.ts +4 -4
- package/dest/trees/index.d.ts.map +1 -1
- package/dest/trees/index.js +3 -3
- package/dest/trees/indexed_merkle_tree.js +1 -1
- package/dest/trees/membership_witness.d.ts +12 -2
- package/dest/trees/membership_witness.d.ts.map +1 -1
- package/dest/trees/membership_witness.js +10 -1
- package/dest/trees/merkle_tree_calculator.d.ts +1 -1
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +2 -2
- package/dest/trees/sibling_path.d.ts +3 -2
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/sibling_path.js +3 -3
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +2 -3
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_calculator.js +1 -5
- package/dest/trees/{unbalanced_merkle_tree.d.ts → unbalanced_merkle_tree_root.d.ts} +3 -5
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{unbalanced_merkle_tree.js → unbalanced_merkle_tree_root.js} +11 -49
- package/dest/trees/unbalanced_tree_store.d.ts +5 -1
- package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
- package/dest/trees/unbalanced_tree_store.js +49 -1
- package/dest/types/index.d.ts +6 -2
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +6 -0
- package/package.json +48 -9
- package/src/array/index.ts +1 -0
- package/src/array/sorted_array.ts +138 -0
- package/src/branded-types/block_number.ts +117 -0
- package/src/branded-types/checkpoint_number.ts +115 -0
- package/src/branded-types/index.ts +3 -0
- package/src/branded-types/index_within_checkpoint.ts +88 -0
- package/src/buffer/buffer16.ts +2 -2
- package/src/buffer/buffer32.ts +2 -2
- package/src/collection/array.ts +52 -0
- package/src/config/env_var.ts +70 -14
- package/src/config/index.ts +39 -6
- package/src/config/network_config.ts +2 -0
- package/src/config/network_name.ts +4 -1
- package/src/config/parse-env.ts +4 -0
- package/src/crypto/bls/bn254_keystore.ts +1 -1
- package/src/crypto/bls/index.ts +1 -1
- package/src/crypto/bn254/index.ts +50 -159
- package/src/crypto/ecdsa/signature.ts +2 -2
- package/src/crypto/grumpkin/index.ts +3 -1
- package/src/crypto/keys/index.ts +1 -1
- package/src/crypto/pedersen/pedersen.wasm.ts +1 -1
- package/src/crypto/poseidon/index.ts +1 -11
- package/src/crypto/random/randomness_singleton.ts +6 -4
- package/src/crypto/schnorr/index.ts +2 -1
- package/src/crypto/schnorr/signature.ts +2 -2
- package/src/crypto/sha256/index.ts +1 -1
- package/src/crypto/sha512/index.ts +1 -1
- package/src/crypto/signature/index.ts +1 -1
- package/src/crypto/sync/pedersen/index.ts +1 -1
- package/src/crypto/sync/poseidon/index.ts +1 -10
- package/src/{fields/bls12_fields.ts → curves/bls12/field.ts} +6 -6
- package/src/curves/bls12/index.ts +2 -0
- package/src/{fields/bls12_point.ts → curves/bls12/point.ts} +7 -7
- package/src/{fields/fields.ts → curves/bn254/field.ts} +33 -56
- package/src/curves/bn254/index.ts +2 -0
- package/src/curves/bn254/point.ts +170 -0
- package/src/curves/grumpkin/index.ts +11 -0
- package/src/{fields → curves/grumpkin}/point.ts +7 -7
- package/src/eth-address/index.ts +8 -2
- package/src/iterator/filter.ts +11 -0
- package/src/iterator/index.ts +1 -0
- package/src/jest/setup.mjs +4 -1
- package/src/json-rpc/client/safe_json_rpc_client.ts +2 -0
- package/src/json-rpc/client/undici.ts +21 -3
- package/src/json-rpc/server/api_key_auth.ts +63 -0
- package/src/json-rpc/server/index.ts +1 -0
- package/src/json-rpc/server/safe_json_rpc_server.ts +1 -1
- package/src/log/bigint-utils.ts +22 -0
- package/src/log/gcloud-logger-config.ts +5 -0
- package/src/log/libp2p_logger.ts +12 -5
- package/src/log/log-filters.ts +29 -11
- package/src/log/pino-logger-server.ts +25 -0
- package/src/log/pino-logger.ts +144 -39
- package/src/queue/base_memory_queue.ts +1 -1
- package/src/queue/semaphore.ts +5 -0
- package/src/retry/index.ts +18 -0
- package/src/schemas/schemas.ts +14 -3
- package/src/schemas/types.ts +33 -0
- package/src/serialize/buffer_reader.ts +36 -9
- package/src/serialize/field_reader.ts +1 -1
- package/src/serialize/free_funcs.ts +1 -1
- package/src/serialize/serialize.ts +33 -1
- package/src/sleep/index.ts +6 -0
- package/src/timer/date.ts +52 -0
- package/src/trees/{balanced_merkle_tree.ts → balanced_merkle_tree_root.ts} +2 -16
- package/src/trees/hasher.ts +9 -0
- package/src/trees/index.ts +3 -3
- package/src/trees/indexed_merkle_tree.ts +1 -1
- package/src/trees/membership_witness.ts +9 -1
- package/src/trees/merkle_tree_calculator.ts +2 -2
- package/src/trees/sibling_path.ts +3 -3
- package/src/trees/unbalanced_merkle_tree_calculator.ts +1 -12
- package/src/trees/{unbalanced_merkle_tree.ts → unbalanced_merkle_tree_root.ts} +17 -61
- package/src/trees/unbalanced_tree_store.ts +57 -2
- package/src/types/index.ts +11 -1
- package/dest/crypto/bn254/bn254_utils.d.ts +0 -39
- package/dest/crypto/bn254/bn254_utils.d.ts.map +0 -1
- package/dest/crypto/bn254/bn254_utils.js +0 -56
- package/dest/crypto/index.d.ts +0 -17
- package/dest/crypto/index.d.ts.map +0 -1
- package/dest/crypto/index.js +0 -16
- package/dest/fields/bls12_fields.d.ts.map +0 -1
- package/dest/fields/bls12_point.d.ts.map +0 -1
- package/dest/fields/coordinate.d.ts +0 -63
- package/dest/fields/coordinate.d.ts.map +0 -1
- package/dest/fields/coordinate.js +0 -96
- package/dest/fields/fields.d.ts.map +0 -1
- package/dest/fields/index.d.ts +0 -6
- package/dest/fields/index.d.ts.map +0 -1
- package/dest/fields/index.js +0 -5
- package/dest/fields/point.d.ts.map +0 -1
- package/dest/index.d.ts +0 -31
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -31
- package/dest/json-rpc/server/telemetry.d.ts +0 -2
- package/dest/json-rpc/server/telemetry.d.ts.map +0 -1
- package/dest/json-rpc/server/telemetry.js +0 -0
- package/dest/trees/balanced_merkle_tree.d.ts +0 -22
- package/dest/trees/balanced_merkle_tree.d.ts.map +0 -1
- package/dest/trees/unbalanced_merkle_tree.d.ts.map +0 -1
- package/src/crypto/bn254/bn254_utils.ts +0 -64
- package/src/crypto/index.ts +0 -16
- package/src/fields/coordinate.ts +0 -104
- package/src/fields/index.ts +0 -5
- package/src/index.ts +0 -31
- package/src/json-rpc/server/telemetry.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assertMemberLength } from '../array/array.js';
|
|
2
2
|
import { toBigIntBE, toBufferBE } from '../bigint-buffer/index.js';
|
|
3
|
-
import { Fr } from '../
|
|
3
|
+
import { Fr } from '../curves/bn254/field.js';
|
|
4
4
|
import { schemas } from '../schemas/schemas.js';
|
|
5
5
|
import { BufferReader, type Tuple, serializeToBuffer } from '../serialize/index.js';
|
|
6
6
|
import type { SiblingPath } from './sibling_path.js';
|
|
@@ -38,6 +38,14 @@ export class MembershipWitness<N extends number> {
|
|
|
38
38
|
return [new Fr(this.leafIndex), ...this.siblingPath];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Returns a representation of the membership witness as expected by intrinsic Noir deserialization.
|
|
43
|
+
*/
|
|
44
|
+
public toNoirRepresentation(): (string | string[])[] {
|
|
45
|
+
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
46
|
+
return [new Fr(this.leafIndex).toString() as string, this.siblingPath.map(fr => fr.toString()) as string[]];
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
static schemaFor<N extends number>(size: N) {
|
|
42
50
|
return schemas.Buffer.transform(b => MembershipWitness.fromBuffer(b, size));
|
|
43
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
2
|
|
|
3
3
|
import type { AsyncHasher } from './hasher.js';
|
|
4
4
|
import { MerkleTree } from './merkle_tree.js';
|
|
@@ -19,7 +19,7 @@ export class MerkleTreeCalculator {
|
|
|
19
19
|
height: number,
|
|
20
20
|
zeroLeaf: Buffer = Buffer.alloc(32),
|
|
21
21
|
hasher = async (left: Buffer, right: Buffer) =>
|
|
22
|
-
(await
|
|
22
|
+
(await poseidon2Hash([left, right])).toBuffer() as Buffer<ArrayBuffer>,
|
|
23
23
|
) {
|
|
24
24
|
const zeroHashes = [zeroLeaf];
|
|
25
25
|
for (let i = 0; i < height; i++) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { makeTuple } from '../array/array.js';
|
|
2
|
-
import {
|
|
3
|
-
import { Fr } from '../
|
|
2
|
+
import { poseidon2Hash } from '../crypto/poseidon/index.js';
|
|
3
|
+
import { Fr } from '../curves/bn254/index.js';
|
|
4
4
|
import { schemas } from '../schemas/index.js';
|
|
5
5
|
import {
|
|
6
6
|
type Tuple,
|
|
@@ -172,7 +172,7 @@ export async function computeRootFromSiblingPath(
|
|
|
172
172
|
leaf: Buffer,
|
|
173
173
|
siblingPath: Buffer[],
|
|
174
174
|
index: number,
|
|
175
|
-
hasher = async (left: Buffer, right: Buffer) => (await
|
|
175
|
+
hasher = async (left: Buffer, right: Buffer) => (await poseidon2Hash([left, right])).toBuffer(),
|
|
176
176
|
) {
|
|
177
177
|
let result = leaf;
|
|
178
178
|
for (const sibling of siblingPath) {
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { shaMerkleHash } from './
|
|
2
|
-
import type { Hasher } from './hasher.js';
|
|
1
|
+
import { type Hasher, shaMerkleHash } from './hasher.js';
|
|
3
2
|
import { SiblingPath } from './sibling_path.js';
|
|
4
3
|
import { type TreeNodeLocation, UnbalancedTreeStore } from './unbalanced_tree_store.js';
|
|
5
4
|
|
|
6
|
-
export function computeCompressedUnbalancedMerkleTreeRoot(
|
|
7
|
-
leaves: Buffer[],
|
|
8
|
-
valueToCompress = Buffer.alloc(32),
|
|
9
|
-
emptyRoot = Buffer.alloc(32),
|
|
10
|
-
hasher?: Hasher['hash'],
|
|
11
|
-
): Buffer {
|
|
12
|
-
const calculator = UnbalancedMerkleTreeCalculator.create(leaves, valueToCompress, emptyRoot, hasher);
|
|
13
|
-
return calculator.getRoot();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
5
|
interface TreeNode {
|
|
17
6
|
value: Buffer;
|
|
18
7
|
leafIndex?: number;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
poseidonMerkleHash,
|
|
5
|
-
shaMerkleHash,
|
|
6
|
-
} from './balanced_merkle_tree.js';
|
|
1
|
+
import { computeBalancedMerkleTreeRoot, computeBalancedMerkleTreeRootAsync } from './balanced_merkle_tree_root.js';
|
|
2
|
+
import { poseidonMerkleHash, shaMerkleHash } from './hasher.js';
|
|
3
|
+
import { UnbalancedMerkleTreeCalculator } from './unbalanced_merkle_tree_calculator.js';
|
|
7
4
|
|
|
8
5
|
export const computeUnbalancedShaRoot = (leaves: Buffer[]) => computeUnbalancedMerkleTreeRoot(leaves, shaMerkleHash);
|
|
9
6
|
|
|
10
7
|
export const computeUnbalancedPoseidonRoot = async (leaves: Buffer[]) =>
|
|
11
8
|
await computeUnbalancedMerkleTreeRootAsync(leaves, poseidonMerkleHash);
|
|
12
9
|
|
|
10
|
+
export const computeWonkyShaRoot = (leaves: Buffer[]) => computeWonkyMerkleTreeRoot(leaves);
|
|
11
|
+
|
|
13
12
|
/**
|
|
14
13
|
* Computes the Merkle root of an unbalanced tree.
|
|
15
14
|
*
|
|
@@ -101,59 +100,16 @@ export async function computeUnbalancedMerkleTreeRootAsync(
|
|
|
101
100
|
return root!;
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function findPosition(
|
|
119
|
-
rootLevel: number,
|
|
120
|
-
leafLevel: number,
|
|
121
|
-
numLeaves: number,
|
|
122
|
-
indexOffset: number,
|
|
123
|
-
targetIndex: number,
|
|
124
|
-
): { level: number; indexAtLevel: number } {
|
|
125
|
-
if (numLeaves <= 1) {
|
|
126
|
-
// Single leaf.
|
|
127
|
-
return { level: rootLevel, indexAtLevel: indexOffset };
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// The largest balanced tree that can be created with the given number of leaves.
|
|
131
|
-
const maxBalancedTreeDepth = getMaxBalancedSubtreeDepth(numLeaves);
|
|
132
|
-
const numBalancedLeaves = 2 ** maxBalancedTreeDepth;
|
|
133
|
-
const numRemainingLeaves = numLeaves - numBalancedLeaves;
|
|
134
|
-
|
|
135
|
-
if (targetIndex < numBalancedLeaves) {
|
|
136
|
-
// Target is in the balanced tree.
|
|
137
|
-
|
|
138
|
-
// - If numRemainingLeaves is 0: this balanced tree is grown from the current root.
|
|
139
|
-
// - If numRemainingLeaves is not 0: the remaining leaves will form another tree, which will become the right child of the root.
|
|
140
|
-
// And the balanced tree will be the left child of the root.
|
|
141
|
-
// There will be an extra level between the root of the balanced tree and the current root.
|
|
142
|
-
const extraLevel = numRemainingLeaves ? 1 : 0;
|
|
143
|
-
|
|
144
|
-
return { level: rootLevel + maxBalancedTreeDepth + extraLevel, indexAtLevel: indexOffset + targetIndex };
|
|
145
|
-
} else {
|
|
146
|
-
// Target is in the right branch.
|
|
147
|
-
const rightBranchMaxLevel = getMaxUnbalancedTreeDepth(numRemainingLeaves);
|
|
148
|
-
const shiftedUp = leafLevel - rootLevel - rightBranchMaxLevel - 1;
|
|
149
|
-
const nextLeafLevel = leafLevel - shiftedUp;
|
|
150
|
-
const newIndexOffset = (indexOffset + numBalancedLeaves) >> shiftedUp;
|
|
151
|
-
const shiftedTargetIndex = targetIndex - numBalancedLeaves;
|
|
152
|
-
return findPosition(rootLevel + 1, nextLeafLevel, numRemainingLeaves, newIndexOffset, shiftedTargetIndex);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function findLeafLevelAndIndex(numLeaves: number, leafIndex: number) {
|
|
157
|
-
const maxLevel = getMaxUnbalancedTreeDepth(numLeaves);
|
|
158
|
-
return findPosition(0, maxLevel, numLeaves, 0, leafIndex);
|
|
103
|
+
// A **wonky** tree is a "compressed" unbalanced Merkle tree.
|
|
104
|
+
// It is constructed in the same way as an unbalanced tree: by first creating the largest possible left subtree, with
|
|
105
|
+
// the remaining leaves forming a right subtree that follows the same process recursively.
|
|
106
|
+
// During construction, leaves equal to `valueToCompress` are skipped (compressed) and do not contribute to the tree.
|
|
107
|
+
export function computeWonkyMerkleTreeRoot(
|
|
108
|
+
leaves: Buffer[],
|
|
109
|
+
valueToCompress = Buffer.alloc(32),
|
|
110
|
+
emptyRoot = Buffer.alloc(32),
|
|
111
|
+
hasher = shaMerkleHash,
|
|
112
|
+
): Buffer {
|
|
113
|
+
const calculator = UnbalancedMerkleTreeCalculator.create(leaves, valueToCompress, emptyRoot, hasher);
|
|
114
|
+
return calculator.getRoot();
|
|
159
115
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { findLeafLevelAndIndex } from './unbalanced_merkle_tree.js';
|
|
2
|
-
|
|
3
1
|
export interface TreeNodeLocation {
|
|
4
2
|
level: number;
|
|
5
3
|
index: number;
|
|
@@ -104,3 +102,60 @@ export class UnbalancedTreeStore<T> {
|
|
|
104
102
|
return `${location.level}-${location.index}`;
|
|
105
103
|
}
|
|
106
104
|
}
|
|
105
|
+
|
|
106
|
+
/// Get the depth of the maximum balanced tree that can be created with the given number of leaves. The subtree will be
|
|
107
|
+
/// the left most subtree of the unbalanced tree with a total of `numLeaves` leaves.
|
|
108
|
+
///
|
|
109
|
+
/// Note: All the leaves may not be used to form the tree. For example, if there are 5 leaves, the maximum depth is 2,
|
|
110
|
+
/// only 4 leaves are used to form a balanced tree.
|
|
111
|
+
function getMaxBalancedSubtreeDepth(numLeaves: number) {
|
|
112
|
+
return Math.floor(Math.log2(numLeaves));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/// Get the maximum depth of an unbalanced tree that can be created with the given number of leaves.
|
|
116
|
+
function getMaxUnbalancedTreeDepth(numLeaves: number) {
|
|
117
|
+
return Math.ceil(Math.log2(numLeaves));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function findPosition(
|
|
121
|
+
rootLevel: number,
|
|
122
|
+
leafLevel: number,
|
|
123
|
+
numLeaves: number,
|
|
124
|
+
indexOffset: number,
|
|
125
|
+
targetIndex: number,
|
|
126
|
+
): { level: number; indexAtLevel: number } {
|
|
127
|
+
if (numLeaves <= 1) {
|
|
128
|
+
// Single leaf.
|
|
129
|
+
return { level: rootLevel, indexAtLevel: indexOffset };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// The largest balanced tree that can be created with the given number of leaves.
|
|
133
|
+
const maxBalancedTreeDepth = getMaxBalancedSubtreeDepth(numLeaves);
|
|
134
|
+
const numBalancedLeaves = 2 ** maxBalancedTreeDepth;
|
|
135
|
+
const numRemainingLeaves = numLeaves - numBalancedLeaves;
|
|
136
|
+
|
|
137
|
+
if (targetIndex < numBalancedLeaves) {
|
|
138
|
+
// Target is in the balanced tree.
|
|
139
|
+
|
|
140
|
+
// - If numRemainingLeaves is 0: this balanced tree is grown from the current root.
|
|
141
|
+
// - If numRemainingLeaves is not 0: the remaining leaves will form another tree, which will become the right child of the root.
|
|
142
|
+
// And the balanced tree will be the left child of the root.
|
|
143
|
+
// There will be an extra level between the root of the balanced tree and the current root.
|
|
144
|
+
const extraLevel = numRemainingLeaves ? 1 : 0;
|
|
145
|
+
|
|
146
|
+
return { level: rootLevel + maxBalancedTreeDepth + extraLevel, indexAtLevel: indexOffset + targetIndex };
|
|
147
|
+
} else {
|
|
148
|
+
// Target is in the right branch.
|
|
149
|
+
const rightBranchMaxLevel = getMaxUnbalancedTreeDepth(numRemainingLeaves);
|
|
150
|
+
const shiftedUp = leafLevel - rootLevel - rightBranchMaxLevel - 1;
|
|
151
|
+
const nextLeafLevel = leafLevel - shiftedUp;
|
|
152
|
+
const newIndexOffset = (indexOffset + numBalancedLeaves) >> shiftedUp;
|
|
153
|
+
const shiftedTargetIndex = targetIndex - numBalancedLeaves;
|
|
154
|
+
return findPosition(rootLevel + 1, nextLeafLevel, numRemainingLeaves, newIndexOffset, shiftedTargetIndex);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function findLeafLevelAndIndex(numLeaves: number, leafIndex: number) {
|
|
159
|
+
const maxLevel = getMaxUnbalancedTreeDepth(numLeaves);
|
|
160
|
+
return findPosition(0, maxLevel, numLeaves, 0, leafIndex);
|
|
161
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -19,6 +19,16 @@ export function unfreeze<T>(obj: T): Writeable<T> {
|
|
|
19
19
|
return obj as Writeable<T>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/** Is defined type guard */
|
|
23
|
+
export function isDefined<T>(value: T | undefined): value is T {
|
|
24
|
+
return value !== undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Type guard for error classes */
|
|
28
|
+
export function isErrorClass<T extends Error>(value: unknown, errorClass: new (...args: any[]) => T): value is T {
|
|
29
|
+
return value instanceof errorClass || (value instanceof Error && value.name === errorClass.name);
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
/** Resolves a record-like type. Lifted from viem. */
|
|
23
33
|
export type Prettify<T> = {
|
|
24
34
|
[K in keyof T]: T[K];
|
|
@@ -28,7 +38,7 @@ export type Prettify<T> = {
|
|
|
28
38
|
* Type-safe Event Emitter type
|
|
29
39
|
* @example
|
|
30
40
|
* export type ArchiverEmitter = TypedEventEmitter<{
|
|
31
|
-
* [L2BlockSourceEvents.
|
|
41
|
+
* [L2BlockSourceEvents.L2PruneUnproven]: (args: L2BlockSourceEvent) => void;
|
|
32
42
|
* [L2BlockSourceEvents.L2BlockProven]: (args: L2BlockSourceEvent) => void;
|
|
33
43
|
* }>;
|
|
34
44
|
* class Archiver extends (EventEmitter as new () => ArchiverEmitter) {
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BN254 utility functions for point operations.
|
|
3
|
-
* Provides compression, decompression, and public key generation for the BN254 curve.
|
|
4
|
-
* Uses the bb.js Barretenberg backend for point operations.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Generate a compressed BN254 G1 public key from a private key.
|
|
8
|
-
*
|
|
9
|
-
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
10
|
-
* @returns Compressed G1 point (32 bytes with sign bit in MSB)
|
|
11
|
-
*/
|
|
12
|
-
export declare function computeBn254G1PublicKeyCompressed(privateKeyHex: string): Promise<string>;
|
|
13
|
-
/**
|
|
14
|
-
* Generate uncompressed BN254 G1 public key from a private key.
|
|
15
|
-
*
|
|
16
|
-
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
17
|
-
* @returns G1 point in affine coordinates
|
|
18
|
-
*/
|
|
19
|
-
export declare function computeBn254G1PublicKey(privateKeyHex: string): Promise<{
|
|
20
|
-
x: bigint;
|
|
21
|
-
y: bigint;
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* Generate BN254 G2 public key from a private key.
|
|
25
|
-
*
|
|
26
|
-
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
27
|
-
* @returns G2 point in affine coordinates
|
|
28
|
-
*/
|
|
29
|
-
export declare function computeBn254G2PublicKey(privateKeyHex: string): Promise<{
|
|
30
|
-
x: {
|
|
31
|
-
c0: bigint;
|
|
32
|
-
c1: bigint;
|
|
33
|
-
};
|
|
34
|
-
y: {
|
|
35
|
-
c0: bigint;
|
|
36
|
-
c1: bigint;
|
|
37
|
-
};
|
|
38
|
-
}>;
|
|
39
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm4yNTRfdXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jcnlwdG8vYm4yNTQvYm4yNTRfdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0E7Ozs7R0FJRztBQUVIOzs7OztHQUtHO0FBQ0gsd0JBQXNCLGlDQUFpQyxDQUFDLGFBQWEsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQVU5RjtBQUVEOzs7OztHQUtHO0FBQ0gsd0JBQXNCLHVCQUF1QixDQUFDLGFBQWEsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDO0lBQUUsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUFDLENBQUMsRUFBRSxNQUFNLENBQUE7Q0FBRSxDQUFDLENBUXRHO0FBRUQ7Ozs7O0dBS0c7QUFDSCx3QkFBc0IsdUJBQXVCLENBQUMsYUFBYSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUM7SUFDNUUsQ0FBQyxFQUFFO1FBQUUsRUFBRSxFQUFFLE1BQU0sQ0FBQztRQUFDLEVBQUUsRUFBRSxNQUFNLENBQUE7S0FBRSxDQUFDO0lBQzlCLENBQUMsRUFBRTtRQUFFLEVBQUUsRUFBRSxNQUFNLENBQUM7UUFBQyxFQUFFLEVBQUUsTUFBTSxDQUFBO0tBQUUsQ0FBQztDQUMvQixDQUFDLENBV0QifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bn254_utils.d.ts","sourceRoot":"","sources":["../../../src/crypto/bn254/bn254_utils.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;;;;;GAKG;AACH,wBAAsB,iCAAiC,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU9F;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAQtG;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5E,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/B,CAAC,CAWD"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Fr } from '../../fields/fields.js';
|
|
2
|
-
import { Bn254G1Point, Bn254G2Point } from './index.js';
|
|
3
|
-
/**
|
|
4
|
-
* BN254 utility functions for point operations.
|
|
5
|
-
* Provides compression, decompression, and public key generation for the BN254 curve.
|
|
6
|
-
* Uses the bb.js Barretenberg backend for point operations.
|
|
7
|
-
*/ /**
|
|
8
|
-
* Generate a compressed BN254 G1 public key from a private key.
|
|
9
|
-
*
|
|
10
|
-
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
11
|
-
* @returns Compressed G1 point (32 bytes with sign bit in MSB)
|
|
12
|
-
*/ export async function computeBn254G1PublicKeyCompressed(privateKeyHex) {
|
|
13
|
-
const sk = BigInt(privateKeyHex);
|
|
14
|
-
const skReduced = sk % Fr.MODULUS;
|
|
15
|
-
// Generate G1 point on BN254 curve using bb.js
|
|
16
|
-
const scalar = Fr.fromString(skReduced.toString());
|
|
17
|
-
const pk1 = await Bn254G1Point.generator(scalar);
|
|
18
|
-
// Compress the point using the primitive method
|
|
19
|
-
return '0x' + pk1.compress().toString('hex');
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Generate uncompressed BN254 G1 public key from a private key.
|
|
23
|
-
*
|
|
24
|
-
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
25
|
-
* @returns G1 point in affine coordinates
|
|
26
|
-
*/ export async function computeBn254G1PublicKey(privateKeyHex) {
|
|
27
|
-
const sk = BigInt(privateKeyHex);
|
|
28
|
-
const skReduced = sk % Fr.MODULUS;
|
|
29
|
-
const scalar = Fr.fromString(skReduced.toString());
|
|
30
|
-
const pk1 = await Bn254G1Point.generator(scalar);
|
|
31
|
-
return {
|
|
32
|
-
x: pk1.x.toBigInt(),
|
|
33
|
-
y: pk1.y.toBigInt()
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Generate BN254 G2 public key from a private key.
|
|
38
|
-
*
|
|
39
|
-
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
40
|
-
* @returns G2 point in affine coordinates
|
|
41
|
-
*/ export async function computeBn254G2PublicKey(privateKeyHex) {
|
|
42
|
-
const sk = BigInt(privateKeyHex);
|
|
43
|
-
const skReduced = sk % Fr.MODULUS;
|
|
44
|
-
const scalar = Fr.fromString(skReduced.toString());
|
|
45
|
-
const pk2 = await Bn254G2Point.generator(scalar);
|
|
46
|
-
return {
|
|
47
|
-
x: {
|
|
48
|
-
c0: pk2.x[0].toBigInt(),
|
|
49
|
-
c1: pk2.x[1].toBigInt()
|
|
50
|
-
},
|
|
51
|
-
y: {
|
|
52
|
-
c0: pk2.y[0].toBigInt(),
|
|
53
|
-
c1: pk2.y[1].toBigInt()
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
package/dest/crypto/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './keccak/index.js';
|
|
2
|
-
export * from './random/index.js';
|
|
3
|
-
export * from './sha256/index.js';
|
|
4
|
-
export * from './sha512/index.js';
|
|
5
|
-
export * from './pedersen/index.js';
|
|
6
|
-
export * from './poseidon/index.js';
|
|
7
|
-
export * from './secp256k1-signer/index.js';
|
|
8
|
-
export * from './keys/index.js';
|
|
9
|
-
export * from './aes128/index.js';
|
|
10
|
-
export * from './bn254/index.js';
|
|
11
|
-
export * from './grumpkin/index.js';
|
|
12
|
-
export * from './ecdsa/index.js';
|
|
13
|
-
export * from './secp256k1/index.js';
|
|
14
|
-
export * from './schnorr/index.js';
|
|
15
|
-
export * from './signature/index.js';
|
|
16
|
-
export * from './bls/index.js';
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jcnlwdG8vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxtQkFBbUIsQ0FBQztBQUNsQyxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyxtQkFBbUIsQ0FBQztBQUNsQyxjQUFjLHFCQUFxQixDQUFDO0FBQ3BDLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyw2QkFBNkIsQ0FBQztBQUM1QyxjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyxrQkFBa0IsQ0FBQztBQUNqQyxjQUFjLHFCQUFxQixDQUFDO0FBQ3BDLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyxzQkFBc0IsQ0FBQztBQUNyQyxjQUFjLG9CQUFvQixDQUFDO0FBQ25DLGNBQWMsc0JBQXNCLENBQUM7QUFDckMsY0FBYyxnQkFBZ0IsQ0FBQyJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
|
package/dest/crypto/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from './keccak/index.js';
|
|
2
|
-
export * from './random/index.js';
|
|
3
|
-
export * from './sha256/index.js';
|
|
4
|
-
export * from './sha512/index.js';
|
|
5
|
-
export * from './pedersen/index.js';
|
|
6
|
-
export * from './poseidon/index.js';
|
|
7
|
-
export * from './secp256k1-signer/index.js';
|
|
8
|
-
export * from './keys/index.js';
|
|
9
|
-
export * from './aes128/index.js';
|
|
10
|
-
export * from './bn254/index.js';
|
|
11
|
-
export * from './grumpkin/index.js';
|
|
12
|
-
export * from './ecdsa/index.js';
|
|
13
|
-
export * from './secp256k1/index.js';
|
|
14
|
-
export * from './schnorr/index.js';
|
|
15
|
-
export * from './signature/index.js';
|
|
16
|
-
export * from './bls/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bls12_fields.d.ts","sourceRoot":"","sources":["../../src/fields/bls12_fields.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAK/B,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAcjC;;GAEG;AACH,8BAAsB,UAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAS;IAE1B,SAAS,aAAa,KAAK,EAAE,MAAM,GA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,QAAQ,4BAMP;IAED;;;;;;OAMG;IACH,QAAQ,kBAEP;IAED;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,UAAU,WAErB;IAED;;OAEG;IACH,MAAM,YAEL;IAED;;;OAGG;IACH,IAAW,GAAG,YAEb;IAED,+CAA+C;IAE/C,sBAAsB,0BAErB;IAED,GAAG,CAAC,GAAG,EAAE,UAAU,cAElB;IAED,MAAM,eAEL;IAED,GAAG,CAAC,GAAG,EAAE,UAAU,cAElB;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,OAAO,cAMf;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAG,EAAE,OAAO,cAErB;IAED;;;;;OAKG;IACH,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,cAOpD;CACF;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,EAGlC;CACF"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { Tuple } from '../serialize/types.js';
|
|
2
|
-
import { Fr } from './fields.js';
|
|
3
|
-
/**
|
|
4
|
-
* Class to wrap a single point coordinate.
|
|
5
|
-
* This class handles the complexities of representing point coordinates as 32 byte buffers as well as fields.
|
|
6
|
-
* The coordinate value is split across 2 fields to ensure that the max size of a field is not breached.
|
|
7
|
-
* This is achieved by placing the most significant byte of the lower field into the least significant byte of the higher field.
|
|
8
|
-
* Calls to 'toBuffer' or 'toBigInt' undo this change and simply return the original 32 byte value.
|
|
9
|
-
* Calls to 'toFieldsBuffer' will return a 64 bytes buffer containing the serialized fields.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Coordinate {
|
|
12
|
-
fields: Tuple<Fr, 2>;
|
|
13
|
-
static ZERO: Coordinate;
|
|
14
|
-
constructor(
|
|
15
|
-
/**
|
|
16
|
-
* The fields of the coordinate value. Least significant limb at index 0.
|
|
17
|
-
*/
|
|
18
|
-
fields: Tuple<Fr, 2>);
|
|
19
|
-
/**
|
|
20
|
-
* Converts the coordinate data into a tuple of fields
|
|
21
|
-
* @returns A tuple of the coordinate fields
|
|
22
|
-
*/
|
|
23
|
-
toFields(): Tuple<Fr, 2>;
|
|
24
|
-
/**
|
|
25
|
-
* Generates a random coordinate value
|
|
26
|
-
* @returns The random coordinate
|
|
27
|
-
*/
|
|
28
|
-
static random(): Coordinate;
|
|
29
|
-
/**
|
|
30
|
-
* serializes the object to buffer of 2 fields.
|
|
31
|
-
* @returns A buffer serialization of the object.
|
|
32
|
-
*/
|
|
33
|
-
toFieldsBuffer(): Buffer;
|
|
34
|
-
/**
|
|
35
|
-
* serializes the coordinate to a single 32 byte buffer.
|
|
36
|
-
* @returns A buffer serialization of the object.
|
|
37
|
-
*/
|
|
38
|
-
toBuffer(): Buffer;
|
|
39
|
-
/**
|
|
40
|
-
* Returns true if this coordinate is equal to the one provided
|
|
41
|
-
* @param other - The coordinate against which to compare
|
|
42
|
-
* @returns True if the coordinates are the same, false otherwise
|
|
43
|
-
*/
|
|
44
|
-
equals(other: Coordinate): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Returns the coordinate's value as a bigint
|
|
47
|
-
* @returns The coordinate value as a bigint
|
|
48
|
-
*/
|
|
49
|
-
toBigInt(): bigint;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a coordinate object from a 32 byte coordinate value
|
|
52
|
-
* @param coordinate - A buffer containing the 32 byte coordinate value
|
|
53
|
-
* @returns The new coordinate object
|
|
54
|
-
*/
|
|
55
|
-
static fromBuffer(coordinate: Buffer): Coordinate;
|
|
56
|
-
/**
|
|
57
|
-
* Creates a coordinate object from a field
|
|
58
|
-
* @param coordinate - The field containing the coordinate
|
|
59
|
-
* @returns The new coordinate object
|
|
60
|
-
*/
|
|
61
|
-
static fromField(coordinate: Fr): Coordinate;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=data:application/json;base64,eyJ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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate.d.ts","sourceRoot":"","sources":["../../src/fields/coordinate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;;;;GAOG;AACH,qBAAa,UAAU;IAOZ,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAN7B,MAAM,CAAC,IAAI,aAAsC;IAEjD;IACE;;OAEG;IACI,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EACzB;IAEJ;;;OAGG;IACH,QAAQ,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAEvB;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,UAAU,CAE1B;IAED;;;OAGG;IACH,cAAc,IAAI,MAAM,CAEvB;IAED;;;OAGG;IACH,QAAQ,IAAI,MAAM,CAKjB;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEjC;IAED;;;OAGG;IACH,QAAQ,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,cAUnC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,cAM9B;CACF"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { toBigIntBE } from '../bigint-buffer/index.js';
|
|
2
|
-
import { Fr } from './fields.js';
|
|
3
|
-
/**
|
|
4
|
-
* Class to wrap a single point coordinate.
|
|
5
|
-
* This class handles the complexities of representing point coordinates as 32 byte buffers as well as fields.
|
|
6
|
-
* The coordinate value is split across 2 fields to ensure that the max size of a field is not breached.
|
|
7
|
-
* This is achieved by placing the most significant byte of the lower field into the least significant byte of the higher field.
|
|
8
|
-
* Calls to 'toBuffer' or 'toBigInt' undo this change and simply return the original 32 byte value.
|
|
9
|
-
* Calls to 'toFieldsBuffer' will return a 64 bytes buffer containing the serialized fields.
|
|
10
|
-
*/ export class Coordinate {
|
|
11
|
-
fields;
|
|
12
|
-
static ZERO = new Coordinate([
|
|
13
|
-
Fr.ZERO,
|
|
14
|
-
Fr.ZERO
|
|
15
|
-
]);
|
|
16
|
-
constructor(/**
|
|
17
|
-
* The fields of the coordinate value. Least significant limb at index 0.
|
|
18
|
-
*/ fields){
|
|
19
|
-
this.fields = fields;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Converts the coordinate data into a tuple of fields
|
|
23
|
-
* @returns A tuple of the coordinate fields
|
|
24
|
-
*/ toFields() {
|
|
25
|
-
return this.fields;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Generates a random coordinate value
|
|
29
|
-
* @returns The random coordinate
|
|
30
|
-
*/ static random() {
|
|
31
|
-
return this.fromField(Fr.random());
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* serializes the object to buffer of 2 fields.
|
|
35
|
-
* @returns A buffer serialization of the object.
|
|
36
|
-
*/ toFieldsBuffer() {
|
|
37
|
-
return Buffer.concat([
|
|
38
|
-
this.fields[0].toBuffer(),
|
|
39
|
-
this.fields[1].toBuffer()
|
|
40
|
-
]);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* serializes the coordinate to a single 32 byte buffer.
|
|
44
|
-
* @returns A buffer serialization of the object.
|
|
45
|
-
*/ toBuffer() {
|
|
46
|
-
const buf0 = this.fields[0].toBuffer();
|
|
47
|
-
const buf1 = this.fields[1].toBuffer();
|
|
48
|
-
buf0[0] = buf1[31];
|
|
49
|
-
return buf0;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Returns true if this coordinate is equal to the one provided
|
|
53
|
-
* @param other - The coordinate against which to compare
|
|
54
|
-
* @returns True if the coordinates are the same, false otherwise
|
|
55
|
-
*/ equals(other) {
|
|
56
|
-
return this.toBigInt() === other.toBigInt();
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Returns the coordinate's value as a bigint
|
|
60
|
-
* @returns The coordinate value as a bigint
|
|
61
|
-
*/ toBigInt() {
|
|
62
|
-
return toBigIntBE(this.toBuffer());
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Creates a coordinate object from a 32 byte coordinate value
|
|
66
|
-
* @param coordinate - A buffer containing the 32 byte coordinate value
|
|
67
|
-
* @returns The new coordinate object
|
|
68
|
-
*/ static fromBuffer(coordinate) {
|
|
69
|
-
if (coordinate.length != 32) {
|
|
70
|
-
throw new Error(`Invalid size of coordinate buffer`);
|
|
71
|
-
}
|
|
72
|
-
const buf0 = Buffer.alloc(32);
|
|
73
|
-
coordinate.copy(buf0, 0, 0, 32);
|
|
74
|
-
const buf1 = Buffer.alloc(32);
|
|
75
|
-
buf1[31] = buf0[0];
|
|
76
|
-
buf0[0] = 0;
|
|
77
|
-
return new Coordinate([
|
|
78
|
-
Fr.fromBuffer(buf0),
|
|
79
|
-
Fr.fromBuffer(buf1)
|
|
80
|
-
]);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Creates a coordinate object from a field
|
|
84
|
-
* @param coordinate - The field containing the coordinate
|
|
85
|
-
* @returns The new coordinate object
|
|
86
|
-
*/ static fromField(coordinate) {
|
|
87
|
-
const buf0 = coordinate.toBuffer();
|
|
88
|
-
const buf1 = Buffer.alloc(32);
|
|
89
|
-
buf1[31] = buf0[0];
|
|
90
|
-
buf0[0] = 0;
|
|
91
|
-
return new Coordinate([
|
|
92
|
-
Fr.fromBuffer(buf0),
|
|
93
|
-
Fr.fromBuffer(buf1)
|
|
94
|
-
]);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/fields/fields.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,M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CD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,EAAE,CAAC;AAChC,eAAO,MAAM,cAAc,WAAK,CAAC;AAEjC,6GAA6G;AAC7G,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,SAAS,SAAS,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,6BAEpH"}
|
package/dest/fields/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './fields.js';
|
|
2
|
-
export * from './point.js';
|
|
3
|
-
export * from './coordinate.js';
|
|
4
|
-
export * from './bls12_fields.js';
|
|
5
|
-
export * from './bls12_point.js';
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maWVsZHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyxpQkFBaUIsQ0FBQztBQUNoQyxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsa0JBQWtCLENBQUMifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/dest/fields/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../src/fields/point.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,WAAW,EA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