@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,132 +1,162 @@
|
|
|
1
|
-
import { serializeToBuffer } from '@aztec/foundation/serialize';
|
|
2
|
-
import { SiblingPath } from '@aztec/foundation/trees';
|
|
3
1
|
import { sha256Trunc } from '../crypto/index.js';
|
|
4
|
-
|
|
2
|
+
import { SiblingPath } from './sibling_path.js';
|
|
3
|
+
import { UnbalancedTreeStore } from './unbalanced_tree_store.js';
|
|
4
|
+
export function computeCompressedUnbalancedMerkleTreeRoot(leaves, valueToCompress = Buffer.alloc(32), hasher) {
|
|
5
|
+
const calculator = UnbalancedMerkleTreeCalculator.create(leaves, valueToCompress, hasher);
|
|
6
|
+
return calculator.getRoot();
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
9
|
* An ephemeral unbalanced Merkle tree implementation.
|
|
7
10
|
* Follows the rollup implementation which greedily hashes pairs of nodes up the tree.
|
|
8
11
|
* Remaining rightmost nodes are shifted up until they can be paired.
|
|
12
|
+
* The values that match the `valueToCompress` are skipped and the sibling of the compressed leaf are shifted up until
|
|
13
|
+
* they can be paired.
|
|
9
14
|
* If there is only one leaf, the root is the leaf.
|
|
10
15
|
*/ export class UnbalancedMerkleTreeCalculator {
|
|
11
|
-
|
|
16
|
+
leaves;
|
|
17
|
+
valueToCompress;
|
|
12
18
|
hasher;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
root;
|
|
19
|
-
constructor(maxDepth, hasher){
|
|
20
|
-
this.maxDepth = maxDepth;
|
|
19
|
+
store;
|
|
20
|
+
leafLocations;
|
|
21
|
+
constructor(leaves, valueToCompress, hasher){
|
|
22
|
+
this.leaves = leaves;
|
|
23
|
+
this.valueToCompress = valueToCompress;
|
|
21
24
|
this.hasher = hasher;
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
this.leafLocations = [];
|
|
26
|
+
if (leaves.length === 0) {
|
|
27
|
+
throw Error('Cannot create a compressed unbalanced tree with 0 leaves.');
|
|
28
|
+
}
|
|
29
|
+
this.store = new UnbalancedTreeStore(leaves.length);
|
|
30
|
+
this.buildTree();
|
|
26
31
|
}
|
|
27
|
-
static create(
|
|
32
|
+
static create(leaves, valueToCompress = Buffer.alloc(0), hasher = (left, right)=>sha256Trunc(Buffer.concat([
|
|
28
33
|
left,
|
|
29
34
|
right
|
|
30
|
-
])))
|
|
31
|
-
return new UnbalancedMerkleTreeCalculator(
|
|
35
|
+
]))) {
|
|
36
|
+
return new UnbalancedMerkleTreeCalculator(leaves, valueToCompress, hasher);
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Returns the root of the tree.
|
|
35
40
|
* @returns The root of the tree.
|
|
36
41
|
*/ getRoot() {
|
|
37
|
-
return this.
|
|
42
|
+
return this.store.getRoot().value;
|
|
38
43
|
}
|
|
39
44
|
/**
|
|
40
|
-
* Returns a sibling path for the element
|
|
45
|
+
* Returns a sibling path for the element.
|
|
41
46
|
* @param value - The value of the element.
|
|
42
47
|
* @returns A sibling path for the element.
|
|
43
48
|
* Note: The sibling path is an array of sibling hashes, with the lowest hash (leaf hash) first, and the highest hash last.
|
|
44
49
|
*/ getSiblingPath(value) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const path = [];
|
|
49
|
-
const [depth, _index] = this.valueCache[serializeToBuffer(value).toString('hex')].split(':');
|
|
50
|
-
let level = parseInt(depth, 10);
|
|
51
|
-
let index = BigInt(_index);
|
|
52
|
-
while(level > 0){
|
|
53
|
-
const isRight = index & 0x01n;
|
|
54
|
-
const key = indexToKeyHash(level, isRight ? index - 1n : index + 1n);
|
|
55
|
-
const sibling = this.cache[key];
|
|
56
|
-
path.push(sibling);
|
|
57
|
-
level -= 1;
|
|
58
|
-
index >>= 1n;
|
|
50
|
+
const leafIndex = this.leaves.findIndex((leaf)=>leaf.equals(value));
|
|
51
|
+
if (leafIndex === -1) {
|
|
52
|
+
throw Error(`Leaf value ${value.toString('hex')} not found in tree.`);
|
|
59
53
|
}
|
|
60
|
-
return
|
|
54
|
+
return this.getSiblingPathByLeafIndex(leafIndex);
|
|
61
55
|
}
|
|
62
56
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @param
|
|
65
|
-
* @returns
|
|
66
|
-
*/
|
|
67
|
-
if (this.
|
|
68
|
-
throw Error(`
|
|
57
|
+
* Returns a sibling path for the leaf at the given index.
|
|
58
|
+
* @param leafIndex - The index of the leaf.
|
|
59
|
+
* @returns A sibling path for the leaf.
|
|
60
|
+
*/ getSiblingPathByLeafIndex(leafIndex) {
|
|
61
|
+
if (leafIndex >= this.leaves.length) {
|
|
62
|
+
throw Error(`Leaf index ${leafIndex} out of bounds. Tree has ${this.leaves.length} leaves.`);
|
|
69
63
|
}
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
const leaf = this.leaves[leafIndex];
|
|
65
|
+
if (leaf.equals(this.valueToCompress)) {
|
|
66
|
+
throw Error(`Leaf at index ${leafIndex} has been compressed.`);
|
|
72
67
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
const path = [];
|
|
69
|
+
let location = this.leafLocations[leafIndex];
|
|
70
|
+
while(location.level > 0){
|
|
71
|
+
const sibling = this.store.getSibling(location);
|
|
72
|
+
path.push(sibling.value);
|
|
73
|
+
location = this.store.getParentLocation(location);
|
|
77
74
|
}
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
return new SiblingPath(path.length, path);
|
|
76
|
+
}
|
|
77
|
+
getLeafLocation(leafIndex) {
|
|
78
|
+
return this.leafLocations[leafIndex];
|
|
80
79
|
}
|
|
81
80
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @param leaves - The leaves
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
81
|
+
* Adds leaves and nodes to the store. Updates the leafLocations.
|
|
82
|
+
* @param leaves - The leaves of the tree.
|
|
83
|
+
*/ buildTree() {
|
|
84
|
+
this.leafLocations = this.leaves.map((value, i)=>this.store.setLeaf(i, {
|
|
85
|
+
value,
|
|
86
|
+
leafIndex: i
|
|
87
|
+
}));
|
|
88
|
+
// Start with the leaves that are not compressed.
|
|
89
|
+
let toProcess = this.leafLocations.filter((_, i)=>!this.leaves[i].equals(this.valueToCompress));
|
|
90
|
+
if (!toProcess.length) {
|
|
91
|
+
// All leaves are compressed. Set 0 to the root.
|
|
92
|
+
this.store.setNode({
|
|
93
|
+
level: 0,
|
|
94
|
+
index: 0
|
|
95
|
+
}, {
|
|
96
|
+
value: Buffer.alloc(32)
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const level = toProcess[0].level;
|
|
101
|
+
for(let i = level; i > 0; i--){
|
|
102
|
+
const toProcessNext = [];
|
|
103
|
+
for (const location of toProcess){
|
|
104
|
+
if (location.level !== i) {
|
|
105
|
+
toProcessNext.push(location);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const parentLocation = this.store.getParentLocation(location);
|
|
109
|
+
if (this.store.getNode(parentLocation)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const sibling = this.store.getSibling(location);
|
|
113
|
+
// If sibling is undefined, all its children are compressed.
|
|
114
|
+
const shouldShiftUp = !sibling || sibling.value.equals(this.valueToCompress);
|
|
115
|
+
if (shouldShiftUp) {
|
|
116
|
+
// The node becomes the parent if the sibling is a compressed leaf.
|
|
117
|
+
const isLeaf = this.shiftNodeUp(location, parentLocation);
|
|
118
|
+
if (!isLeaf) {
|
|
119
|
+
this.shiftChildrenUp(location);
|
|
120
|
+
}
|
|
114
121
|
} else {
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
// Hash the value with the (right) sibling and update the parent node.
|
|
123
|
+
const node = this.store.getNode(location);
|
|
124
|
+
const parentValue = this.hasher(node.value, sibling.value);
|
|
125
|
+
this.store.setNode(parentLocation, {
|
|
126
|
+
value: parentValue
|
|
127
|
+
});
|
|
118
128
|
}
|
|
129
|
+
// Add the parent location to be processed next.
|
|
130
|
+
toProcessNext.push(parentLocation);
|
|
119
131
|
}
|
|
120
|
-
|
|
121
|
-
thisLayer = nextLayer;
|
|
122
|
-
nextLayer = [];
|
|
132
|
+
toProcess = toProcessNext;
|
|
123
133
|
}
|
|
124
|
-
// return the root
|
|
125
|
-
return thisLayer[0];
|
|
126
134
|
}
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
this.
|
|
130
|
-
|
|
135
|
+
shiftNodeUp(fromLocation, toLocation) {
|
|
136
|
+
const node = this.store.getNode(fromLocation);
|
|
137
|
+
this.store.setNode(toLocation, node);
|
|
138
|
+
const isLeaf = node.leafIndex !== undefined;
|
|
139
|
+
if (isLeaf) {
|
|
140
|
+
// Update the location if the node is a leaf.
|
|
141
|
+
this.leafLocations[node.leafIndex] = toLocation;
|
|
142
|
+
}
|
|
143
|
+
return isLeaf;
|
|
144
|
+
}
|
|
145
|
+
shiftChildrenUp(parent) {
|
|
146
|
+
const [left, right] = this.store.getChildLocations(parent);
|
|
147
|
+
const level = parent.level;
|
|
148
|
+
const groupSize = 2 ** level;
|
|
149
|
+
const computeNewLocation = (index)=>({
|
|
150
|
+
level,
|
|
151
|
+
index: Math.floor(index / (groupSize * 2)) * groupSize + index % groupSize
|
|
152
|
+
});
|
|
153
|
+
const isLeftLeaf = this.shiftNodeUp(left, computeNewLocation(left.index));
|
|
154
|
+
const isRightLeaf = this.shiftNodeUp(right, computeNewLocation(right.index));
|
|
155
|
+
if (!isLeftLeaf) {
|
|
156
|
+
this.shiftChildrenUp(left);
|
|
157
|
+
}
|
|
158
|
+
if (!isRightLeaf) {
|
|
159
|
+
this.shiftChildrenUp(right);
|
|
160
|
+
}
|
|
131
161
|
}
|
|
132
162
|
}
|
|
@@ -12,6 +12,7 @@ export declare class UnbalancedTreeStore<T> {
|
|
|
12
12
|
getChildLocations({ level, index }: TreeNodeLocation): [TreeNodeLocation, TreeNodeLocation];
|
|
13
13
|
getLeaf(leafIndex: number): T | undefined;
|
|
14
14
|
getNode(location: TreeNodeLocation): T | undefined;
|
|
15
|
+
getRoot(): T | undefined;
|
|
15
16
|
getParent(location: TreeNodeLocation): T | undefined;
|
|
16
17
|
getSibling(location: TreeNodeLocation): T | undefined;
|
|
17
18
|
getChildren(location: TreeNodeLocation): [T | undefined, T | undefined];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unbalanced_tree_store.d.ts","sourceRoot":"","sources":["../../src/trees/unbalanced_tree_store.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAOD,qBAAa,mBAAmB,CAAC,CAAC;;gBAIpB,SAAS,EAAE,MAAM;IAI7B,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,gBAAgB;IAiBtD,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;IAWpD,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,gBAAgB;IAQvE,kBAAkB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,gBAAgB;IAQxE,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAM3F,OAAO,CAAC,SAAS,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"unbalanced_tree_store.d.ts","sourceRoot":"","sources":["../../src/trees/unbalanced_tree_store.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAOD,qBAAa,mBAAmB,CAAC,CAAC;;gBAIpB,SAAS,EAAE,MAAM;IAI7B,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,gBAAgB;IAiBtD,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;IAWpD,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,gBAAgB;IAQvE,kBAAkB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,gBAAgB;IAQxE,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAM3F,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IASzC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,SAAS;IAIlD,OAAO,IAAI,CAAC,GAAG,SAAS;IAIxB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,SAAS;IAKpD,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,SAAS;IAKrD,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC;CAQxE"}
|
|
@@ -73,6 +73,12 @@ export class UnbalancedTreeStore {
|
|
|
73
73
|
getNode(location) {
|
|
74
74
|
return this.#nodeMapping.get(this.#getKey(location))?.value;
|
|
75
75
|
}
|
|
76
|
+
getRoot() {
|
|
77
|
+
return this.getNode({
|
|
78
|
+
level: 0,
|
|
79
|
+
index: 0
|
|
80
|
+
});
|
|
81
|
+
}
|
|
76
82
|
getParent(location) {
|
|
77
83
|
const parentLocation = this.getParentLocation(location);
|
|
78
84
|
return this.getNode(parentLocation);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/foundation",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-devnet.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dest/index.js",
|
|
6
6
|
"types": "./dest/index.d.ts",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"./noir": "./dest/noir/index.js",
|
|
48
48
|
"./testing": "./dest/testing/index.js",
|
|
49
49
|
"./testing/files": "./dest/testing/files/index.js",
|
|
50
|
+
"./profiler": "./dest/profiler/index.js",
|
|
50
51
|
"./array": "./dest/array/index.js",
|
|
51
52
|
"./validation": "./dest/validation/index.js",
|
|
52
53
|
"./promise": "./dest/promise/index.js",
|
|
@@ -102,7 +103,7 @@
|
|
|
102
103
|
"testEnvironment": "../../foundation/src/jest/env.mjs"
|
|
103
104
|
},
|
|
104
105
|
"dependencies": {
|
|
105
|
-
"@aztec/bb.js": "3.0.0-
|
|
106
|
+
"@aztec/bb.js": "3.0.0-devnet.3",
|
|
106
107
|
"@koa/cors": "^5.0.0",
|
|
107
108
|
"@noble/curves": "=1.7.0",
|
|
108
109
|
"bn.js": "^5.2.1",
|
|
@@ -112,7 +113,7 @@
|
|
|
112
113
|
"koa": "^2.16.1",
|
|
113
114
|
"koa-bodyparser": "^4.4.0",
|
|
114
115
|
"koa-compress": "^5.1.0",
|
|
115
|
-
"koa-router": "^
|
|
116
|
+
"koa-router": "^13.1.1",
|
|
116
117
|
"leveldown": "^6.1.1",
|
|
117
118
|
"lodash.chunk": "^4.2.0",
|
|
118
119
|
"lodash.clonedeepwith": "^4.5.0",
|
|
@@ -153,7 +154,7 @@
|
|
|
153
154
|
"ts-node": "^10.9.1",
|
|
154
155
|
"typescript": "^5.3.3",
|
|
155
156
|
"typescript-eslint": "^8.32.1",
|
|
156
|
-
"viem": "2.
|
|
157
|
+
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
|
|
157
158
|
},
|
|
158
159
|
"files": [
|
|
159
160
|
"dest",
|
package/src/collection/object.ts
CHANGED
|
@@ -79,3 +79,11 @@ export function assertRequired<T extends object>(obj: T): Required<T> {
|
|
|
79
79
|
}
|
|
80
80
|
return obj as Required<T>;
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/** Returns the result of merging two objects ignoring properties with undefined values. */
|
|
84
|
+
export function merge<T extends object, U extends object>(
|
|
85
|
+
obj1: T,
|
|
86
|
+
obj2: U | undefined,
|
|
87
|
+
): T & { [P in keyof U]+?: Exclude<U[P], undefined> } {
|
|
88
|
+
return { ...obj1, ...compact(obj2 ?? {}) };
|
|
89
|
+
}
|
package/src/config/env_var.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type EnvVar =
|
|
2
|
+
| 'REGISTRY_CONTRACT_ADDRESS'
|
|
3
|
+
| 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS'
|
|
4
|
+
| 'SLASH_FACTORY_CONTRACT_ADDRESS'
|
|
2
5
|
| 'ACVM_BINARY_PATH'
|
|
3
6
|
| 'ACVM_WORKING_DIRECTORY'
|
|
4
|
-
| 'GOVERNANCE_CONTRACT_ADDRESS'
|
|
5
7
|
| 'API_KEY'
|
|
6
8
|
| 'API_PREFIX'
|
|
7
9
|
| 'ARCHIVER_MAX_LOGS'
|
|
@@ -9,7 +11,6 @@ export type EnvVar =
|
|
|
9
11
|
| 'ARCHIVER_URL'
|
|
10
12
|
| 'ARCHIVER_VIEM_POLLING_INTERVAL_MS'
|
|
11
13
|
| 'ARCHIVER_BATCH_SIZE'
|
|
12
|
-
| 'ASSUME_PROVEN_THROUGH_BLOCK_NUMBER'
|
|
13
14
|
| 'AZTEC_ADMIN_PORT'
|
|
14
15
|
| 'AZTEC_NODE_ADMIN_URL'
|
|
15
16
|
| 'AZTEC_NODE_URL'
|
|
@@ -25,6 +26,7 @@ export type EnvVar =
|
|
|
25
26
|
| 'BLOB_SINK_URL'
|
|
26
27
|
| 'BOT_DA_GAS_LIMIT'
|
|
27
28
|
| 'BOT_FEE_PAYMENT_METHOD'
|
|
29
|
+
| 'BOT_BASE_FEE_PADDING'
|
|
28
30
|
| 'BOT_FLUSH_SETUP_TRANSACTIONS'
|
|
29
31
|
| 'BOT_FOLLOW_CHAIN'
|
|
30
32
|
| 'BOT_L2_GAS_LIMIT'
|
|
@@ -37,7 +39,6 @@ export type EnvVar =
|
|
|
37
39
|
| 'BOT_ACCOUNT_SALT'
|
|
38
40
|
| 'BOT_PRIVATE_TRANSFERS_PER_TX'
|
|
39
41
|
| 'BOT_PUBLIC_TRANSFERS_PER_TX'
|
|
40
|
-
| 'BOT_PXE_URL'
|
|
41
42
|
| 'BOT_RECIPIENT_ENCRYPTION_SECRET'
|
|
42
43
|
| 'BOT_TOKEN_CONTRACT'
|
|
43
44
|
| 'BOT_TOKEN_SALT'
|
|
@@ -64,13 +65,9 @@ export type EnvVar =
|
|
|
64
65
|
| 'DEBUG_P2P_DISABLE_COLOCATION_PENALTY'
|
|
65
66
|
| 'DEPLOY_AZTEC_CONTRACTS_SALT'
|
|
66
67
|
| 'ETHEREUM_HOSTS'
|
|
67
|
-
| 'FEE_JUICE_CONTRACT_ADDRESS'
|
|
68
|
-
| 'FEE_JUICE_PORTAL_CONTRACT_ADDRESS'
|
|
69
68
|
| 'FEE_RECIPIENT'
|
|
70
69
|
| 'FORCE_COLOR'
|
|
71
|
-
| 'GOVERNANCE_PROPOSER_CONTRACT_ADDRESS'
|
|
72
70
|
| 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS'
|
|
73
|
-
| 'INBOX_CONTRACT_ADDRESS'
|
|
74
71
|
| 'KEY_STORE_DIRECTORY'
|
|
75
72
|
| 'L1_CHAIN_ID'
|
|
76
73
|
| 'L1_CONSENSUS_HOST_URLS'
|
|
@@ -81,8 +78,8 @@ export type EnvVar =
|
|
|
81
78
|
| 'LOG_LEVEL'
|
|
82
79
|
| 'MNEMONIC'
|
|
83
80
|
| 'NETWORK'
|
|
81
|
+
| 'NETWORK_CONFIG_LOCATION'
|
|
84
82
|
| 'NO_PXE'
|
|
85
|
-
| 'COIN_ISSUER_CONTRACT_ADDRESS'
|
|
86
83
|
| 'USE_GCLOUD_LOGGING'
|
|
87
84
|
| 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
|
|
88
85
|
| 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'
|
|
@@ -94,7 +91,6 @@ export type EnvVar =
|
|
|
94
91
|
| 'PUBLIC_OTEL_INCLUDE_METRICS'
|
|
95
92
|
| 'PUBLIC_OTEL_COLLECT_FROM'
|
|
96
93
|
| 'PUBLIC_OTEL_OPT_OUT'
|
|
97
|
-
| 'OUTBOX_CONTRACT_ADDRESS'
|
|
98
94
|
| 'P2P_BLOCK_CHECK_INTERVAL_MS'
|
|
99
95
|
| 'P2P_BLOCK_REQUEST_BATCH_SIZE'
|
|
100
96
|
| 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK'
|
|
@@ -139,6 +135,7 @@ export type EnvVar =
|
|
|
139
135
|
| 'P2P_SEEN_MSG_CACHE_SIZE'
|
|
140
136
|
| 'P2P_DROP_TX'
|
|
141
137
|
| 'P2P_DROP_TX_CHANCE'
|
|
138
|
+
| 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG'
|
|
142
139
|
| 'PEER_ID_PRIVATE_KEY'
|
|
143
140
|
| 'PEER_ID_PRIVATE_KEY_PATH'
|
|
144
141
|
| 'PROVER_AGENT_COUNT'
|
|
@@ -154,6 +151,7 @@ export type EnvVar =
|
|
|
154
151
|
| 'PROVER_COORDINATION_NODE_URLS'
|
|
155
152
|
| 'PROVER_FAILED_PROOF_STORE'
|
|
156
153
|
| 'PROVER_NODE_FAILED_EPOCH_STORE'
|
|
154
|
+
| 'PROVER_NODE_DISABLE_PROOF_PUBLISH'
|
|
157
155
|
| 'PROVER_ID'
|
|
158
156
|
| 'PROVER_NODE_POLLING_INTERVAL_MS'
|
|
159
157
|
| 'PROVER_NODE_MAX_PENDING_JOBS'
|
|
@@ -162,40 +160,39 @@ export type EnvVar =
|
|
|
162
160
|
| 'PROVER_NODE_TX_GATHERING_BATCH_SIZE'
|
|
163
161
|
| 'PROVER_NODE_TX_GATHERING_MAX_PARALLEL_REQUESTS_PER_NODE'
|
|
164
162
|
| 'PROVER_NODE_TX_GATHERING_TIMEOUT_MS'
|
|
165
|
-
| 'PROVER_PUBLISH_RETRY_INTERVAL_MS'
|
|
166
163
|
| 'PROVER_PUBLISHER_PRIVATE_KEY'
|
|
167
164
|
| 'PROVER_PUBLISHER_PRIVATE_KEYS'
|
|
168
165
|
| 'PROVER_PUBLISHER_ADDRESSES'
|
|
166
|
+
| 'PROVER_PUBLISHER_ALLOW_INVALID_STATES'
|
|
169
167
|
| 'PROVER_REAL_PROOFS'
|
|
170
168
|
| 'PROVER_TEST_DELAY_FACTOR'
|
|
171
169
|
| 'PROVER_TEST_DELAY_MS'
|
|
172
170
|
| 'PROVER_TEST_DELAY_TYPE'
|
|
173
171
|
| 'PXE_L2_BLOCK_BATCH_SIZE'
|
|
174
172
|
| 'PXE_PROVER_ENABLED'
|
|
175
|
-
| 'REGISTRY_CONTRACT_ADDRESS'
|
|
176
|
-
| 'ROLLUP_CONTRACT_ADDRESS'
|
|
177
173
|
| 'RPC_MAX_BATCH_SIZE'
|
|
178
174
|
| 'RPC_MAX_BODY_SIZE'
|
|
179
175
|
| 'RPC_SIMULATE_PUBLIC_MAX_GAS_LIMIT'
|
|
176
|
+
| 'RPC_SIMULATE_PUBLIC_MAX_DEBUG_LOG_MEMORY_READS'
|
|
180
177
|
| 'SENTINEL_ENABLED'
|
|
181
178
|
| 'SENTINEL_HISTORY_LENGTH_IN_EPOCHS'
|
|
179
|
+
| 'SENTINEL_HISTORIC_PROVEN_PERFORMANCE_LENGTH_IN_EPOCHS'
|
|
182
180
|
| 'SEQ_MAX_BLOCK_SIZE_IN_BYTES'
|
|
183
181
|
| 'SEQ_MAX_TX_PER_BLOCK'
|
|
184
182
|
| 'SEQ_MIN_TX_PER_BLOCK'
|
|
185
183
|
| 'SEQ_PUBLISH_TXS_WITH_PROPOSALS'
|
|
186
184
|
| 'SEQ_MAX_DA_BLOCK_GAS'
|
|
187
185
|
| 'SEQ_MAX_L2_BLOCK_GAS'
|
|
188
|
-
| 'SEQ_PUBLISH_RETRY_INTERVAL_MS'
|
|
189
186
|
| 'SEQ_PUBLISHER_PRIVATE_KEY'
|
|
190
187
|
| 'SEQ_PUBLISHER_PRIVATE_KEYS'
|
|
191
188
|
| 'SEQ_PUBLISHER_ADDRESSES'
|
|
189
|
+
| 'SEQ_PUBLISHER_ALLOW_INVALID_STATES'
|
|
192
190
|
| 'SEQ_TX_POLLING_INTERVAL_MS'
|
|
193
191
|
| 'SEQ_ENFORCE_TIME_TABLE'
|
|
194
192
|
| 'SEQ_MAX_L1_TX_INCLUSION_TIME_INTO_SLOT'
|
|
195
193
|
| 'SEQ_ATTESTATION_PROPAGATION_TIME'
|
|
196
194
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER'
|
|
197
195
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER'
|
|
198
|
-
| 'SLASH_FACTORY_CONTRACT_ADDRESS'
|
|
199
196
|
| 'SLASH_MIN_PENALTY_PERCENTAGE'
|
|
200
197
|
| 'SLASH_MAX_PENALTY_PERCENTAGE'
|
|
201
198
|
| 'SLASH_VALIDATORS_ALWAYS'
|
|
@@ -213,11 +210,10 @@ export type EnvVar =
|
|
|
213
210
|
| 'SLASH_GRACE_PERIOD_L2_SLOTS'
|
|
214
211
|
| 'SLASH_OFFENSE_EXPIRATION_ROUNDS'
|
|
215
212
|
| 'SLASH_MAX_PAYLOAD_SIZE'
|
|
216
|
-
| '
|
|
217
|
-
| 'STAKING_ASSET_HANDLER_CONTRACT_ADDRESS'
|
|
213
|
+
| 'SLASH_EXECUTE_ROUNDS_LOOK_BACK'
|
|
218
214
|
| 'SYNC_MODE'
|
|
215
|
+
| 'SYNC_SNAPSHOTS_URLS'
|
|
219
216
|
| 'SYNC_SNAPSHOTS_URL'
|
|
220
|
-
| 'REWARD_DISTRIBUTOR_CONTRACT_ADDRESS'
|
|
221
217
|
| 'TELEMETRY'
|
|
222
218
|
| 'TEST_ACCOUNTS'
|
|
223
219
|
| 'SPONSORED_FPC'
|
|
@@ -251,9 +247,11 @@ export type EnvVar =
|
|
|
251
247
|
| 'AZTEC_SLOT_DURATION'
|
|
252
248
|
| 'AZTEC_EPOCH_DURATION'
|
|
253
249
|
| 'AZTEC_TARGET_COMMITTEE_SIZE'
|
|
250
|
+
| 'AZTEC_LAG_IN_EPOCHS'
|
|
254
251
|
| 'AZTEC_PROOF_SUBMISSION_EPOCHS'
|
|
255
252
|
| 'AZTEC_ACTIVATION_THRESHOLD'
|
|
256
253
|
| 'AZTEC_EJECTION_THRESHOLD'
|
|
254
|
+
| 'AZTEC_LOCAL_EJECTION_THRESHOLD'
|
|
257
255
|
| 'AZTEC_MANA_TARGET'
|
|
258
256
|
| 'AZTEC_PROVING_COST_PER_MANA'
|
|
259
257
|
| 'AZTEC_SLASHING_QUORUM'
|
|
@@ -262,6 +260,7 @@ export type EnvVar =
|
|
|
262
260
|
| 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS'
|
|
263
261
|
| 'AZTEC_SLASHING_VETOER'
|
|
264
262
|
| 'AZTEC_SLASHING_OFFSET_IN_ROUNDS'
|
|
263
|
+
| 'AZTEC_SLASHING_DISABLE_DURATION'
|
|
265
264
|
| 'AZTEC_SLASH_AMOUNT_SMALL'
|
|
266
265
|
| 'AZTEC_SLASH_AMOUNT_MEDIUM'
|
|
267
266
|
| 'AZTEC_SLASH_AMOUNT_LARGE'
|
|
@@ -279,8 +278,9 @@ export type EnvVar =
|
|
|
279
278
|
| 'L1_TX_MONITOR_CHECK_INTERVAL_MS'
|
|
280
279
|
| 'L1_TX_MONITOR_STALL_TIME_MS'
|
|
281
280
|
| 'L1_TX_MONITOR_TX_TIMEOUT_MS'
|
|
282
|
-
| 'L1_TX_PROPAGATION_MAX_QUERY_ATTEMPTS'
|
|
283
281
|
| 'L1_TX_MONITOR_CANCEL_TX_ON_TIMEOUT'
|
|
282
|
+
| 'L1_TX_MONITOR_TX_CANCELLATION_TIMEOUT_MS'
|
|
283
|
+
| 'L1_TX_MONITOR_TX_UNSEEN_CONSIDERED_DROPPED_MS'
|
|
284
284
|
| 'FAUCET_MNEMONIC_ADDRESS_INDEX'
|
|
285
285
|
| 'FAUCET_ETH_AMOUNT'
|
|
286
286
|
| 'FAUCET_INTERVAL_MS'
|
|
@@ -288,9 +288,8 @@ export type EnvVar =
|
|
|
288
288
|
| 'K8S_POD_NAME'
|
|
289
289
|
| 'K8S_POD_UID'
|
|
290
290
|
| 'K8S_NAMESPACE_NAME'
|
|
291
|
-
| 'CUSTOM_FORWARDER_CONTRACT_ADDRESS'
|
|
292
|
-
| 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS'
|
|
293
291
|
| 'VALIDATOR_REEXECUTE_DEADLINE_MS'
|
|
292
|
+
| 'ALWAYS_REEXECUTE_BLOCK_PROPOSALS'
|
|
294
293
|
| 'AUTO_UPDATE'
|
|
295
294
|
| 'AUTO_UPDATE_URL'
|
|
296
295
|
| 'WEB3_SIGNER_URL';
|
package/src/config/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { SecretValue } from './secret_value.js';
|
|
|
5
5
|
|
|
6
6
|
export { SecretValue, getActiveNetworkName };
|
|
7
7
|
export type { EnvVar, NetworkNames };
|
|
8
|
+
export type { NetworkConfig, NetworkConfigMap } from './network_config.js';
|
|
9
|
+
export { NetworkConfigMapSchema, NetworkConfigSchema } from './network_config.js';
|
|
8
10
|
|
|
9
11
|
export interface ConfigMapping {
|
|
10
12
|
env?: EnvVar;
|
|
@@ -259,7 +261,7 @@ export function secretFrConfigHelper(defaultValue?: Fr): Required<
|
|
|
259
261
|
return {
|
|
260
262
|
parseEnv: parse,
|
|
261
263
|
parseVal: parse,
|
|
262
|
-
defaultValue:
|
|
264
|
+
defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
|
|
263
265
|
isBoolean: true,
|
|
264
266
|
};
|
|
265
267
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const NetworkConfigSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
bootnodes: z.array(z.string()),
|
|
6
|
+
snapshots: z.array(z.string()),
|
|
7
|
+
registryAddress: z.string(),
|
|
8
|
+
feeAssetHandlerAddress: z.string().optional(),
|
|
9
|
+
l1ChainId: z.number(),
|
|
10
|
+
})
|
|
11
|
+
.passthrough(); // Allow additional unknown fields to pass through
|
|
12
|
+
|
|
13
|
+
export const NetworkConfigMapSchema = z.record(z.string(), NetworkConfigSchema);
|
|
14
|
+
|
|
15
|
+
export type NetworkConfig = z.infer<typeof NetworkConfigSchema>;
|
|
16
|
+
export type NetworkConfigMap = z.infer<typeof NetworkConfigMapSchema>;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
export type NetworkNames =
|
|
1
|
+
export type NetworkNames =
|
|
2
|
+
| 'local'
|
|
3
|
+
| 'staging-ignition'
|
|
4
|
+
| 'staging-public'
|
|
5
|
+
| 'testnet'
|
|
6
|
+
| 'mainnet'
|
|
7
|
+
| 'next-net'
|
|
8
|
+
| 'devnet';
|
|
2
9
|
|
|
3
10
|
export function getActiveNetworkName(name?: string): NetworkNames {
|
|
4
11
|
const network = name || process.env.NETWORK;
|
|
5
12
|
if (!network || network === '' || network === 'local') {
|
|
6
13
|
return 'local';
|
|
7
|
-
} else if (network === '
|
|
14
|
+
} else if (network === 'staging-ignition') {
|
|
8
15
|
return network;
|
|
9
|
-
} else if (network === '
|
|
16
|
+
} else if (network === 'staging-public') {
|
|
10
17
|
return network;
|
|
18
|
+
} else if (network === 'testnet' || network === 'alpha-testnet') {
|
|
19
|
+
return 'testnet';
|
|
20
|
+
} else if (network === 'mainnet') {
|
|
21
|
+
return 'mainnet';
|
|
22
|
+
} else if (network === 'next-net') {
|
|
23
|
+
return 'next-net';
|
|
24
|
+
} else if (network === 'devnet') {
|
|
25
|
+
return 'devnet';
|
|
11
26
|
}
|
|
12
27
|
throw new Error(`Unknown network: ${network}`);
|
|
13
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BarretenbergSync
|
|
1
|
+
import { BarretenbergSync } from '@aztec/bb.js';
|
|
2
2
|
|
|
3
3
|
import { Buffer } from 'buffer';
|
|
4
4
|
|
|
@@ -22,10 +22,15 @@ export class Aes128 {
|
|
|
22
22
|
paddingBuffer.fill(numPaddingBytes);
|
|
23
23
|
const input = Buffer.concat([data, paddingBuffer]);
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
|
|
26
|
+
const api = BarretenbergSync.getSingleton();
|
|
27
|
+
const response = api.aesEncrypt({
|
|
28
|
+
plaintext: input,
|
|
29
|
+
iv,
|
|
30
|
+
key,
|
|
31
|
+
length: input.length,
|
|
32
|
+
});
|
|
33
|
+
return Buffer.from(response.ciphertext);
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/**
|
|
@@ -37,11 +42,15 @@ export class Aes128 {
|
|
|
37
42
|
* @returns Decrypted data.
|
|
38
43
|
*/
|
|
39
44
|
public async decryptBufferCBCKeepPadding(data: Uint8Array, iv: Uint8Array, key: Uint8Array): Promise<Buffer> {
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
await BarretenbergSync.initSingleton({ wasmPath: process.env.BB_WASM_PATH });
|
|
46
|
+
const api = BarretenbergSync.getSingleton();
|
|
47
|
+
const response = api.aesDecrypt({
|
|
48
|
+
ciphertext: data,
|
|
49
|
+
iv,
|
|
50
|
+
key,
|
|
51
|
+
length: data.length,
|
|
52
|
+
});
|
|
53
|
+
return Buffer.from(response.plaintext);
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
/**
|