@aztec/bb.js 0.0.1-alpha.0
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 +3 -0
- package/dest/async_map/index.d.ts +10 -0
- package/dest/async_map/index.d.ts.map +1 -0
- package/dest/async_map/index.js +16 -0
- package/dest/barretenberg-threads.wasm +0 -0
- package/dest/barretenberg.wasm +0 -0
- package/dest/barretenberg_api/blake2s.test.d.ts +2 -0
- package/dest/barretenberg_api/blake2s.test.d.ts.map +1 -0
- package/dest/barretenberg_api/blake2s.test.js +30 -0
- package/dest/barretenberg_api/common.test.d.ts +2 -0
- package/dest/barretenberg_api/common.test.d.ts.map +1 -0
- package/dest/barretenberg_api/common.test.js +18 -0
- package/dest/barretenberg_api/index.d.ts +101 -0
- package/dest/barretenberg_api/index.d.ts.map +1 -0
- package/dest/barretenberg_api/index.js +371 -0
- package/dest/barretenberg_api/pedersen.test.d.ts +2 -0
- package/dest/barretenberg_api/pedersen.test.d.ts.map +1 -0
- package/dest/barretenberg_api/pedersen.test.js +69 -0
- package/dest/barretenberg_api/schnorr.test.d.ts +2 -0
- package/dest/barretenberg_api/schnorr.test.d.ts.map +1 -0
- package/dest/barretenberg_api/schnorr.test.js +113 -0
- package/dest/barretenberg_binder/heap_allocator.d.ts +22 -0
- package/dest/barretenberg_binder/heap_allocator.d.ts.map +1 -0
- package/dest/barretenberg_binder/heap_allocator.js +59 -0
- package/dest/barretenberg_binder/heap_allocator_sync.d.ts +22 -0
- package/dest/barretenberg_binder/heap_allocator_sync.d.ts.map +1 -0
- package/dest/barretenberg_binder/heap_allocator_sync.js +58 -0
- package/dest/barretenberg_binder/index.d.ts +32 -0
- package/dest/barretenberg_binder/index.d.ts.map +1 -0
- package/dest/barretenberg_binder/index.js +73 -0
- package/dest/barretenberg_wasm/barretenberg_wasm.d.ts +49 -0
- package/dest/barretenberg_wasm/barretenberg_wasm.d.ts.map +1 -0
- package/dest/barretenberg_wasm/barretenberg_wasm.js +190 -0
- package/dest/barretenberg_wasm/barretenberg_wasm.test.d.ts +2 -0
- package/dest/barretenberg_wasm/barretenberg_wasm.test.d.ts.map +1 -0
- package/dest/barretenberg_wasm/barretenberg_wasm.test.js +43 -0
- package/dest/barretenberg_wasm/browser/index.d.ts +8 -0
- package/dest/barretenberg_wasm/browser/index.d.ts.map +1 -0
- package/dest/barretenberg_wasm/browser/index.js +26 -0
- package/dest/barretenberg_wasm/browser/worker.d.ts +2 -0
- package/dest/barretenberg_wasm/browser/worker.d.ts.map +1 -0
- package/dest/barretenberg_wasm/browser/worker.js +11 -0
- package/dest/barretenberg_wasm/index.d.ts +2 -0
- package/dest/barretenberg_wasm/index.d.ts.map +1 -0
- package/dest/barretenberg_wasm/index.js +2 -0
- package/dest/barretenberg_wasm/node/index.d.ts +17 -0
- package/dest/barretenberg_wasm/node/index.d.ts.map +1 -0
- package/dest/barretenberg_wasm/node/index.js +40 -0
- package/dest/barretenberg_wasm/node/node_endpoint.d.ts +8 -0
- package/dest/barretenberg_wasm/node/node_endpoint.d.ts.map +1 -0
- package/dest/barretenberg_wasm/node/node_endpoint.js +28 -0
- package/dest/barretenberg_wasm/node/worker.d.ts +2 -0
- package/dest/barretenberg_wasm/node/worker.d.ts.map +1 -0
- package/dest/barretenberg_wasm/node/worker.js +9 -0
- package/dest/barretenberg_wasm.js +2 -0
- package/dest/barretenberg_wasm.js.LICENSE.txt +5 -0
- package/dest/bigint-array/index.d.ts +3 -0
- package/dest/bigint-array/index.d.ts.map +1 -0
- package/dest/bigint-array/index.js +21 -0
- package/dest/bindgen/function_declaration.d.ts +11 -0
- package/dest/bindgen/function_declaration.d.ts.map +1 -0
- package/dest/bindgen/function_declaration.js +2 -0
- package/dest/bindgen/index.d.ts +2 -0
- package/dest/bindgen/index.d.ts.map +1 -0
- package/dest/bindgen/index.js +15 -0
- package/dest/bindgen/mappings.d.ts +4 -0
- package/dest/bindgen/mappings.d.ts.map +1 -0
- package/dest/bindgen/mappings.js +63 -0
- package/dest/bindgen/rust.d.ts +2 -0
- package/dest/bindgen/rust.d.ts.map +1 -0
- package/dest/bindgen/rust.js +43 -0
- package/dest/bindgen/to_camel_case.d.ts +2 -0
- package/dest/bindgen/to_camel_case.d.ts.map +1 -0
- package/dest/bindgen/to_camel_case.js +11 -0
- package/dest/bindgen/typescript.d.ts +2 -0
- package/dest/bindgen/typescript.d.ts.map +1 -0
- package/dest/bindgen/typescript.js +80 -0
- package/dest/crs/browser/cached_net_crs.d.ts +25 -0
- package/dest/crs/browser/cached_net_crs.d.ts.map +1 -0
- package/dest/crs/browser/cached_net_crs.js +54 -0
- package/dest/crs/browser/index.d.ts +2 -0
- package/dest/crs/browser/index.d.ts.map +1 -0
- package/dest/crs/browser/index.js +2 -0
- package/dest/crs/index.d.ts +2 -0
- package/dest/crs/index.d.ts.map +1 -0
- package/dest/crs/index.js +2 -0
- package/dest/crs/net_crs.d.ts +36 -0
- package/dest/crs/net_crs.d.ts.map +1 -0
- package/dest/crs/net_crs.js +59 -0
- package/dest/crs/node/file_crs.d.ts +37 -0
- package/dest/crs/node/file_crs.d.ts.map +1 -0
- package/dest/crs/node/file_crs.js +51 -0
- package/dest/crs/node/index.d.ts +31 -0
- package/dest/crs/node/index.d.ts.map +1 -0
- package/dest/crs/node/index.js +41 -0
- package/dest/examples/simple.rawtest.d.ts +2 -0
- package/dest/examples/simple.rawtest.d.ts.map +1 -0
- package/dest/examples/simple.rawtest.js +24 -0
- package/dest/examples/simple.test.d.ts +2 -0
- package/dest/examples/simple.test.d.ts.map +1 -0
- package/dest/examples/simple.test.js +22 -0
- package/dest/factory/index.d.ts +21 -0
- package/dest/factory/index.d.ts.map +1 -0
- package/dest/factory/index.js +34 -0
- package/dest/index.d.ts +4 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.html +1 -0
- package/dest/index.js +4 -0
- package/dest/main-dev.d.ts +3 -0
- package/dest/main-dev.d.ts.map +1 -0
- package/dest/main-dev.js +3 -0
- package/dest/main.d.ts +10 -0
- package/dest/main.d.ts.map +1 -0
- package/dest/main.js +288 -0
- package/dest/random/browser/index.d.ts +2 -0
- package/dest/random/browser/index.d.ts.map +1 -0
- package/dest/random/browser/index.js +31 -0
- package/dest/random/index.d.ts +2 -0
- package/dest/random/index.d.ts.map +1 -0
- package/dest/random/index.js +2 -0
- package/dest/random/node/index.d.ts +2 -0
- package/dest/random/node/index.d.ts.map +1 -0
- package/dest/random/node/index.js +5 -0
- package/dest/serialize/buffer_reader.d.ts +28 -0
- package/dest/serialize/buffer_reader.d.ts.map +1 -0
- package/dest/serialize/buffer_reader.js +66 -0
- package/dest/serialize/index.d.ts +4 -0
- package/dest/serialize/index.d.ts.map +1 -0
- package/dest/serialize/index.js +4 -0
- package/dest/serialize/output_type.d.ts +11 -0
- package/dest/serialize/output_type.d.ts.map +1 -0
- package/dest/serialize/output_type.js +44 -0
- package/dest/serialize/serialize.d.ts +53 -0
- package/dest/serialize/serialize.d.ts.map +1 -0
- package/dest/serialize/serialize.js +139 -0
- package/dest/simple_test.js +2 -0
- package/dest/simple_test.js.LICENSE.txt +14 -0
- package/dest/types/fields.d.ts +33 -0
- package/dest/types/fields.d.ts.map +1 -0
- package/dest/types/fields.js +86 -0
- package/dest/types/fixed_size_buffer.d.ts +26 -0
- package/dest/types/fixed_size_buffer.d.ts.map +1 -0
- package/dest/types/fixed_size_buffer.js +54 -0
- package/dest/types/index.d.ts +6 -0
- package/dest/types/index.d.ts.map +1 -0
- package/dest/types/index.js +6 -0
- package/dest/types/point.d.ts +17 -0
- package/dest/types/point.d.ts.map +1 -0
- package/dest/types/point.js +32 -0
- package/dest/types/ptr.d.ts +13 -0
- package/dest/types/ptr.d.ts.map +1 -0
- package/dest/types/ptr.js +20 -0
- package/dest/types/raw_buffer.d.ts +3 -0
- package/dest/types/raw_buffer.d.ts.map +1 -0
- package/dest/types/raw_buffer.js +5 -0
- package/package.json +79 -0
- package/src/async_map/index.ts +15 -0
- package/src/barretenberg_api/blake2s.test.ts +39 -0
- package/src/barretenberg_api/common.test.ts +21 -0
- package/src/barretenberg_api/index.ts +461 -0
- package/src/barretenberg_api/pedersen.test.ts +84 -0
- package/src/barretenberg_api/schnorr.test.ts +169 -0
- package/src/barretenberg_binder/heap_allocator.ts +62 -0
- package/src/barretenberg_binder/heap_allocator_sync.ts +61 -0
- package/src/barretenberg_binder/index.ts +76 -0
- package/src/barretenberg_wasm/barretenberg_wasm.test.ts +52 -0
- package/src/barretenberg_wasm/barretenberg_wasm.ts +222 -0
- package/src/barretenberg_wasm/browser/index.ts +32 -0
- package/src/barretenberg_wasm/browser/worker.ts +13 -0
- package/src/barretenberg_wasm/index.ts +1 -0
- package/src/barretenberg_wasm/node/index.ts +46 -0
- package/src/barretenberg_wasm/node/node_endpoint.ts +28 -0
- package/src/barretenberg_wasm/node/worker.ts +10 -0
- package/src/bigint-array/index.ts +21 -0
- package/src/bindgen/function_declaration.ts +11 -0
- package/src/bindgen/index.ts +17 -0
- package/src/bindgen/mappings.ts +66 -0
- package/src/bindgen/rust.ts +52 -0
- package/src/bindgen/to_camel_case.ts +10 -0
- package/src/bindgen/typescript.ts +91 -0
- package/src/crs/browser/cached_net_crs.ts +60 -0
- package/src/crs/browser/index.ts +1 -0
- package/src/crs/index.ts +1 -0
- package/src/crs/net_crs.ts +69 -0
- package/src/crs/node/file_crs.ts +60 -0
- package/src/crs/node/index.ts +48 -0
- package/src/examples/simple.rawtest.ts +32 -0
- package/src/examples/simple.test.ts +27 -0
- package/src/factory/index.ts +36 -0
- package/src/index.html +9 -0
- package/src/index.ts +3 -0
- package/src/main-dev.ts +2 -0
- package/src/main.ts +329 -0
- package/src/random/browser/index.ts +32 -0
- package/src/random/index.ts +1 -0
- package/src/random/node/index.ts +5 -0
- package/src/serialize/buffer_reader.ts +82 -0
- package/src/serialize/index.ts +3 -0
- package/src/serialize/output_type.ts +53 -0
- package/src/serialize/serialize.ts +157 -0
- package/src/types/fields.ts +98 -0
- package/src/types/fixed_size_buffer.ts +59 -0
- package/src/types/index.ts +5 -0
- package/src/types/point.ts +35 -0
- package/src/types/ptr.ts +20 -0
- package/src/types/raw_buffer.ts +3 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
// WARNING: FILE CODE GENERATED BY BINDGEN UTILITY. DO NOT EDIT!
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
import { BarretenbergBinder, BarretenbergBinderSync } from '../barretenberg_binder/index.js';
|
|
4
|
+
import { BufferDeserializer, NumberDeserializer, VectorDeserializer, BoolDeserializer, StringDeserializer } from '../serialize/index.js';
|
|
5
|
+
import { Fr, Fq, Point, Buffer32, Buffer128, Ptr } from '../types/index.js';
|
|
6
|
+
|
|
7
|
+
export class BarretenbergApi {
|
|
8
|
+
constructor(public binder: BarretenbergBinder) {}
|
|
9
|
+
|
|
10
|
+
async destroy() {
|
|
11
|
+
await this.binder.wasm.destroy();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async pedersenInit(): Promise<void> {
|
|
15
|
+
const result = await this.binder.callWasmExport('pedersen_init', [], []);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async pedersenCompressFields(left: Fr, right: Fr): Promise<Fr> {
|
|
20
|
+
const result = await this.binder.callWasmExport('pedersen_compress_fields', [left, right], [Fr]);
|
|
21
|
+
return result[0];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async pedersenPlookupCompressFields(left: Fr, right: Fr): Promise<Fr> {
|
|
25
|
+
const result = await this.binder.callWasmExport('pedersen_plookup_compress_fields', [left, right], [Fr]);
|
|
26
|
+
return result[0];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async pedersenCompress(inputsBuffer: Fr[]): Promise<Fr> {
|
|
30
|
+
const result = await this.binder.callWasmExport('pedersen_compress', [inputsBuffer], [Fr]);
|
|
31
|
+
return result[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async pedersenPlookupCompress(inputsBuffer: Fr[]): Promise<Fr> {
|
|
35
|
+
const result = await this.binder.callWasmExport('pedersen_plookup_compress', [inputsBuffer], [Fr]);
|
|
36
|
+
return result[0];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async pedersenCompressWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Promise<Fr> {
|
|
40
|
+
const result = await this.binder.callWasmExport('pedersen_compress_with_hash_index', [inputsBuffer, hashIndex], [Fr]);
|
|
41
|
+
return result[0];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async pedersenCommit(inputsBuffer: Fr[]): Promise<Fr> {
|
|
45
|
+
const result = await this.binder.callWasmExport('pedersen_commit', [inputsBuffer], [Fr]);
|
|
46
|
+
return result[0];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async pedersenPlookupCommit(inputsBuffer: Fr[]): Promise<Fr> {
|
|
50
|
+
const result = await this.binder.callWasmExport('pedersen_plookup_commit', [inputsBuffer], [Fr]);
|
|
51
|
+
return result[0];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async pedersenBufferToField(data: Uint8Array): Promise<Fr> {
|
|
55
|
+
const result = await this.binder.callWasmExport('pedersen_buffer_to_field', [data], [Fr]);
|
|
56
|
+
return result[0];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async pedersenHashInit(): Promise<void> {
|
|
60
|
+
const result = await this.binder.callWasmExport('pedersen_hash_init', [], []);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async pedersenHashPair(left: Fr, right: Fr): Promise<Fr> {
|
|
65
|
+
const result = await this.binder.callWasmExport('pedersen_hash_pair', [left, right], [Fr]);
|
|
66
|
+
return result[0];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async pedersenHashMultiple(inputsBuffer: Fr[]): Promise<Fr> {
|
|
70
|
+
const result = await this.binder.callWasmExport('pedersen_hash_multiple', [inputsBuffer], [Fr]);
|
|
71
|
+
return result[0];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async pedersenHashMultipleWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Promise<Fr> {
|
|
75
|
+
const result = await this.binder.callWasmExport('pedersen_hash_multiple_with_hash_index', [inputsBuffer, hashIndex], [Fr]);
|
|
76
|
+
return result[0];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async pedersenHashToTree(data: Fr[]): Promise<Fr[]> {
|
|
80
|
+
const result = await this.binder.callWasmExport('pedersen_hash_to_tree', [data], [VectorDeserializer(Fr)]);
|
|
81
|
+
return result[0];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async blake2s(data: Uint8Array): Promise<Buffer32> {
|
|
85
|
+
const result = await this.binder.callWasmExport('blake2s', [data], [Buffer32]);
|
|
86
|
+
return result[0];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async blake2sToField(data: Uint8Array): Promise<Fr> {
|
|
90
|
+
const result = await this.binder.callWasmExport('blake2s_to_field_', [data], [Fr]);
|
|
91
|
+
return result[0];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async schnorrComputePublicKey(privateKey: Fr): Promise<Point> {
|
|
95
|
+
const result = await this.binder.callWasmExport('schnorr_compute_public_key', [privateKey], [Point]);
|
|
96
|
+
return result[0];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async schnorrNegatePublicKey(publicKeyBuffer: Point): Promise<Point> {
|
|
100
|
+
const result = await this.binder.callWasmExport('schnorr_negate_public_key', [publicKeyBuffer], [Point]);
|
|
101
|
+
return result[0];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async schnorrConstructSignature(message: Uint8Array, privateKey: Fr): Promise<[Buffer32, Buffer32]> {
|
|
105
|
+
const result = await this.binder.callWasmExport('schnorr_construct_signature', [message, privateKey], [Buffer32, Buffer32]);
|
|
106
|
+
return result as any;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async schnorrVerifySignature(message: Uint8Array, pubKey: Point, sigS: Buffer32, sigE: Buffer32): Promise<boolean> {
|
|
110
|
+
const result = await this.binder.callWasmExport('schnorr_verify_signature', [message, pubKey, sigS, sigE], [BoolDeserializer()]);
|
|
111
|
+
return result[0];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async schnorrMultisigCreateMultisigPublicKey(privateKey: Fq): Promise<Buffer128> {
|
|
115
|
+
const result = await this.binder.callWasmExport('schnorr_multisig_create_multisig_public_key', [privateKey], [Buffer128]);
|
|
116
|
+
return result[0];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async schnorrMultisigValidateAndCombineSignerPubkeys(signerPubkeyBuf: Buffer128[]): Promise<[Point, boolean]> {
|
|
120
|
+
const result = await this.binder.callWasmExport('schnorr_multisig_validate_and_combine_signer_pubkeys', [signerPubkeyBuf], [Point, BoolDeserializer()]);
|
|
121
|
+
return result as any;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async schnorrMultisigConstructSignatureRound1(): Promise<[Buffer128, Buffer128]> {
|
|
125
|
+
const result = await this.binder.callWasmExport('schnorr_multisig_construct_signature_round_1', [], [Buffer128, Buffer128]);
|
|
126
|
+
return result as any;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async schnorrMultisigConstructSignatureRound2(message: Uint8Array, privateKey: Fq, signerRoundOnePrivateBuf: Buffer128, signerPubkeysBuf: Buffer128[], roundOnePublicBuf: Buffer128[]): Promise<[Fq, boolean]> {
|
|
130
|
+
const result = await this.binder.callWasmExport('schnorr_multisig_construct_signature_round_2', [message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf], [Fq, BoolDeserializer()]);
|
|
131
|
+
return result as any;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async schnorrMultisigCombineSignatures(message: Uint8Array, signerPubkeysBuf: Buffer128[], roundOneBuf: Buffer128[], roundTwoBuf: Fr[]): Promise<[Buffer32, Buffer32, boolean]> {
|
|
135
|
+
const result = await this.binder.callWasmExport('schnorr_multisig_combine_signatures', [message, signerPubkeysBuf, roundOneBuf, roundTwoBuf], [Buffer32, Buffer32, BoolDeserializer()]);
|
|
136
|
+
return result as any;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async srsInitSrs(pointsBuf: Uint8Array, numPoints: number, g2PointBuf: Uint8Array): Promise<void> {
|
|
140
|
+
const result = await this.binder.callWasmExport('srs_init_srs', [pointsBuf, numPoints, g2PointBuf], []);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async examplesSimpleCreateAndVerifyProof(): Promise<boolean> {
|
|
145
|
+
const result = await this.binder.callWasmExport('examples_simple_create_and_verify_proof', [], [BoolDeserializer()]);
|
|
146
|
+
return result[0];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async testThreads(threads: number, iterations: number): Promise<number> {
|
|
150
|
+
const result = await this.binder.callWasmExport('test_threads', [threads, iterations], [NumberDeserializer()]);
|
|
151
|
+
return result[0];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async testThreadAbort(): Promise<void> {
|
|
155
|
+
const result = await this.binder.callWasmExport('test_thread_abort', [], []);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async testAbort(): Promise<void> {
|
|
160
|
+
const result = await this.binder.callWasmExport('test_abort', [], []);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async commonInitSlabAllocator(circuitSize: number): Promise<void> {
|
|
165
|
+
const result = await this.binder.callWasmExport('common_init_slab_allocator', [circuitSize], []);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async acirGetCircuitSizes(constraintSystemBuf: Uint8Array): Promise<[number, number, number]> {
|
|
170
|
+
const result = await this.binder.callWasmExport('acir_get_circuit_sizes', [constraintSystemBuf], [NumberDeserializer(), NumberDeserializer(), NumberDeserializer()]);
|
|
171
|
+
return result as any;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async acirNewAcirComposer(): Promise<Ptr> {
|
|
175
|
+
const result = await this.binder.callWasmExport('acir_new_acir_composer', [], [Ptr]);
|
|
176
|
+
return result[0];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async acirDeleteAcirComposer(acirComposerPtr: Ptr): Promise<void> {
|
|
180
|
+
const result = await this.binder.callWasmExport('acir_delete_acir_composer', [acirComposerPtr], []);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async acirCreateCircuit(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, sizeHint: number): Promise<void> {
|
|
185
|
+
const result = await this.binder.callWasmExport('acir_create_circuit', [acirComposerPtr, constraintSystemBuf, sizeHint], []);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async acirInitProvingKey(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, sizeHint: number): Promise<void> {
|
|
190
|
+
const result = await this.binder.callWasmExport('acir_init_proving_key', [acirComposerPtr, constraintSystemBuf, sizeHint], []);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async acirCreateProof(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array, isRecursive: boolean): Promise<Uint8Array> {
|
|
195
|
+
const result = await this.binder.callWasmExport('acir_create_proof', [acirComposerPtr, constraintSystemBuf, witnessBuf, isRecursive], [BufferDeserializer()]);
|
|
196
|
+
return result[0];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async acirLoadVerificationKey(acirComposerPtr: Ptr, vkBuf: Uint8Array): Promise<void> {
|
|
200
|
+
const result = await this.binder.callWasmExport('acir_load_verification_key', [acirComposerPtr, vkBuf], []);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async acirInitVerificationKey(acirComposerPtr: Ptr): Promise<void> {
|
|
205
|
+
const result = await this.binder.callWasmExport('acir_init_verification_key', [acirComposerPtr], []);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async acirGetVerificationKey(acirComposerPtr: Ptr): Promise<Uint8Array> {
|
|
210
|
+
const result = await this.binder.callWasmExport('acir_get_verification_key', [acirComposerPtr], [BufferDeserializer()]);
|
|
211
|
+
return result[0];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async acirVerifyProof(acirComposerPtr: Ptr, proofBuf: Uint8Array, isRecursive: boolean): Promise<boolean> {
|
|
215
|
+
const result = await this.binder.callWasmExport('acir_verify_proof', [acirComposerPtr, proofBuf, isRecursive], [BoolDeserializer()]);
|
|
216
|
+
return result[0];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async acirGetSolidityVerifier(acirComposerPtr: Ptr): Promise<string> {
|
|
220
|
+
const result = await this.binder.callWasmExport('acir_get_solidity_verifier', [acirComposerPtr], [StringDeserializer()]);
|
|
221
|
+
return result[0];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async acirSerializeProofIntoFields(acirComposerPtr: Ptr, proofBuf: Uint8Array, numInnerPublicInputs: number): Promise<Fr[]> {
|
|
225
|
+
const result = await this.binder.callWasmExport('acir_serialize_proof_into_fields', [acirComposerPtr, proofBuf, numInnerPublicInputs], [VectorDeserializer(Fr)]);
|
|
226
|
+
return result[0];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async acirSerializeVerificationKeyIntoFields(acirComposerPtr: Ptr): Promise<[Fr[], Fr]> {
|
|
230
|
+
const result = await this.binder.callWasmExport('acir_serialize_verification_key_into_fields', [acirComposerPtr], [VectorDeserializer(Fr), Fr]);
|
|
231
|
+
return result as any;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export class BarretenbergApiSync {
|
|
236
|
+
constructor(public binder: BarretenbergBinderSync) {}
|
|
237
|
+
|
|
238
|
+
async destroy() {
|
|
239
|
+
await this.binder.wasm.destroy();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
pedersenInit(): void {
|
|
243
|
+
const result = this.binder.callWasmExport('pedersen_init', [], []);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
pedersenCompressFields(left: Fr, right: Fr): Fr {
|
|
248
|
+
const result = this.binder.callWasmExport('pedersen_compress_fields', [left, right], [Fr]);
|
|
249
|
+
return result[0];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
pedersenPlookupCompressFields(left: Fr, right: Fr): Fr {
|
|
253
|
+
const result = this.binder.callWasmExport('pedersen_plookup_compress_fields', [left, right], [Fr]);
|
|
254
|
+
return result[0];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
pedersenCompress(inputsBuffer: Fr[]): Fr {
|
|
258
|
+
const result = this.binder.callWasmExport('pedersen_compress', [inputsBuffer], [Fr]);
|
|
259
|
+
return result[0];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
pedersenPlookupCompress(inputsBuffer: Fr[]): Fr {
|
|
263
|
+
const result = this.binder.callWasmExport('pedersen_plookup_compress', [inputsBuffer], [Fr]);
|
|
264
|
+
return result[0];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
pedersenCompressWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Fr {
|
|
268
|
+
const result = this.binder.callWasmExport('pedersen_compress_with_hash_index', [inputsBuffer, hashIndex], [Fr]);
|
|
269
|
+
return result[0];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
pedersenCommit(inputsBuffer: Fr[]): Fr {
|
|
273
|
+
const result = this.binder.callWasmExport('pedersen_commit', [inputsBuffer], [Fr]);
|
|
274
|
+
return result[0];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
pedersenPlookupCommit(inputsBuffer: Fr[]): Fr {
|
|
278
|
+
const result = this.binder.callWasmExport('pedersen_plookup_commit', [inputsBuffer], [Fr]);
|
|
279
|
+
return result[0];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
pedersenBufferToField(data: Uint8Array): Fr {
|
|
283
|
+
const result = this.binder.callWasmExport('pedersen_buffer_to_field', [data], [Fr]);
|
|
284
|
+
return result[0];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
pedersenHashInit(): void {
|
|
288
|
+
const result = this.binder.callWasmExport('pedersen_hash_init', [], []);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
pedersenHashPair(left: Fr, right: Fr): Fr {
|
|
293
|
+
const result = this.binder.callWasmExport('pedersen_hash_pair', [left, right], [Fr]);
|
|
294
|
+
return result[0];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
pedersenHashMultiple(inputsBuffer: Fr[]): Fr {
|
|
298
|
+
const result = this.binder.callWasmExport('pedersen_hash_multiple', [inputsBuffer], [Fr]);
|
|
299
|
+
return result[0];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
pedersenHashMultipleWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Fr {
|
|
303
|
+
const result = this.binder.callWasmExport('pedersen_hash_multiple_with_hash_index', [inputsBuffer, hashIndex], [Fr]);
|
|
304
|
+
return result[0];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
pedersenHashToTree(data: Fr[]): Fr[] {
|
|
308
|
+
const result = this.binder.callWasmExport('pedersen_hash_to_tree', [data], [VectorDeserializer(Fr)]);
|
|
309
|
+
return result[0];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
blake2s(data: Uint8Array): Buffer32 {
|
|
313
|
+
const result = this.binder.callWasmExport('blake2s', [data], [Buffer32]);
|
|
314
|
+
return result[0];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
blake2sToField(data: Uint8Array): Fr {
|
|
318
|
+
const result = this.binder.callWasmExport('blake2s_to_field_', [data], [Fr]);
|
|
319
|
+
return result[0];
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
schnorrComputePublicKey(privateKey: Fr): Point {
|
|
323
|
+
const result = this.binder.callWasmExport('schnorr_compute_public_key', [privateKey], [Point]);
|
|
324
|
+
return result[0];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
schnorrNegatePublicKey(publicKeyBuffer: Point): Point {
|
|
328
|
+
const result = this.binder.callWasmExport('schnorr_negate_public_key', [publicKeyBuffer], [Point]);
|
|
329
|
+
return result[0];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
schnorrConstructSignature(message: Uint8Array, privateKey: Fr): [Buffer32, Buffer32] {
|
|
333
|
+
const result = this.binder.callWasmExport('schnorr_construct_signature', [message, privateKey], [Buffer32, Buffer32]);
|
|
334
|
+
return result as any;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
schnorrVerifySignature(message: Uint8Array, pubKey: Point, sigS: Buffer32, sigE: Buffer32): boolean {
|
|
338
|
+
const result = this.binder.callWasmExport('schnorr_verify_signature', [message, pubKey, sigS, sigE], [BoolDeserializer()]);
|
|
339
|
+
return result[0];
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
schnorrMultisigCreateMultisigPublicKey(privateKey: Fq): Buffer128 {
|
|
343
|
+
const result = this.binder.callWasmExport('schnorr_multisig_create_multisig_public_key', [privateKey], [Buffer128]);
|
|
344
|
+
return result[0];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
schnorrMultisigValidateAndCombineSignerPubkeys(signerPubkeyBuf: Buffer128[]): [Point, boolean] {
|
|
348
|
+
const result = this.binder.callWasmExport('schnorr_multisig_validate_and_combine_signer_pubkeys', [signerPubkeyBuf], [Point, BoolDeserializer()]);
|
|
349
|
+
return result as any;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
schnorrMultisigConstructSignatureRound1(): [Buffer128, Buffer128] {
|
|
353
|
+
const result = this.binder.callWasmExport('schnorr_multisig_construct_signature_round_1', [], [Buffer128, Buffer128]);
|
|
354
|
+
return result as any;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
schnorrMultisigConstructSignatureRound2(message: Uint8Array, privateKey: Fq, signerRoundOnePrivateBuf: Buffer128, signerPubkeysBuf: Buffer128[], roundOnePublicBuf: Buffer128[]): [Fq, boolean] {
|
|
358
|
+
const result = this.binder.callWasmExport('schnorr_multisig_construct_signature_round_2', [message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf], [Fq, BoolDeserializer()]);
|
|
359
|
+
return result as any;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
schnorrMultisigCombineSignatures(message: Uint8Array, signerPubkeysBuf: Buffer128[], roundOneBuf: Buffer128[], roundTwoBuf: Fr[]): [Buffer32, Buffer32, boolean] {
|
|
363
|
+
const result = this.binder.callWasmExport('schnorr_multisig_combine_signatures', [message, signerPubkeysBuf, roundOneBuf, roundTwoBuf], [Buffer32, Buffer32, BoolDeserializer()]);
|
|
364
|
+
return result as any;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
srsInitSrs(pointsBuf: Uint8Array, numPoints: number, g2PointBuf: Uint8Array): void {
|
|
368
|
+
const result = this.binder.callWasmExport('srs_init_srs', [pointsBuf, numPoints, g2PointBuf], []);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
examplesSimpleCreateAndVerifyProof(): boolean {
|
|
373
|
+
const result = this.binder.callWasmExport('examples_simple_create_and_verify_proof', [], [BoolDeserializer()]);
|
|
374
|
+
return result[0];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
testThreads(threads: number, iterations: number): number {
|
|
378
|
+
const result = this.binder.callWasmExport('test_threads', [threads, iterations], [NumberDeserializer()]);
|
|
379
|
+
return result[0];
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
testThreadAbort(): void {
|
|
383
|
+
const result = this.binder.callWasmExport('test_thread_abort', [], []);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
testAbort(): void {
|
|
388
|
+
const result = this.binder.callWasmExport('test_abort', [], []);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
commonInitSlabAllocator(circuitSize: number): void {
|
|
393
|
+
const result = this.binder.callWasmExport('common_init_slab_allocator', [circuitSize], []);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
acirGetCircuitSizes(constraintSystemBuf: Uint8Array): [number, number, number] {
|
|
398
|
+
const result = this.binder.callWasmExport('acir_get_circuit_sizes', [constraintSystemBuf], [NumberDeserializer(), NumberDeserializer(), NumberDeserializer()]);
|
|
399
|
+
return result as any;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
acirNewAcirComposer(): Ptr {
|
|
403
|
+
const result = this.binder.callWasmExport('acir_new_acir_composer', [], [Ptr]);
|
|
404
|
+
return result[0];
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
acirDeleteAcirComposer(acirComposerPtr: Ptr): void {
|
|
408
|
+
const result = this.binder.callWasmExport('acir_delete_acir_composer', [acirComposerPtr], []);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
acirCreateCircuit(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, sizeHint: number): void {
|
|
413
|
+
const result = this.binder.callWasmExport('acir_create_circuit', [acirComposerPtr, constraintSystemBuf, sizeHint], []);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
acirInitProvingKey(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, sizeHint: number): void {
|
|
418
|
+
const result = this.binder.callWasmExport('acir_init_proving_key', [acirComposerPtr, constraintSystemBuf, sizeHint], []);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
acirCreateProof(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array, isRecursive: boolean): Uint8Array {
|
|
423
|
+
const result = this.binder.callWasmExport('acir_create_proof', [acirComposerPtr, constraintSystemBuf, witnessBuf, isRecursive], [BufferDeserializer()]);
|
|
424
|
+
return result[0];
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
acirLoadVerificationKey(acirComposerPtr: Ptr, vkBuf: Uint8Array): void {
|
|
428
|
+
const result = this.binder.callWasmExport('acir_load_verification_key', [acirComposerPtr, vkBuf], []);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
acirInitVerificationKey(acirComposerPtr: Ptr): void {
|
|
433
|
+
const result = this.binder.callWasmExport('acir_init_verification_key', [acirComposerPtr], []);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
acirGetVerificationKey(acirComposerPtr: Ptr): Uint8Array {
|
|
438
|
+
const result = this.binder.callWasmExport('acir_get_verification_key', [acirComposerPtr], [BufferDeserializer()]);
|
|
439
|
+
return result[0];
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
acirVerifyProof(acirComposerPtr: Ptr, proofBuf: Uint8Array, isRecursive: boolean): boolean {
|
|
443
|
+
const result = this.binder.callWasmExport('acir_verify_proof', [acirComposerPtr, proofBuf, isRecursive], [BoolDeserializer()]);
|
|
444
|
+
return result[0];
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
acirGetSolidityVerifier(acirComposerPtr: Ptr): string {
|
|
448
|
+
const result = this.binder.callWasmExport('acir_get_solidity_verifier', [acirComposerPtr], [StringDeserializer()]);
|
|
449
|
+
return result[0];
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
acirSerializeProofIntoFields(acirComposerPtr: Ptr, proofBuf: Uint8Array, numInnerPublicInputs: number): Fr[] {
|
|
453
|
+
const result = this.binder.callWasmExport('acir_serialize_proof_into_fields', [acirComposerPtr, proofBuf, numInnerPublicInputs], [VectorDeserializer(Fr)]);
|
|
454
|
+
return result[0];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
acirSerializeVerificationKeyIntoFields(acirComposerPtr: Ptr): [Fr[], Fr] {
|
|
458
|
+
const result = this.binder.callWasmExport('acir_serialize_verification_key_into_fields', [acirComposerPtr], [VectorDeserializer(Fr), Fr]);
|
|
459
|
+
return result as any;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { newBarretenbergApiSync } from '../factory/index.js';
|
|
2
|
+
import { Fr } from '../types/index.js';
|
|
3
|
+
import { BarretenbergApiSync } from './index.js';
|
|
4
|
+
|
|
5
|
+
describe('pedersen', () => {
|
|
6
|
+
let api: BarretenbergApiSync;
|
|
7
|
+
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
api = await newBarretenbergApiSync();
|
|
10
|
+
api.pedersenHashInit();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
afterAll(async () => {
|
|
14
|
+
await api.destroy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('pedersenCompressFields', () => {
|
|
18
|
+
const result = api.pedersenCompressFields(new Fr(4n), new Fr(8n));
|
|
19
|
+
expect(result).toEqual(new Fr(16672613430297770667465722499387909817686322516130512258122141976728892914370n));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('pedersenPlookupCompressFields', () => {
|
|
23
|
+
const result = api.pedersenPlookupCompressFields(new Fr(4n), new Fr(8n));
|
|
24
|
+
expect(result).toEqual(new Fr(21568810706345846819294487214368613840251909831689369685420108292337497444070n));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('pedersenCompress', () => {
|
|
28
|
+
const result = api.pedersenCompress([new Fr(4n), new Fr(8n), new Fr(12n)]);
|
|
29
|
+
expect(result).toEqual(new Fr(20749503715308760529311051818180468653739005441229560405092292242074298877245n));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('pedersenPlookupCompress', () => {
|
|
33
|
+
const result = api.pedersenPlookupCompress([new Fr(4n), new Fr(8n), new Fr(12n)]);
|
|
34
|
+
expect(result).toEqual(new Fr(4213911891650716450883144878301329379460622830501147795631256054071351353887n));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('pedersenCompressWithHashIndex', () => {
|
|
38
|
+
const result = api.pedersenCompressWithHashIndex([new Fr(4n), new Fr(8n)], 7);
|
|
39
|
+
expect(result).toEqual(new Fr(12675961871866002745031098923411501942277744385859978302365013982702509949754n));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('pedersenCommit', () => {
|
|
43
|
+
const result = api.pedersenCommit([new Fr(4n), new Fr(8n), new Fr(12n)]);
|
|
44
|
+
expect(result).toEqual(new Fr(20749503715308760529311051818180468653739005441229560405092292242074298877245n));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('pedersenPlookupCommit', () => {
|
|
48
|
+
const result = api.pedersenPlookupCommit([new Fr(4n), new Fr(8n)]);
|
|
49
|
+
expect(result).toEqual(new Fr(21568810706345846819294487214368613840251909831689369685420108292337497444070n));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('pedersenBufferToField', () => {
|
|
53
|
+
const result = api.pedersenBufferToField(Buffer.from('Hello world! I am a buffer to be converted to a field!'));
|
|
54
|
+
expect(result).toEqual(new Fr(4923399520610513632896240312051201308554838580477778325691012985962614653619n));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('pedersenHashPair', () => {
|
|
58
|
+
const result = api.pedersenHashPair(new Fr(4n), new Fr(8n));
|
|
59
|
+
expect(result).toEqual(new Fr(7508407170365331152493586290597472346478280823936748458450026785528968221772n));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('pedersenHashMultiple', () => {
|
|
63
|
+
const result = api.pedersenHashMultiple([new Fr(4n), new Fr(8n), new Fr(12n)]);
|
|
64
|
+
expect(result).toEqual(new Fr(641613987782189905475142047603559162464012327378197326488471789040703504911n));
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('pedersenHashMultipleWithHashIndex', () => {
|
|
68
|
+
const result = api.pedersenHashMultipleWithHashIndex([new Fr(4n), new Fr(8n)], 7);
|
|
69
|
+
expect(result).toEqual(new Fr(14181105996307540196932058280391669339364159586581375348016341320932872505408n));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('pedersenHashToTree', () => {
|
|
73
|
+
const result = api.pedersenHashToTree([new Fr(4n), new Fr(8n), new Fr(12n), new Fr(16n)]);
|
|
74
|
+
expect(result).toEqual([
|
|
75
|
+
new Fr(4n),
|
|
76
|
+
new Fr(8n),
|
|
77
|
+
new Fr(12n),
|
|
78
|
+
new Fr(16n),
|
|
79
|
+
new Fr(7508407170365331152493586290597472346478280823936748458450026785528968221772n),
|
|
80
|
+
new Fr(61370238324203854110612958249832030753990119715269709182131929073387209477n),
|
|
81
|
+
new Fr(7696240979753031171651958947943309270095593128155855154123615677953596407768n),
|
|
82
|
+
]);
|
|
83
|
+
});
|
|
84
|
+
});
|