@aztec/merkle-tree 0.7.2 → 0.7.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.
Files changed (66) hide show
  1. package/.tsbuildinfo +1 -0
  2. package/dest/index.d.ts +12 -0
  3. package/dest/index.d.ts.map +1 -0
  4. package/dest/index.js +12 -0
  5. package/dest/interfaces/append_only_tree.d.ts +13 -0
  6. package/dest/interfaces/append_only_tree.d.ts.map +1 -0
  7. package/dest/interfaces/append_only_tree.js +2 -0
  8. package/dest/interfaces/indexed_tree.d.ts +57 -0
  9. package/dest/interfaces/indexed_tree.d.ts.map +1 -0
  10. package/dest/interfaces/indexed_tree.js +2 -0
  11. package/dest/interfaces/merkle_tree.d.ts +47 -0
  12. package/dest/interfaces/merkle_tree.d.ts.map +1 -0
  13. package/dest/interfaces/merkle_tree.js +2 -0
  14. package/dest/interfaces/update_only_tree.d.ts +15 -0
  15. package/dest/interfaces/update_only_tree.d.ts.map +1 -0
  16. package/dest/interfaces/update_only_tree.js +2 -0
  17. package/dest/load_tree.d.ts +13 -0
  18. package/dest/load_tree.d.ts.map +1 -0
  19. package/dest/load_tree.js +17 -0
  20. package/dest/new_tree.d.ts +15 -0
  21. package/dest/new_tree.d.ts.map +1 -0
  22. package/dest/new_tree.js +16 -0
  23. package/dest/pedersen.d.ts +15 -0
  24. package/dest/pedersen.d.ts.map +1 -0
  25. package/dest/pedersen.js +22 -0
  26. package/dest/sparse_tree/sparse_tree.d.ts +15 -0
  27. package/dest/sparse_tree/sparse_tree.d.ts.map +1 -0
  28. package/dest/sparse_tree/sparse_tree.js +31 -0
  29. package/dest/sparse_tree/sparse_tree.test.d.ts +2 -0
  30. package/dest/sparse_tree/sparse_tree.test.d.ts.map +1 -0
  31. package/dest/sparse_tree/sparse_tree.test.js +133 -0
  32. package/dest/standard_indexed_tree/standard_indexed_tree.d.ts +245 -0
  33. package/dest/standard_indexed_tree/standard_indexed_tree.d.ts.map +1 -0
  34. package/dest/standard_indexed_tree/standard_indexed_tree.js +488 -0
  35. package/dest/standard_indexed_tree/test/standard_indexed_tree.test.d.ts +2 -0
  36. package/dest/standard_indexed_tree/test/standard_indexed_tree.test.d.ts.map +1 -0
  37. package/dest/standard_indexed_tree/test/standard_indexed_tree.test.js +336 -0
  38. package/dest/standard_indexed_tree/test/standard_indexed_tree_with_append.d.ts +23 -0
  39. package/dest/standard_indexed_tree/test/standard_indexed_tree_with_append.d.ts.map +1 -0
  40. package/dest/standard_indexed_tree/test/standard_indexed_tree_with_append.js +59 -0
  41. package/dest/standard_tree/standard_tree.d.ts +15 -0
  42. package/dest/standard_tree/standard_tree.d.ts.map +1 -0
  43. package/dest/standard_tree/standard_tree.js +15 -0
  44. package/dest/standard_tree/standard_tree.test.d.ts +2 -0
  45. package/dest/standard_tree/standard_tree.test.d.ts.map +1 -0
  46. package/dest/standard_tree/standard_tree.test.js +58 -0
  47. package/dest/test/standard_based_test_suite.d.ts +6 -0
  48. package/dest/test/standard_based_test_suite.d.ts.map +1 -0
  49. package/dest/test/standard_based_test_suite.js +87 -0
  50. package/dest/test/test_suite.d.ts +6 -0
  51. package/dest/test/test_suite.d.ts.map +1 -0
  52. package/dest/test/test_suite.js +119 -0
  53. package/dest/test/utils/append_leaves.d.ts +5 -0
  54. package/dest/test/utils/append_leaves.d.ts.map +1 -0
  55. package/dest/test/utils/append_leaves.js +14 -0
  56. package/dest/test/utils/create_mem_down.d.ts +3 -0
  57. package/dest/test/utils/create_mem_down.d.ts.map +1 -0
  58. package/dest/test/utils/create_mem_down.js +3 -0
  59. package/dest/test/utils/pedersen_with_counter.d.ts +24 -0
  60. package/dest/test/utils/pedersen_with_counter.d.ts.map +1 -0
  61. package/dest/test/utils/pedersen_with_counter.js +31 -0
  62. package/dest/tree_base.d.ts +130 -0
  63. package/dest/tree_base.d.ts.map +1 -0
  64. package/dest/tree_base.js +257 -0
  65. package/package.json +4 -4
  66. package/Dockerfile +0 -15
@@ -0,0 +1,488 @@
1
+ import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer';
2
+ import { createDebugLogger } from '@aztec/foundation/log';
3
+ import { SiblingPath } from '@aztec/types';
4
+ import { TreeBase } from '../tree_base.js';
5
+ const log = createDebugLogger('aztec:standard-indexed-tree');
6
+ const indexToKeyLeaf = (name, index) => {
7
+ return `${name}:leaf:${index}`;
8
+ };
9
+ const zeroLeaf = {
10
+ value: 0n,
11
+ nextValue: 0n,
12
+ nextIndex: 0n,
13
+ };
14
+ /**
15
+ * Pre-compute empty witness.
16
+ * @param treeHeight - Height of tree for sibling path.
17
+ * @returns An empty witness.
18
+ */
19
+ function getEmptyLowLeafWitness(treeHeight) {
20
+ return {
21
+ leafData: zeroLeaf,
22
+ index: 0n,
23
+ siblingPath: new SiblingPath(treeHeight, Array(treeHeight).fill(toBufferBE(0n, 32))),
24
+ };
25
+ }
26
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
+ const encodeTreeValue = (leafData) => {
28
+ const valueAsBuffer = toBufferBE(leafData.value, 32);
29
+ const indexAsBuffer = toBufferBE(leafData.nextIndex, 32);
30
+ const nextValueAsBuffer = toBufferBE(leafData.nextValue, 32);
31
+ return Buffer.concat([valueAsBuffer, indexAsBuffer, nextValueAsBuffer]);
32
+ };
33
+ const decodeTreeValue = (buf) => {
34
+ const value = toBigIntBE(buf.subarray(0, 32));
35
+ const nextIndex = toBigIntBE(buf.subarray(32, 64));
36
+ const nextValue = toBigIntBE(buf.subarray(64, 96));
37
+ return {
38
+ value,
39
+ nextIndex,
40
+ nextValue,
41
+ };
42
+ };
43
+ /**
44
+ * Indexed merkle tree.
45
+ */
46
+ export class StandardIndexedTree extends TreeBase {
47
+ constructor() {
48
+ super(...arguments);
49
+ this.leaves = [];
50
+ this.cachedLeaves = {};
51
+ }
52
+ /**
53
+ * Appends the given leaves to the tree.
54
+ * @param _leaves - The leaves to append.
55
+ * @returns Empty promise.
56
+ * @remarks Use batchInsert method instead.
57
+ */
58
+ appendLeaves(_leaves) {
59
+ throw new Error('Not implemented');
60
+ }
61
+ /**
62
+ * Commits the changes to the database.
63
+ * @returns Empty promise.
64
+ */
65
+ async commit() {
66
+ await super.commit();
67
+ await this.commitLeaves();
68
+ }
69
+ /**
70
+ * Rolls back the not-yet-committed changes.
71
+ * @returns Empty promise.
72
+ */
73
+ async rollback() {
74
+ await super.rollback();
75
+ this.clearCachedLeaves();
76
+ }
77
+ /**
78
+ * Gets the value of the leaf at the given index.
79
+ * @param index - Index of the leaf of which to obtain the value.
80
+ * @param includeUncommitted - Indicates whether to include uncommitted leaves in the computation.
81
+ * @returns The value of the leaf at the given index or undefined if the leaf is empty.
82
+ */
83
+ getLeafValue(index, includeUncommitted) {
84
+ const leaf = this.getLatestLeafDataCopy(Number(index), includeUncommitted);
85
+ if (!leaf)
86
+ return Promise.resolve(undefined);
87
+ return Promise.resolve(toBufferBE(leaf.value, 32));
88
+ }
89
+ /**
90
+ * Finds the index of the largest leaf whose value is less than or equal to the provided value.
91
+ * @param newValue - The new value to be inserted into the tree.
92
+ * @param includeUncommitted - If true, the uncommitted changes are included in the search.
93
+ * @returns The found leaf index and a flag indicating if the corresponding leaf's value is equal to `newValue`.
94
+ */
95
+ findIndexOfPreviousValue(newValue, includeUncommitted) {
96
+ const numLeaves = this.getNumLeaves(includeUncommitted);
97
+ const diff = [];
98
+ for (let i = 0; i < numLeaves; i++) {
99
+ const storedLeaf = this.getLatestLeafDataCopy(i, includeUncommitted);
100
+ // The stored leaf can be undefined if it addresses an empty leaf
101
+ // If the leaf is empty we do the same as if the leaf was larger
102
+ if (storedLeaf === undefined) {
103
+ diff.push(newValue);
104
+ }
105
+ else if (storedLeaf.value > newValue) {
106
+ diff.push(newValue);
107
+ }
108
+ else if (storedLeaf.value === newValue) {
109
+ return { index: i, alreadyPresent: true };
110
+ }
111
+ else {
112
+ diff.push(newValue - storedLeaf.value);
113
+ }
114
+ }
115
+ const minIndex = this.findMinIndex(diff);
116
+ return { index: minIndex, alreadyPresent: false };
117
+ }
118
+ /**
119
+ * Gets the latest LeafData copy.
120
+ * @param index - Index of the leaf of which to obtain the LeafData copy.
121
+ * @param includeUncommitted - If true, the uncommitted changes are included in the search.
122
+ * @returns A copy of the leaf data at the given index or undefined if the leaf was not found.
123
+ */
124
+ getLatestLeafDataCopy(index, includeUncommitted) {
125
+ const leaf = !includeUncommitted ? this.leaves[index] : this.cachedLeaves[index] ?? this.leaves[index];
126
+ return leaf
127
+ ? {
128
+ value: leaf.value,
129
+ nextIndex: leaf.nextIndex,
130
+ nextValue: leaf.nextValue,
131
+ }
132
+ : undefined;
133
+ }
134
+ /**
135
+ * Finds the index of the minimum value in an array.
136
+ * @param values - The collection of values to be searched.
137
+ * @returns The index of the minimum value in the array.
138
+ */
139
+ findMinIndex(values) {
140
+ if (!values.length) {
141
+ return 0;
142
+ }
143
+ let minIndex = 0;
144
+ for (let i = 1; i < values.length; i++) {
145
+ if (values[minIndex] > values[i]) {
146
+ minIndex = i;
147
+ }
148
+ }
149
+ return minIndex;
150
+ }
151
+ /**
152
+ * Initializes the tree.
153
+ * @param prefilledSize - A number of leaves that are prefilled with values.
154
+ * @returns Empty promise.
155
+ *
156
+ * @remarks Explanation of pre-filling:
157
+ * There needs to be an initial (0,0,0) leaf in the tree, so that when we insert the first 'proper' leaf, we can
158
+ * prove that any value greater than 0 doesn't exist in the tree yet. We prefill/pad the tree with "the number of
159
+ * leaves that are added by one block" so that the first 'proper' block can insert a full subtree.
160
+ *
161
+ * Without this padding, there would be a leaf (0,0,0) at leaf index 0, making it really difficult to insert e.g.
162
+ * 1024 leaves for the first block, because there's only neat space for 1023 leaves after 0. By padding with 1023
163
+ * more leaves, we can then insert the first block of 1024 leaves into indices 1024:2047.
164
+ */
165
+ async init(prefilledSize) {
166
+ if (prefilledSize < 1) {
167
+ throw new Error(`Prefilled size must be at least 1!`);
168
+ }
169
+ const leaves = [];
170
+ for (let i = 0n; i < prefilledSize; i++) {
171
+ const newLeaf = {
172
+ value: toBigIntBE(Buffer.from([Number(i)])),
173
+ nextIndex: i + 1n,
174
+ nextValue: i + 1n,
175
+ };
176
+ leaves.push(newLeaf);
177
+ }
178
+ // Make the first leaf have 0 value
179
+ leaves[0].value = 0n;
180
+ // Make the last leaf point to the first leaf
181
+ leaves[prefilledSize - 1].nextIndex = 0n;
182
+ leaves[prefilledSize - 1].nextValue = 0n;
183
+ await this.encodeAndAppendLeaves(leaves, true);
184
+ await this.commit();
185
+ }
186
+ /**
187
+ * Loads Merkle tree data from a database and assigns them to this object.
188
+ */
189
+ async initFromDb() {
190
+ const startingIndex = 0n;
191
+ const values = [];
192
+ const promise = new Promise((resolve, reject) => {
193
+ this.db
194
+ .createReadStream({
195
+ gte: indexToKeyLeaf(this.getName(), startingIndex),
196
+ lte: indexToKeyLeaf(this.getName(), 2n ** BigInt(this.getDepth())),
197
+ })
198
+ .on('data', function (data) {
199
+ const index = Number(data.key);
200
+ values[index] = decodeTreeValue(data.value);
201
+ })
202
+ .on('close', function () { })
203
+ .on('end', function () {
204
+ resolve();
205
+ })
206
+ .on('error', function () {
207
+ log.error('stream error');
208
+ reject();
209
+ });
210
+ });
211
+ await promise;
212
+ this.leaves = values;
213
+ }
214
+ /**
215
+ * Commits all the leaves to the database and removes them from a cache.
216
+ */
217
+ async commitLeaves() {
218
+ const batch = this.db.batch();
219
+ const keys = Object.getOwnPropertyNames(this.cachedLeaves);
220
+ for (const key of keys) {
221
+ const index = Number(key);
222
+ batch.put(key, this.cachedLeaves[index]);
223
+ this.leaves[index] = this.cachedLeaves[index];
224
+ }
225
+ await batch.write();
226
+ this.clearCachedLeaves();
227
+ }
228
+ /**
229
+ * Clears the cache.
230
+ */
231
+ clearCachedLeaves() {
232
+ this.cachedLeaves = {};
233
+ }
234
+ /**
235
+ * Updates a leaf in the tree.
236
+ * @param leaf - New contents of the leaf.
237
+ * @param index - Index of the leaf to be updated.
238
+ */
239
+ async updateLeaf(leaf, index) {
240
+ if (index > this.maxIndex) {
241
+ throw Error(`Index out of bounds. Index ${index}, max index: ${this.maxIndex}.`);
242
+ }
243
+ const encodedLeaf = this.encodeLeaf(leaf, true);
244
+ await this.addLeafToCacheAndHashToRoot(encodedLeaf, index);
245
+ const numLeaves = this.getNumLeaves(true);
246
+ if (index >= numLeaves) {
247
+ this.cachedSize = index + 1n;
248
+ }
249
+ }
250
+ /* eslint-disable jsdoc/require-description-complete-sentence */
251
+ /* The following doc block messes up with complete-sentence, so we just disable it */
252
+ /**
253
+ *
254
+ * Each base rollup needs to provide non membership / inclusion proofs for each of the nullifier.
255
+ * This method will return membership proofs and perform partial node updates that will
256
+ * allow the circuit to incrementally update the tree and perform a batch insertion.
257
+ *
258
+ * This offers massive circuit performance savings over doing incremental insertions.
259
+ *
260
+ * A description of the algorithm can be found here: https://colab.research.google.com/drive/1A0gizduSi4FIiIJZ8OylwIpO9-OTqV-R
261
+ *
262
+ * WARNING: This function has side effects, it will insert values into the tree.
263
+ *
264
+ * Assumptions:
265
+ * 1. There are 8 nullifiers provided and they are either unique or empty. (denoted as 0)
266
+ * 2. If kc 0 has 1 nullifier, and kc 1 has 3 nullifiers the layout will assume to be the sparse
267
+ * nullifier layout: [kc0-0, 0, 0, 0, kc1-0, kc1-1, kc1-2, 0]
268
+ *
269
+ * Algorithm overview
270
+ *
271
+ * In general, if we want to batch insert items, we first need to update their low nullifier to point to them,
272
+ * then batch insert all of the values at once in the final step.
273
+ * To update a low nullifier, we provide an insertion proof that the low nullifier currently exists to the
274
+ * circuit, then update the low nullifier.
275
+ * Updating this low nullifier will in turn change the root of the tree. Therefore future low nullifier insertion proofs
276
+ * must be given against this new root.
277
+ * As a result, each low nullifier membership proof will be provided against an intermediate tree state, each with differing
278
+ * roots.
279
+ *
280
+ * This become tricky when two items that are being batch inserted need to update the same low nullifier, or need to use
281
+ * a value that is part of the same batch insertion as their low nullifier. In this case a zero low nullifier path is given
282
+ * to the circuit, and it must determine from the set of batch inserted values if the insertion is valid.
283
+ *
284
+ * The following example will illustrate attempting to insert 2,3,20,19 into a tree already containing 0,5,10,15
285
+ *
286
+ * The example will explore two cases. In each case the values low nullifier will exist within the batch insertion,
287
+ * One where the low nullifier comes before the item in the set (2,3), and one where it comes after (20,19).
288
+ *
289
+ * The original tree: Pending insertion subtree
290
+ *
291
+ * index 0 2 3 4 - - - -
292
+ * ------------------------------------- ----------------------------
293
+ * val 0 5 10 15 - - - -
294
+ * nextIdx 1 2 3 0 - - - -
295
+ * nextVal 5 10 15 0 - - - -
296
+ *
297
+ *
298
+ * Inserting 2: (happy path)
299
+ * 1. Find the low nullifier (0) - provide inclusion proof
300
+ * 2. Update its pointers
301
+ * 3. Insert 2 into the pending subtree
302
+ *
303
+ * index 0 2 3 4 5 - - -
304
+ * ------------------------------------- ----------------------------
305
+ * val 0 5 10 15 2 - - -
306
+ * nextIdx 5 2 3 0 2 - - -
307
+ * nextVal 2 10 15 0 5 - - -
308
+ *
309
+ * Inserting 3: The low nullifier exists within the insertion current subtree
310
+ * 1. When looking for the low nullifier for 3, we will receive 0 again as we have not inserted 2 into the main tree
311
+ * This is problematic, as we cannot use either 0 or 2 as our inclusion proof.
312
+ * Why cant we?
313
+ * - Index 0 has a val 0 and nextVal of 2. This is NOT enough to prove non inclusion of 2.
314
+ * - Our existing tree is in a state where we cannot prove non inclusion of 3.
315
+ * We do not provide a non inclusion proof to out circuit, but prompt it to look within the insertion subtree.
316
+ * 2. Update pending insertion subtree
317
+ * 3. Insert 3 into pending subtree
318
+ *
319
+ * (no inclusion proof provided)
320
+ * index 0 2 3 4 5 6 - -
321
+ * ------------------------------------- ----------------------------
322
+ * val 0 5 10 15 2 3 - -
323
+ * nextIdx 5 2 3 0 6 2 - -
324
+ * nextVal 2 10 15 0 3 5 - -
325
+ *
326
+ * Inserting 20: (happy path)
327
+ * 1. Find the low nullifier (15) - provide inclusion proof
328
+ * 2. Update its pointers
329
+ * 3. Insert 20 into the pending subtree
330
+ *
331
+ * index 0 2 3 4 5 6 7 -
332
+ * ------------------------------------- ----------------------------
333
+ * val 0 5 10 15 2 3 20 -
334
+ * nextIdx 5 2 3 7 6 2 0 -
335
+ * nextVal 2 10 15 20 3 5 0 -
336
+ *
337
+ * Inserting 19:
338
+ * 1. In this case we can find a low nullifier, but we are updating a low nullifier that has already been updated
339
+ * We can provide an inclusion proof of this intermediate tree state.
340
+ * 2. Update its pointers
341
+ * 3. Insert 19 into the pending subtree
342
+ *
343
+ * index 0 2 3 4 5 6 7 8
344
+ * ------------------------------------- ----------------------------
345
+ * val 0 5 10 15 2 3 20 19
346
+ * nextIdx 5 2 3 8 6 2 0 7
347
+ * nextVal 2 10 15 19 3 5 0 20
348
+ *
349
+ * Perform subtree insertion
350
+ *
351
+ * index 0 2 3 4 5 6 7 8
352
+ * ---------------------------------------------------------------------
353
+ * val 0 5 10 15 2 3 20 19
354
+ * nextIdx 5 2 3 8 6 2 0 7
355
+ * nextVal 2 10 15 19 3 5 0 20
356
+ *
357
+ * TODO: this implementation will change once the zero value is changed from h(0,0,0). Changes incoming over the next sprint
358
+ * @param leaves - Values to insert into the tree.
359
+ * @param subtreeHeight - Height of the subtree.
360
+ * @returns The data for the leaves to be updated when inserting the new ones.
361
+ */
362
+ async batchInsert(leaves, subtreeHeight) {
363
+ // Keep track of touched low leaves
364
+ const touched = new Map();
365
+ const emptyLowLeafWitness = getEmptyLowLeafWitness(this.getDepth());
366
+ // Accumulators
367
+ const lowLeavesWitnesses = [];
368
+ const pendingInsertionSubtree = [];
369
+ // Start info
370
+ const startInsertionIndex = this.getNumLeaves(true);
371
+ // Get insertion path for each leaf
372
+ for (let i = 0; i < leaves.length; i++) {
373
+ const newValue = toBigIntBE(leaves[i]);
374
+ // Keep space and just insert zero values
375
+ if (newValue === 0n) {
376
+ pendingInsertionSubtree.push(zeroLeaf);
377
+ lowLeavesWitnesses.push(emptyLowLeafWitness);
378
+ continue;
379
+ }
380
+ const indexOfPrevious = this.findIndexOfPreviousValue(newValue, true);
381
+ // If a touched node has a value that is less than the current value
382
+ const prevNodes = touched.get(indexOfPrevious.index);
383
+ if (prevNodes && prevNodes.some(v => v < newValue)) {
384
+ // check the pending low nullifiers for a low nullifier that works
385
+ // This is the case where the next value is less than the pending
386
+ for (let j = 0; j < pendingInsertionSubtree.length; j++) {
387
+ if (pendingInsertionSubtree[j].value === 0n)
388
+ continue;
389
+ if (pendingInsertionSubtree[j].value < newValue &&
390
+ (pendingInsertionSubtree[j].nextValue > newValue || pendingInsertionSubtree[j].nextValue === 0n)) {
391
+ // add the new value to the pending low nullifiers
392
+ const currentLowLeaf = {
393
+ value: newValue,
394
+ nextValue: pendingInsertionSubtree[j].nextValue,
395
+ nextIndex: pendingInsertionSubtree[j].nextIndex,
396
+ };
397
+ pendingInsertionSubtree.push(currentLowLeaf);
398
+ // Update the pending low leaf to point at the new value
399
+ pendingInsertionSubtree[j].nextValue = newValue;
400
+ pendingInsertionSubtree[j].nextIndex = startInsertionIndex + BigInt(i);
401
+ break;
402
+ }
403
+ }
404
+ // Any node updated in this space will need to calculate its low nullifier from a previously inserted value
405
+ lowLeavesWitnesses.push(emptyLowLeafWitness);
406
+ }
407
+ else {
408
+ // Update the touched mapping
409
+ if (prevNodes) {
410
+ prevNodes.push(newValue);
411
+ touched.set(indexOfPrevious.index, prevNodes);
412
+ }
413
+ else {
414
+ touched.set(indexOfPrevious.index, [newValue]);
415
+ }
416
+ // get the low leaf
417
+ const lowLeaf = this.getLatestLeafDataCopy(indexOfPrevious.index, true);
418
+ if (lowLeaf === undefined) {
419
+ return [undefined, await this.getSubtreeSiblingPath(subtreeHeight, true)];
420
+ }
421
+ const siblingPath = await this.getSiblingPath(BigInt(indexOfPrevious.index), true);
422
+ const witness = {
423
+ leafData: { ...lowLeaf },
424
+ index: BigInt(indexOfPrevious.index),
425
+ siblingPath,
426
+ };
427
+ // Update the running paths
428
+ lowLeavesWitnesses.push(witness);
429
+ const currentLowLeaf = {
430
+ value: newValue,
431
+ nextValue: lowLeaf.nextValue,
432
+ nextIndex: lowLeaf.nextIndex,
433
+ };
434
+ pendingInsertionSubtree.push(currentLowLeaf);
435
+ lowLeaf.nextValue = newValue;
436
+ lowLeaf.nextIndex = startInsertionIndex + BigInt(i);
437
+ const lowLeafIndex = indexOfPrevious.index;
438
+ this.cachedLeaves[lowLeafIndex] = lowLeaf;
439
+ await this.updateLeaf(lowLeaf, BigInt(lowLeafIndex));
440
+ }
441
+ }
442
+ const newSubtreeSiblingPath = await this.getSubtreeSiblingPath(subtreeHeight, true);
443
+ // Perform batch insertion of new pending values
444
+ // Note: In this case we set `hash0Leaf` param to false because batch insertion algorithm use forced null leaf
445
+ // inclusion. See {@link encodeLeaf} for a more through param explanation.
446
+ await this.encodeAndAppendLeaves(pendingInsertionSubtree, false);
447
+ return [lowLeavesWitnesses, newSubtreeSiblingPath];
448
+ }
449
+ async getSubtreeSiblingPath(subtreeHeight, includeUncommitted) {
450
+ const nextAvailableLeafIndex = this.getNumLeaves(includeUncommitted);
451
+ const fullSiblingPath = await this.getSiblingPath(nextAvailableLeafIndex, includeUncommitted);
452
+ // Drop the first subtreeHeight items since we only care about the path to the subtree root
453
+ return fullSiblingPath.getSubtreeSiblingPath(subtreeHeight);
454
+ }
455
+ /**
456
+ * Encodes leaves and appends them to a tree.
457
+ * @param leaves - Leaves to encode.
458
+ * @param hash0Leaf - Indicates whether 0 value leaf should be hashed. See {@link encodeLeaf}.
459
+ * @returns Empty promise
460
+ */
461
+ async encodeAndAppendLeaves(leaves, hash0Leaf) {
462
+ const startInsertionIndex = Number(this.getNumLeaves(true));
463
+ const serialisedLeaves = leaves.map((leaf, i) => {
464
+ this.cachedLeaves[startInsertionIndex + i] = leaf;
465
+ return this.encodeLeaf(leaf, hash0Leaf);
466
+ });
467
+ await super.appendLeaves(serialisedLeaves);
468
+ }
469
+ /**
470
+ * Encode a leaf into a buffer.
471
+ * @param leaf - Leaf to encode.
472
+ * @param hash0Leaf - Indicates whether 0 value leaf should be hashed. Not hashing 0 value can represent a forced
473
+ * null leaf insertion. Detecting this case by checking for 0 value is safe as in the case of
474
+ * nullifier it is improbable that a valid nullifier would be 0.
475
+ * @returns Leaf encoded in a buffer.
476
+ */
477
+ encodeLeaf(leaf, hash0Leaf) {
478
+ let encodedLeaf;
479
+ if (!hash0Leaf && leaf.value == 0n) {
480
+ encodedLeaf = toBufferBE(0n, 32);
481
+ }
482
+ else {
483
+ encodedLeaf = this.hasher.compressInputs([leaf.value, leaf.nextIndex, leaf.nextValue].map(val => toBufferBE(val, 32)));
484
+ }
485
+ return encodedLeaf;
486
+ }
487
+ }
488
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhbmRhcmRfaW5kZXhlZF90cmVlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N0YW5kYXJkX2luZGV4ZWRfdHJlZS9zdGFuZGFyZF9pbmRleGVkX3RyZWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxVQUFVLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUN6RSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUMxRCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sY0FBYyxDQUFDO0FBRzNDLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUUzQyxNQUFNLEdBQUcsR0FBRyxpQkFBaUIsQ0FBQyw2QkFBNkIsQ0FBQyxDQUFDO0FBRTdELE1BQU0sY0FBYyxHQUFHLENBQUMsSUFBWSxFQUFFLEtBQWEsRUFBRSxFQUFFO0lBQ3JELE9BQU8sR0FBRyxJQUFJLFNBQVMsS0FBSyxFQUFFLENBQUM7QUFDakMsQ0FBQyxDQUFDO0FBRUYsTUFBTSxRQUFRLEdBQWE7SUFDekIsS0FBSyxFQUFFLEVBQUU7SUFDVCxTQUFTLEVBQUUsRUFBRTtJQUNiLFN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-0,0 +1 @@
1
+ {"version":3,"file":"standard_indexed_tree.test.d.ts","sourceRoot":"","sources":["../../../src/standard_indexed_tree/test/standard_indexed_tree.test.ts"],"names":[],"mappings":""}