@veilo/sdk-core 0.3.3 → 0.4.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 +42 -3
- package/SHIELD_INTEGRATION.md +143 -0
- package/config.d.ts +2 -0
- package/config.js +4 -0
- package/dist/cjs/client.d.ts +5 -5
- package/dist/cjs/client.js +79 -42
- package/dist/cjs/compactNote.d.ts +107 -0
- package/dist/cjs/compactNote.js +167 -0
- package/dist/cjs/events.d.ts +1 -1
- package/dist/cjs/events.js +2 -2
- package/dist/cjs/idl/privacy_pool.d.ts +5 -0
- package/dist/cjs/idl/privacy_pool.js +15218 -0
- package/dist/cjs/index.d.ts +16 -13
- package/dist/cjs/index.js +40 -30
- package/dist/cjs/merkle.d.ts +13 -0
- package/dist/cjs/merkle.js +31 -8
- package/dist/cjs/program.d.ts +11 -0
- package/dist/cjs/program.js +26 -3
- package/dist/cjs/proof.d.ts +1 -1
- package/dist/cjs/proof.js +37 -37
- package/dist/cjs/prover.d.ts +1 -1
- package/dist/cjs/prover.js +2 -2
- package/dist/cjs/random.d.ts +16 -0
- package/dist/cjs/random.js +28 -0
- package/dist/cjs/relayer.d.ts +27 -4
- package/dist/cjs/relayer.js +16 -5
- package/dist/cjs/shield/alt.d.ts +87 -0
- package/dist/cjs/shield/alt.js +194 -0
- package/dist/cjs/shield/computeBudget.d.ts +61 -0
- package/dist/cjs/shield/computeBudget.js +64 -0
- package/dist/cjs/shield/errors.d.ts +58 -0
- package/dist/cjs/shield/errors.js +121 -0
- package/dist/cjs/shield/finalize.d.ts +45 -0
- package/dist/cjs/shield/finalize.js +119 -0
- package/dist/cjs/shield/index.d.ts +35 -0
- package/dist/cjs/shield/index.js +68 -0
- package/dist/cjs/shield/ix.d.ts +54 -0
- package/dist/cjs/shield/ix.js +119 -0
- package/dist/cjs/shield/owner.d.ts +36 -0
- package/dist/cjs/shield/owner.js +126 -0
- package/dist/cjs/shield/ports.d.ts +43 -0
- package/dist/cjs/shield/ports.js +153 -0
- package/dist/cjs/shield/preflight.d.ts +30 -0
- package/dist/cjs/shield/preflight.js +154 -0
- package/dist/cjs/shield/shield.d.ts +68 -0
- package/dist/cjs/shield/shield.js +499 -0
- package/dist/cjs/shield/types.d.ts +202 -0
- package/dist/cjs/shield/types.js +2 -0
- package/dist/cjs/utxo.d.ts +20 -0
- package/dist/cjs/utxo.js +41 -28
- package/dist/esm/client.d.ts +407 -0
- package/dist/esm/client.js +9 -5
- package/dist/esm/compactNote.d.ts +107 -0
- package/dist/esm/compactNote.js +156 -0
- package/dist/esm/config.d.ts +82 -0
- package/dist/esm/events.d.ts +77 -0
- package/dist/esm/events.js +1 -1
- package/dist/esm/idl/privacy_pool.d.ts +5 -0
- package/dist/esm/idl/privacy_pool.js +15216 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +18 -11
- package/dist/esm/merkle.d.ts +77 -0
- package/dist/esm/merkle.js +23 -1
- package/dist/esm/package.json +1 -0
- package/dist/esm/poseidon.d.ts +29 -0
- package/dist/esm/program.d.ts +37 -0
- package/dist/esm/program.js +23 -1
- package/dist/esm/proof.d.ts +183 -0
- package/dist/esm/proof.js +2 -2
- package/dist/esm/prover.d.ts +54 -0
- package/dist/esm/prover.js +1 -1
- package/dist/esm/random.d.ts +16 -0
- package/dist/esm/random.js +21 -0
- package/dist/esm/relayer.d.ts +318 -0
- package/dist/esm/relayer.js +16 -5
- package/dist/esm/retry.d.ts +32 -0
- package/dist/esm/shield/alt.d.ts +87 -0
- package/dist/esm/shield/alt.js +186 -0
- package/dist/esm/shield/computeBudget.d.ts +61 -0
- package/dist/esm/shield/computeBudget.js +61 -0
- package/dist/esm/shield/errors.d.ts +58 -0
- package/dist/esm/shield/errors.js +115 -0
- package/dist/esm/shield/finalize.d.ts +45 -0
- package/dist/esm/shield/finalize.js +83 -0
- package/dist/esm/shield/index.d.ts +35 -0
- package/dist/esm/shield/index.js +32 -0
- package/dist/esm/shield/ix.d.ts +54 -0
- package/dist/esm/shield/ix.js +82 -0
- package/dist/esm/shield/owner.d.ts +36 -0
- package/dist/esm/shield/owner.js +122 -0
- package/dist/esm/shield/ports.d.ts +43 -0
- package/dist/esm/shield/ports.js +147 -0
- package/dist/esm/shield/preflight.d.ts +30 -0
- package/dist/esm/shield/preflight.js +151 -0
- package/dist/esm/shield/shield.d.ts +68 -0
- package/dist/esm/shield/shield.js +492 -0
- package/dist/esm/shield/types.d.ts +202 -0
- package/dist/esm/shield/types.js +1 -0
- package/dist/esm/utxo.d.ts +235 -0
- package/dist/esm/utxo.js +18 -8
- package/dist/src/client.d.ts +407 -0
- package/dist/src/client.js +951 -0
- package/dist/src/compactNote.d.ts +107 -0
- package/dist/src/compactNote.js +167 -0
- package/dist/src/config.d.ts +82 -0
- package/dist/src/config.js +57 -0
- package/dist/src/events.d.ts +77 -0
- package/dist/src/events.js +167 -0
- package/dist/src/idl/privacy_pool.d.ts +5 -0
- package/dist/src/idl/privacy_pool.js +15218 -0
- package/dist/src/index.d.ts +16 -0
- package/dist/src/index.js +67 -0
- package/dist/src/merkle.d.ts +77 -0
- package/dist/src/merkle.js +156 -0
- package/dist/src/poseidon.d.ts +29 -0
- package/dist/src/poseidon.js +100 -0
- package/dist/src/program.d.ts +37 -0
- package/dist/src/program.js +61 -0
- package/dist/src/proof.d.ts +183 -0
- package/dist/src/proof.js +292 -0
- package/dist/src/prover.d.ts +54 -0
- package/dist/src/prover.js +112 -0
- package/dist/src/random.d.ts +16 -0
- package/dist/src/random.js +28 -0
- package/dist/src/relayer.d.ts +318 -0
- package/dist/src/relayer.js +257 -0
- package/dist/src/retry.d.ts +32 -0
- package/dist/src/retry.js +75 -0
- package/dist/src/shield/alt.d.ts +87 -0
- package/dist/src/shield/alt.js +194 -0
- package/dist/src/shield/computeBudget.d.ts +61 -0
- package/dist/src/shield/computeBudget.js +64 -0
- package/dist/src/shield/errors.d.ts +58 -0
- package/dist/src/shield/errors.js +121 -0
- package/dist/src/shield/finalize.d.ts +45 -0
- package/dist/src/shield/finalize.js +119 -0
- package/dist/src/shield/index.d.ts +35 -0
- package/dist/src/shield/index.js +68 -0
- package/dist/src/shield/ix.d.ts +54 -0
- package/dist/src/shield/ix.js +119 -0
- package/dist/src/shield/owner.d.ts +36 -0
- package/dist/src/shield/owner.js +126 -0
- package/dist/src/shield/ports.d.ts +43 -0
- package/dist/src/shield/ports.js +153 -0
- package/dist/src/shield/preflight.d.ts +30 -0
- package/dist/src/shield/preflight.js +154 -0
- package/dist/src/shield/shield.d.ts +68 -0
- package/dist/src/shield/shield.js +499 -0
- package/dist/src/shield/types.d.ts +202 -0
- package/dist/src/shield/types.js +2 -0
- package/dist/src/utxo.d.ts +235 -0
- package/dist/src/utxo.js +407 -0
- package/dist/tests/compact-note.test.d.ts +1 -0
- package/dist/tests/compact-note.test.js +173 -0
- package/dist/tests/config.test.d.ts +1 -0
- package/dist/tests/config.test.js +102 -0
- package/dist/tests/edge-cases.test.d.ts +1 -0
- package/dist/tests/edge-cases.test.js +220 -0
- package/dist/tests/encryption.test.d.ts +1 -0
- package/dist/tests/encryption.test.js +215 -0
- package/dist/tests/events.test.d.ts +1 -0
- package/dist/tests/events.test.js +78 -0
- package/dist/tests/multi-tree.test.d.ts +1 -0
- package/dist/tests/multi-tree.test.js +405 -0
- package/dist/tests/pda.test.d.ts +1 -0
- package/dist/tests/pda.test.js +229 -0
- package/dist/tests/poseidon-builder-parity.test.d.ts +1 -0
- package/dist/tests/poseidon-builder-parity.test.js +72 -0
- package/dist/tests/poseidon.test.d.ts +1 -0
- package/dist/tests/poseidon.test.js +142 -0
- package/dist/tests/proof.test.d.ts +1 -0
- package/dist/tests/proof.test.js +296 -0
- package/dist/tests/relayer.test.d.ts +1 -0
- package/dist/tests/relayer.test.js +271 -0
- package/dist/tests/sdk.integration.test.d.ts +1 -0
- package/dist/tests/sdk.integration.test.js +330 -0
- package/dist/tests/shield-owner.test.d.ts +1 -0
- package/dist/tests/shield-owner.test.js +89 -0
- package/dist/tests/shield-preflight.test.d.ts +1 -0
- package/dist/tests/shield-preflight.test.js +87 -0
- package/dist/tests/shield-realproof.test.d.ts +1 -0
- package/dist/tests/shield-realproof.test.js +272 -0
- package/dist/tests/shield.test.d.ts +1 -0
- package/dist/tests/shield.test.js +403 -0
- package/dist/tests/utxo.test.d.ts +1 -0
- package/dist/tests/utxo.test.js +140 -0
- package/package.json +69 -11
- package/poseidon.d.ts +2 -0
- package/poseidon.js +4 -0
- package/proof.d.ts +2 -0
- package/proof.js +4 -0
- package/prover.d.ts +2 -0
- package/prover.js +4 -0
- package/shield.d.ts +2 -0
- package/shield.js +4 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.COMPACT_BLOB_LENGTH = void 0;
|
|
7
|
+
exports.createCompactNoteCipher = createCompactNoteCipher;
|
|
8
|
+
exports.decryptCompactNoteCipher = decryptCompactNoteCipher;
|
|
9
|
+
exports.matchesViewTag = matchesViewTag;
|
|
10
|
+
exports.toX25519Private = toX25519Private;
|
|
11
|
+
exports.emptyNoteCipher = emptyNoteCipher;
|
|
12
|
+
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
13
|
+
const utxo_js_1 = require("./utxo.js");
|
|
14
|
+
const random_js_1 = require("./random.js");
|
|
15
|
+
/**
|
|
16
|
+
* Compact note ciphers — the 80-byte payload carried inside the on-chain
|
|
17
|
+
* `transact` instruction (`note_ciphers: Option<NoteCiphers>`) and re-emitted in
|
|
18
|
+
* `CommitmentEvent`.
|
|
19
|
+
*
|
|
20
|
+
* This is what makes a note recoverable from chain data alone: a recipient who
|
|
21
|
+
* was never told about a deposit can still find it by scanning `view_tag` and
|
|
22
|
+
* decrypting the blob. Without it, note delivery depends on someone calling the
|
|
23
|
+
* relayer, which a third-party integrator cannot be trusted to do.
|
|
24
|
+
*
|
|
25
|
+
* ## Byte-compatibility is load-bearing
|
|
26
|
+
*
|
|
27
|
+
* Four sibling implementations already exist (relayer-server, extension ×2,
|
|
28
|
+
* wallet-app). This is the canonical one, and it MUST agree with them byte for
|
|
29
|
+
* byte in both directions:
|
|
30
|
+
*
|
|
31
|
+
* - disagree on encrypt → new notes are invisible to every existing client
|
|
32
|
+
* - disagree on decrypt → the entire historical note corpus becomes unreadable
|
|
33
|
+
*
|
|
34
|
+
* Three details are easy to get wrong and are individually fatal:
|
|
35
|
+
*
|
|
36
|
+
* 1. The KDF is `nacl.hash(x).slice(0, 32)` — **truncated SHA-512**, despite the
|
|
37
|
+
* sibling helper being named `sha256ForNotes`. See `kdfSHA512_256` in utxo.ts.
|
|
38
|
+
* 2. The ephemeral key published on-chain is **Ed25519**; it is converted to
|
|
39
|
+
* X25519 only for the Diffie-Hellman. Scanners convert it back.
|
|
40
|
+
* 3. `viewTag` is the first byte of the hash of the **raw shared secret**, not of
|
|
41
|
+
* the derived key. A wrong view tag makes every note invisible to the scan
|
|
42
|
+
* loop, which rejects ~255/256 candidates on this byte alone.
|
|
43
|
+
*
|
|
44
|
+
* The ECDH primitives are imported from `utxo.ts` rather than reimplemented — a
|
|
45
|
+
* fifth independent Edwards→Montgomery implementation is exactly how the current
|
|
46
|
+
* drift risk between the four siblings arose.
|
|
47
|
+
*
|
|
48
|
+
* Verified against the siblings by `tests/compact-note.test.ts` (golden vectors)
|
|
49
|
+
* and `scripts/verify-compact-cipher-parity.mjs` (differential).
|
|
50
|
+
*/
|
|
51
|
+
/** Size of the on-chain compact blob: nonce[24] || secretbox(40-byte plaintext)[56]. */
|
|
52
|
+
exports.COMPACT_BLOB_LENGTH = 80;
|
|
53
|
+
/** Plaintext layout: blinding[32] || amount as little-endian u64[8]. */
|
|
54
|
+
const COMPACT_PLAINTEXT_LENGTH = 40;
|
|
55
|
+
const NONCE_LENGTH = 24;
|
|
56
|
+
/**
|
|
57
|
+
* Encrypt a note's secret material to a recipient's Solana wallet key.
|
|
58
|
+
*
|
|
59
|
+
* The recipient does not need to be the signer of the transaction, or to have
|
|
60
|
+
* any prior relationship with the sender — this is what makes shielding to an
|
|
61
|
+
* arbitrary owner possible.
|
|
62
|
+
*
|
|
63
|
+
* @param recipientWalletPubkey 32-byte Ed25519 Solana wallet public key
|
|
64
|
+
* @param blinding 32-byte big-endian blinding factor
|
|
65
|
+
* @param amount note amount in base units
|
|
66
|
+
*/
|
|
67
|
+
function createCompactNoteCipher(recipientWalletPubkey, blinding, amount,
|
|
68
|
+
/** @internal */ __det) {
|
|
69
|
+
if (recipientWalletPubkey.length !== 32) {
|
|
70
|
+
throw new Error(`recipientWalletPubkey must be 32 bytes, got ${recipientWalletPubkey.length}`);
|
|
71
|
+
}
|
|
72
|
+
if (blinding.length < 32) {
|
|
73
|
+
throw new Error(`blinding must be at least 32 bytes, got ${blinding.length}`);
|
|
74
|
+
}
|
|
75
|
+
if (amount < 0n || amount > 0xffffffffffffffffn) {
|
|
76
|
+
throw new Error(`amount ${amount} does not fit in a u64`);
|
|
77
|
+
}
|
|
78
|
+
// Ed25519 ephemeral keypair. `nacl.sign.keyPair.fromSeed(seed)` produces the
|
|
79
|
+
// same public key as web3.js `Keypair.generate()` for the same seed, which is
|
|
80
|
+
// what the sibling implementations use — but without pulling @solana/web3.js
|
|
81
|
+
// into the crypto path.
|
|
82
|
+
const ephemeralSeed = __det?.ephemeralSeed ?? (0, random_js_1.randomBytes)(32);
|
|
83
|
+
const ephemeralPublicKey = tweetnacl_1.default.sign.keyPair.fromSeed(ephemeralSeed).publicKey;
|
|
84
|
+
const sharedSecret = deriveSharedSecret(ephemeralSeed, recipientWalletPubkey);
|
|
85
|
+
const key = (0, utxo_js_1.kdfSHA512_256)(sharedSecret);
|
|
86
|
+
const plaintext = new Uint8Array(COMPACT_PLAINTEXT_LENGTH);
|
|
87
|
+
plaintext.set(blinding.slice(0, 32), 0);
|
|
88
|
+
let amt = amount;
|
|
89
|
+
for (let i = 0; i < 8; i++) {
|
|
90
|
+
plaintext[32 + i] = Number(amt & 0xffn);
|
|
91
|
+
amt >>= 8n;
|
|
92
|
+
}
|
|
93
|
+
const nonce = __det?.nonce ?? tweetnacl_1.default.randomBytes(NONCE_LENGTH);
|
|
94
|
+
const encrypted = tweetnacl_1.default.secretbox(plaintext, nonce, key);
|
|
95
|
+
const compactBlob = new Uint8Array(exports.COMPACT_BLOB_LENGTH);
|
|
96
|
+
compactBlob.set(nonce, 0);
|
|
97
|
+
compactBlob.set(encrypted, NONCE_LENGTH);
|
|
98
|
+
// First byte of the hash of the RAW shared secret — not of `key`.
|
|
99
|
+
const viewTag = tweetnacl_1.default.hash(sharedSecret)[0];
|
|
100
|
+
return { ephemeralPublicKey, compactBlob, viewTag };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Recover a note's blinding and amount from an on-chain compact cipher.
|
|
104
|
+
*
|
|
105
|
+
* Returns `null` when the blob was not encrypted to this key — the expected
|
|
106
|
+
* outcome for the overwhelming majority of candidates during a scan, so callers
|
|
107
|
+
* should filter on `viewTag` first (see {@link matchesViewTag}) and only attempt
|
|
108
|
+
* decryption on the ~1/256 that survive.
|
|
109
|
+
*
|
|
110
|
+
* @param walletSecretKey 32-byte Ed25519 seed or 64-byte secret key
|
|
111
|
+
*/
|
|
112
|
+
function decryptCompactNoteCipher(walletSecretKey, ephemeralPublicKey, compactBlob, precomputed) {
|
|
113
|
+
if (compactBlob.length !== exports.COMPACT_BLOB_LENGTH)
|
|
114
|
+
return null;
|
|
115
|
+
const sharedSecret = precomputed?.sharedSecret ??
|
|
116
|
+
(precomputed?.x25519Private
|
|
117
|
+
? tweetnacl_1.default.scalarMult(precomputed.x25519Private, (0, utxo_js_1.ed25519PublicKeyToX25519)(ephemeralPublicKey))
|
|
118
|
+
: deriveSharedSecret(walletSecretKey, ephemeralPublicKey));
|
|
119
|
+
const key = (0, utxo_js_1.kdfSHA512_256)(sharedSecret);
|
|
120
|
+
const nonce = compactBlob.slice(0, NONCE_LENGTH);
|
|
121
|
+
const encrypted = compactBlob.slice(NONCE_LENGTH);
|
|
122
|
+
const plaintext = tweetnacl_1.default.secretbox.open(encrypted, nonce, key);
|
|
123
|
+
if (!plaintext)
|
|
124
|
+
return null;
|
|
125
|
+
const blinding = new Uint8Array(plaintext.slice(0, 32));
|
|
126
|
+
let amount = 0n;
|
|
127
|
+
for (let i = 7; i >= 0; i--) {
|
|
128
|
+
amount = (amount << 8n) | BigInt(plaintext[32 + i]);
|
|
129
|
+
}
|
|
130
|
+
return { blinding, amount };
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Cheap scan filter: does this on-chain cipher plausibly belong to us?
|
|
134
|
+
*
|
|
135
|
+
* Rejects ~255/256 candidates for the cost of one scalar multiplication and one
|
|
136
|
+
* hash, versus a full secretbox open. Hoist `x25519Private` across a scan loop
|
|
137
|
+
* with {@link toX25519Private}.
|
|
138
|
+
*/
|
|
139
|
+
function matchesViewTag(walletSecretKey, ephemeralPublicKey, viewTag, precomputed) {
|
|
140
|
+
const sharedSecret = precomputed?.x25519Private
|
|
141
|
+
? tweetnacl_1.default.scalarMult(precomputed.x25519Private, (0, utxo_js_1.ed25519PublicKeyToX25519)(ephemeralPublicKey))
|
|
142
|
+
: deriveSharedSecret(walletSecretKey, ephemeralPublicKey);
|
|
143
|
+
return { matches: tweetnacl_1.default.hash(sharedSecret)[0] === viewTag, sharedSecret };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Convert an Ed25519 wallet secret key to its X25519 scalar once, for reuse
|
|
147
|
+
* across a scan loop.
|
|
148
|
+
*/
|
|
149
|
+
function toX25519Private(walletSecretKey) {
|
|
150
|
+
return (0, utxo_js_1.ed25519SeedToX25519Private)(seedOf(walletSecretKey));
|
|
151
|
+
}
|
|
152
|
+
/** The all-zero cipher the program treats as "no note here". */
|
|
153
|
+
function emptyNoteCipher() {
|
|
154
|
+
return {
|
|
155
|
+
ephemeralPublicKey: new Uint8Array(32),
|
|
156
|
+
compactBlob: new Uint8Array(exports.COMPACT_BLOB_LENGTH),
|
|
157
|
+
viewTag: 0,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
// -- internal -----------------------------------------------------------------
|
|
161
|
+
/** Accept either a 32-byte Ed25519 seed or a 64-byte secret key, as the siblings do. */
|
|
162
|
+
function seedOf(secretKey) {
|
|
163
|
+
return secretKey.length === 64 ? secretKey.slice(0, 32) : secretKey;
|
|
164
|
+
}
|
|
165
|
+
function deriveSharedSecret(mySecretKey, theirEd25519PublicKey) {
|
|
166
|
+
return tweetnacl_1.default.scalarMult((0, utxo_js_1.ed25519SeedToX25519Private)(seedOf(mySecretKey)), (0, utxo_js_1.ed25519PublicKeyToX25519)(theirEd25519PublicKey));
|
|
167
|
+
}
|
package/dist/cjs/events.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { Program, Idl } from "@coral-xyz/anchor";
|
|
3
|
-
import { MerkleTree } from "./merkle";
|
|
3
|
+
import { MerkleTree } from "./merkle.js";
|
|
4
4
|
/**
|
|
5
5
|
* On-chain CommitmentEvent emitted by `transact` and `transact_swap`.
|
|
6
6
|
* Mirrors the IDL CommitmentEvent struct.
|
package/dist/cjs/events.js
CHANGED
|
@@ -37,7 +37,7 @@ exports.scanCommitmentEvents = scanCommitmentEvents;
|
|
|
37
37
|
exports.scanNullifierEvents = scanNullifierEvents;
|
|
38
38
|
exports.buildTreeFromEvents = buildTreeFromEvents;
|
|
39
39
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
40
|
-
const
|
|
40
|
+
const merkle_js_1 = require("./merkle.js");
|
|
41
41
|
// -----------------------------------------------------------------------------
|
|
42
42
|
// Event Scanning
|
|
43
43
|
// -----------------------------------------------------------------------------
|
|
@@ -156,7 +156,7 @@ async function buildTreeFromEvents(params) {
|
|
|
156
156
|
const treeEvents = allEvents
|
|
157
157
|
.filter((e) => e.treeId === treeId)
|
|
158
158
|
.sort((a, b) => a.leafIndex - b.leafIndex);
|
|
159
|
-
const tree = new
|
|
159
|
+
const tree = new merkle_js_1.MerkleTree(depth);
|
|
160
160
|
for (const ev of treeEvents) {
|
|
161
161
|
tree.insert(ev.commitment);
|
|
162
162
|
}
|