@collectorcrypt/vrf-client 0.1.0 → 0.1.2
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 +212 -0
- package/dist/light.js +3 -3
- package/dist/light.js.map +1 -1
- package/package.json +2 -2
- package/src/light.ts +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# @collectorcrypt/vrf-client
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the **cc-vrf** on-chain verifiable-random-function program on Solana. It wraps the Anchor IDL, all of the Light Protocol compressed-PDA plumbing (validity proofs, packed accounts, address-tree-v2), event-log scanning, and the RFC 9381 ECVRF math — so you can register a VRF key, commit proofs, and verify outcomes end-to-end with a single import.
|
|
4
|
+
|
|
5
|
+
cc-vrf is a permissionless, standalone VRF system. The program is live on **devnet + mainnet** at `ccvrfu3fSpbnPLiUqdWAt85Zn9nq96ekwGTbHqGtdgQ`. It registers operator public keys on-chain, freezes them, and accepts cheap proof commitments; the actual ECVRF evaluation happens off-chain (each operator runs their own [`@collectorcrypt/ecvrf`](https://www.npmjs.com/package/@collectorcrypt/ecvrf)), and anyone can verify a committed outcome against the chain. See the [cc-vrf monorepo](https://github.com/collectorcrypt/cc-vrf) for the full architecture, security model, and cost comparison.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
- **Register & lock keys.** Build the `init_authority` / `freeze_authority` / `revoke_authority` instructions. An authority binds one `(owner, label, pk, suite)` tuple; freezing makes the key permanent.
|
|
10
|
+
- **Commit proofs in three modes.** `commit_proof` (compressed-PDA registry), `commit_proof_with_beta` (registry + the 64-byte VRF output stored on-chain for cross-program reads), and `commit_proof_event` (no PDA — just a verified log event, ~3× cheaper).
|
|
11
|
+
- **Fetch & decode** authorities, commits, with-beta commits, and event-mode commitments — including paginated event-log scanning over a plain RPC.
|
|
12
|
+
- **Verify end-to-end.** `verifyEndToEnd` and `verifyAuthorityCommitEndToEnd` check the ECVRF math, the on-chain proof/alpha/memo hashes, the authority lifecycle (frozen, not revoked, owner/label), the commit→authority binding, and optionally the on-chain beta — in one synchronous call. `pickCanonicalCommit` resolves duplicate event-mode commits.
|
|
13
|
+
- **Re-exports the ECVRF primitives** so you don't need a second import to produce or verify proofs.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @collectorcrypt/vrf-client
|
|
19
|
+
# or: pnpm add @collectorcrypt/vrf-client / yarn add @collectorcrypt/vrf-client
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Pulls in `@coral-xyz/anchor` (^0.32), `@solana/web3.js` (^1.98), `@lightprotocol/stateless.js` (^0.23), and `@collectorcrypt/ecvrf`. ESM + TypeScript types included; the program IDL is vendored, so the SDK is browser-safe.
|
|
23
|
+
|
|
24
|
+
> **RPC requirement.** Creating and reading compressed accounts needs a **Photon-capable** Solana RPC (e.g. a Helius dev plan). Pure verification and event-log scanning work against any standard RPC.
|
|
25
|
+
|
|
26
|
+
## Quick start — full lifecycle
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
|
|
30
|
+
import { createRpc } from "@lightprotocol/stateless.js";
|
|
31
|
+
import {
|
|
32
|
+
getProgram,
|
|
33
|
+
generateKeyPair,
|
|
34
|
+
proveVRF,
|
|
35
|
+
vrfProofToHash,
|
|
36
|
+
SUITE_EDWARDS25519_SHA512_TAI,
|
|
37
|
+
buildInitAuthorityIx,
|
|
38
|
+
buildFreezeAuthorityIx,
|
|
39
|
+
buildCommitProofIx,
|
|
40
|
+
fetchAuthority,
|
|
41
|
+
fetchProofCommit,
|
|
42
|
+
verifyAuthorityCommitEndToEnd,
|
|
43
|
+
asTx,
|
|
44
|
+
} from "@collectorcrypt/vrf-client";
|
|
45
|
+
|
|
46
|
+
// Photon-capable RPC + an Anchor provider whose wallet is the operator/owner.
|
|
47
|
+
const rpc = createRpc(RPC_URL); // e.g. https://devnet.helius-rpc.com/?api-key=...
|
|
48
|
+
const wallet = new Wallet(payerKeypair);
|
|
49
|
+
const provider = new AnchorProvider(rpc, wallet, { commitment: "confirmed" });
|
|
50
|
+
const program = getProgram(provider);
|
|
51
|
+
|
|
52
|
+
// 1. Operator: generate a VRF keypair and register the public key as an authority.
|
|
53
|
+
const { sk, pk } = generateKeyPair();
|
|
54
|
+
const label = "gacha";
|
|
55
|
+
const { ix: initIx } = await buildInitAuthorityIx(program, rpc, {
|
|
56
|
+
owner: wallet.publicKey,
|
|
57
|
+
pk,
|
|
58
|
+
suite: SUITE_EDWARDS25519_SHA512_TAI,
|
|
59
|
+
label,
|
|
60
|
+
});
|
|
61
|
+
await provider.sendAndConfirm(asTx(initIx));
|
|
62
|
+
|
|
63
|
+
// 2. Freeze it — one-way. The pk and suite are now permanent; commits are only accepted after this.
|
|
64
|
+
const freezeIx = await buildFreezeAuthorityIx(program, rpc, { owner: wallet.publicKey, label });
|
|
65
|
+
await provider.sendAndConfirm(asTx(freezeIx));
|
|
66
|
+
|
|
67
|
+
// 3. Per VRF call: evaluate off-chain, then commit the hashes on-chain.
|
|
68
|
+
const memo = "draw:user-123:2026-06-19"; // unique per call; user-chosen is ideal
|
|
69
|
+
const alpha = new TextEncoder().encode(memo);
|
|
70
|
+
const { proof } = proveVRF(sk, alpha); // 80-byte ECVRF proof
|
|
71
|
+
const { ix: commitIx } = await buildCommitProofIx(program, rpc, {
|
|
72
|
+
owner: wallet.publicKey,
|
|
73
|
+
label,
|
|
74
|
+
memo,
|
|
75
|
+
alpha,
|
|
76
|
+
proof,
|
|
77
|
+
});
|
|
78
|
+
await provider.sendAndConfirm(asTx(commitIx));
|
|
79
|
+
|
|
80
|
+
// 4. Any verifier: pull the on-chain authority + commit and verify the whole story.
|
|
81
|
+
const auth = await fetchAuthority(program, rpc, wallet.publicKey, label);
|
|
82
|
+
const commit = await fetchProofCommit(program, rpc, auth!.authorityAddress, memo);
|
|
83
|
+
const result = verifyAuthorityCommitEndToEnd({
|
|
84
|
+
authority: auth!.onChainAuthority,
|
|
85
|
+
onChainCommit: commit!.onChainCommit,
|
|
86
|
+
alpha,
|
|
87
|
+
proof,
|
|
88
|
+
memo,
|
|
89
|
+
expectedOwner: wallet.publicKey,
|
|
90
|
+
});
|
|
91
|
+
console.log(result.valid); // true — ECVRF + on-chain hashes + frozen authority all check out
|
|
92
|
+
console.log(result.reasons); // [] (populated with specific failure codes when invalid)
|
|
93
|
+
|
|
94
|
+
// 5. Derive the random value(s) from the verified proof.
|
|
95
|
+
const beta = vrfProofToHash(proof); // 64-byte canonical output; feed to vrfStream() for typed values
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The `build*Ix` helpers **build** instructions (verifying the proof against the authority pk first) but never sign or send — you submit them with your own provider/wallet, so the SDK stays agnostic about transaction assembly, priority fees, and signing.
|
|
99
|
+
|
|
100
|
+
## Commit modes
|
|
101
|
+
|
|
102
|
+
| | `commit_proof` (registry) | `commit_proof_with_beta` | `commit_proof_event` |
|
|
103
|
+
|---|---|---|---|
|
|
104
|
+
| Builder | `buildCommitProofIx` | `buildCommitProofWithBetaIx` | `buildCommitProofEventIx` |
|
|
105
|
+
| Storage | compressed PDA | compressed PDA + 64-byte beta | Solana log event (no PDA) |
|
|
106
|
+
| Other programs read the value | hash only | **yes** (via Light SDK CPI) | only via same-tx CPI |
|
|
107
|
+
| Chain-enforced one-commit-per-memo | yes | yes (shares the registry address) | **no** — verifier-side |
|
|
108
|
+
| Relative per-call cost | baseline | ~same as baseline | ~3× cheaper |
|
|
109
|
+
| Fetch with | `fetchProofCommit` | `fetchProofCommitWithBeta` | `fetchProofCommitEvents` + `pickCanonicalCommit` |
|
|
110
|
+
|
|
111
|
+
`commit_proof` and `commit_proof_with_beta` share the same compressed-PDA address namespace, so a given `(authority, memo)` can use **one or the other**, not both. `buildCommitProofWithBetaIx` takes an extra `beta` field and asserts `beta === vrfProofToHash(proof)`.
|
|
112
|
+
|
|
113
|
+
### Event mode and duplicate resolution
|
|
114
|
+
|
|
115
|
+
Event mode skips the per-call PDA, so the chain does **not** enforce one commit per memo — `fetchProofCommitEvents` can return more than one row for the same `(owner, label, memo)`. Because ECVRF proofs are deterministic for a fixed `(pk, alpha)`, at most one candidate can carry a valid proof hash; the rest are detectable noise, not forgeries. Resolve them before verifying:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import {
|
|
119
|
+
fetchProofCommitEvents,
|
|
120
|
+
pickCanonicalCommit,
|
|
121
|
+
verifyAuthorityCommitEndToEnd,
|
|
122
|
+
} from "@collectorcrypt/vrf-client";
|
|
123
|
+
|
|
124
|
+
// Event-log scanning only needs a plain Connection (provider.connection works).
|
|
125
|
+
const events = await fetchProofCommitEvents(program, provider.connection, owner, label, memo);
|
|
126
|
+
const { canonical, duplicateMemoEvents } = pickCanonicalCommit(
|
|
127
|
+
events.map((e) => e.onChainCommit),
|
|
128
|
+
proof,
|
|
129
|
+
);
|
|
130
|
+
if (!canonical) throw new Error("no event matches a verifying proof");
|
|
131
|
+
|
|
132
|
+
const result = verifyAuthorityCommitEndToEnd({
|
|
133
|
+
authority: auth!.onChainAuthority,
|
|
134
|
+
onChainCommit: canonical,
|
|
135
|
+
alpha,
|
|
136
|
+
proof,
|
|
137
|
+
memo,
|
|
138
|
+
expectedOwner: owner,
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
A naive verifier that just "picks the latest event" without running ECVRF can be misled — `pickCanonicalCommit` + `verifyAuthorityCommitEndToEnd` close that gap and keep event mode as cryptographically sound as registry mode.
|
|
143
|
+
|
|
144
|
+
## API reference
|
|
145
|
+
|
|
146
|
+
### Program handle
|
|
147
|
+
|
|
148
|
+
- `getProgram(provider: AnchorProvider): Program` — build an Anchor `Program` for cc-vrf from a provider (the provider's wallet signs state-mutating instructions). The IDL is vendored into the package.
|
|
149
|
+
|
|
150
|
+
### Constants
|
|
151
|
+
|
|
152
|
+
- `CC_VRF_PROGRAM_ID: PublicKey` — canonical mainnet/devnet program ID. Pass a `programId` override to the address/verify helpers for forked deployments.
|
|
153
|
+
- `SUITE_EDWARDS25519_SHA512_TAI: number` — `0x03`, the only supported suite.
|
|
154
|
+
|
|
155
|
+
### Instruction builders (async; need a Photon-capable `Rpc`)
|
|
156
|
+
|
|
157
|
+
| Builder | Returns | Notes |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| `buildInitAuthorityIx(program, rpc, input)` | `{ ix, authorityAddress }` | `input: InitAuthorityInput` (`owner`, `pk` 32 bytes, `suite`, `label`). |
|
|
160
|
+
| `buildFreezeAuthorityIx(program, rpc, input)` | `ix` | `input: FreezeAuthorityInput` (`owner`, `label`). One-way. |
|
|
161
|
+
| `buildRevokeAuthorityIx(program, rpc, input)` | `ix` | Informational; historical proofs stay verifiable. |
|
|
162
|
+
| `buildCommitProofIx(program, rpc, input)` | `{ ix, commitAddress }` | `input: CommitProofInput` (`owner`, `label`, `memo`, `alpha`, `proof` 80 bytes). Verifies the proof before building. |
|
|
163
|
+
| `buildCommitProofWithBetaIx(program, rpc, input)` | `{ ix, commitAddress }` | `CommitProofInput & { beta: Uint8Array }` (64 bytes; must equal `vrfProofToHash(proof)`). |
|
|
164
|
+
| `buildCommitProofEventIx(program, rpc, input)` | `ix` | `CommitProofInput`. Emits a `VrfProofCommitted` log instead of a PDA. |
|
|
165
|
+
|
|
166
|
+
`label` and `memo` accept a `string` (UTF-8) or `Uint8Array`; labels encode to exactly 32 bytes (`encodeLabel` right-pads).
|
|
167
|
+
|
|
168
|
+
### Fetchers & decoders
|
|
169
|
+
|
|
170
|
+
- `fetchAuthority(program, rpc, owner, label)` → `{ authorityAddress, account, decoded, onChainAuthority } | null`
|
|
171
|
+
- `fetchProofCommit(program, rpc, authority, memo)` → `{ commitAddress, account, decoded, onChainCommit } | null`
|
|
172
|
+
- `fetchProofCommitWithBeta(program, rpc, authority, memo)` → `{ …, onChainCommit, beta } | null` (reassembles the 64-byte beta from its two halves)
|
|
173
|
+
- `fetchProofCommitEvents(program, connection, owner, label, memo, { limit? })` → `ProofCommitEvent[]` (oldest→newest; paginates `getSignaturesForAddress`, default `limit` 1000; uses a plain `Connection`)
|
|
174
|
+
- `decodeAuthority` / `decodeProofCommit` / `decodeProofCommitWithBeta` `(program, dataBytes)` — low-level Borsh decoders.
|
|
175
|
+
|
|
176
|
+
### Verification (pure, synchronous — no RPC)
|
|
177
|
+
|
|
178
|
+
- `verifyEndToEnd(input: VerifyEndToEndInput): VerifyEndToEndResult` — checks ECVRF math + `sha256(proof|alpha|memo)` against the commit. `result.valid` is the AND of every check; `result.beta` is the 64-byte output when `ecvrfValid`; `result.reasons` lists failure codes.
|
|
179
|
+
- `verifyAuthorityCommitEndToEnd(input): VerifyAuthorityCommitEndToEndResult` — everything `verifyEndToEnd` does **plus** authority `frozen`, `!revoked`, optional `expectedOwner`/`expectedLabel`, the commit→authority binding (always rederived from `(owner, label)`), and an optional `onChainBeta` match. Use this for any real verification.
|
|
180
|
+
- `pickCanonicalCommit(candidates: OnChainCommit[], proof): PickCanonicalResult` — returns the unique candidate whose `proofHash` matches the given proof (`canonical`), plus `duplicateMemoEvents` / `multipleVerifying` flags.
|
|
181
|
+
|
|
182
|
+
### Address & hashing helpers (pure)
|
|
183
|
+
|
|
184
|
+
- `deriveAuthorityAddress(owner, label, programId)` — compressed-PDA address; seeds `["vrf_authority", owner, label]` (label must be 32 bytes).
|
|
185
|
+
- `deriveProofCommitAddress(authority, memoHash, programId)` / `deriveProofCommitWithBetaAddress(...)` — seeds `["vrf_proof", authority, memoHash]` (shared namespace).
|
|
186
|
+
- `memoHash(memo)` / `alphaHash(alpha)` / `proofHash(proof)` — SHA-256 convenience wrappers.
|
|
187
|
+
- `encodeLabel(label: string): Uint8Array` — UTF-8, right-padded to 32 bytes (throws if >32 bytes encoded).
|
|
188
|
+
|
|
189
|
+
### Light Protocol context builders (advanced)
|
|
190
|
+
|
|
191
|
+
`forceLightV2`, `buildCreateContext`, `buildCommitProofContext`, `buildReadOnlyAuthorityContext`, `buildMutateContext` — assemble the validity-proof bundle + packed remaining-accounts the program expects. The `build*Ix` helpers use these internally; reach for them directly only when composing custom transactions.
|
|
192
|
+
|
|
193
|
+
### Re-exported from `@collectorcrypt/ecvrf`
|
|
194
|
+
|
|
195
|
+
`generateKeyPair`, `publicKeyFromSeed`, `proveVRF`, `verifyVRF`, `vrfProofToHash`, `bytesToHex`, `hexToBytes` — so producing and verifying proofs needs only this one package.
|
|
196
|
+
|
|
197
|
+
### Exported types
|
|
198
|
+
|
|
199
|
+
`InitAuthorityInput`, `FreezeAuthorityInput`, `CommitProofInput`, `ProofCommitEvent`, `OnChainAuthority`, `OnChainCommit`, `VerifyEndToEndInput`, `VerifyEndToEndResult`, `VerifyAuthorityCommitEndToEndInput`, `VerifyAuthorityCommitEndToEndResult`, `PickCanonicalResult`.
|
|
200
|
+
|
|
201
|
+
## Trust model
|
|
202
|
+
|
|
203
|
+
The program registers public keys, marks them ready (`freeze`), and stores proof-hash commitments — it does **not** custody keys, evaluate randomness, or run ECVRF on-chain (no Solana program can verify an RFC 9381 ECVRF proof in a single tx today). You trust the operator who froze the key to evaluate the VRF honestly; the on-chain commitments make any after-the-fact proof substitution detectable, and `verifyAuthorityCommitEndToEnd` is what makes that detection one function call. Full discussion in the [monorepo README](https://github.com/collectorcrypt/cc-vrf).
|
|
204
|
+
|
|
205
|
+
## Related
|
|
206
|
+
|
|
207
|
+
- [`@collectorcrypt/ecvrf`](https://www.npmjs.com/package/@collectorcrypt/ecvrf) — the underlying RFC 9381 ECVRF library + stream expander.
|
|
208
|
+
- [cc-vrf monorepo](https://github.com/collectorcrypt/cc-vrf) — program, CLI demo, security model, and measured costs.
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
MIT.
|
package/dist/light.js
CHANGED
|
@@ -89,7 +89,7 @@ async function buildCommitProofContext(rpc, programId, authorityExisting, newCom
|
|
|
89
89
|
const authorityReadOnlyMeta = {
|
|
90
90
|
treeInfo: {
|
|
91
91
|
rootIndex: proofRes.rootIndices[0],
|
|
92
|
-
proveByIndex:
|
|
92
|
+
proveByIndex: proofRes.proveByIndices[0],
|
|
93
93
|
merkleTreePubkeyIndex: authMerkleTreePubkeyIndex,
|
|
94
94
|
queuePubkeyIndex: authQueuePubkeyIndex,
|
|
95
95
|
leafIndex: authorityExisting.leafIndex,
|
|
@@ -129,7 +129,7 @@ async function buildReadOnlyAuthorityContext(rpc, programId, authorityExisting)
|
|
|
129
129
|
const authorityReadOnlyMeta = {
|
|
130
130
|
treeInfo: {
|
|
131
131
|
rootIndex: proofRes.rootIndices[0],
|
|
132
|
-
proveByIndex:
|
|
132
|
+
proveByIndex: proofRes.proveByIndices[0],
|
|
133
133
|
merkleTreePubkeyIndex: authMerkleTreePubkeyIndex,
|
|
134
134
|
queuePubkeyIndex: authQueuePubkeyIndex,
|
|
135
135
|
leafIndex: authorityExisting.leafIndex,
|
|
@@ -165,7 +165,7 @@ async function buildMutateContext(rpc, programId, existing) {
|
|
|
165
165
|
const accountMeta = {
|
|
166
166
|
treeInfo: {
|
|
167
167
|
rootIndex: proofRes.rootIndices[0],
|
|
168
|
-
proveByIndex:
|
|
168
|
+
proveByIndex: proofRes.proveByIndices[0],
|
|
169
169
|
merkleTreePubkeyIndex,
|
|
170
170
|
queuePubkeyIndex,
|
|
171
171
|
leafIndex: existing.leafIndex,
|
package/dist/light.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.js","sourceRoot":"","sources":["../src/light.ts"],"names":[],"mappings":";;AAiBA,oCAGC;AAOD,gDAgDC;AAQD,0DAsEC;AAMD,sEA2CC;AAMD,gDAkDC;AAlQD,6CAA4C;AAC5C,8DAUqC;AAErC;;;GAGG;AACH,SAAgB,YAAY;IAC1B,8DAA8D;IAC7D,2BAAoB,CAAC,OAAO,GAAG,sBAAO,CAAC,EAAE,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,kBA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AQ,CAAC,SAAS;SAC9B;QACD,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,oBAAoB;KACrB,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,eAAe,EAAE;QACtC,WAAW;QACX,qBAAqB,EAAE,iBAAiB,CAAC,cAAc,EAAE,CAAC,iBAAiB;KAC5E,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@collectorcrypt/vrf-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "TypeScript SDK for the cc-vrf on-chain VRF program (Solana + Light Protocol)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@lightprotocol/stateless.js": "^0.23.3",
|
|
35
35
|
"@noble/hashes": "^2.2.0",
|
|
36
36
|
"@solana/web3.js": "^1.98.4",
|
|
37
|
-
"@collectorcrypt/ecvrf": "0.1.
|
|
37
|
+
"@collectorcrypt/ecvrf": "0.1.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^25.7.0",
|
package/src/light.ts
CHANGED
|
@@ -130,7 +130,7 @@ export async function buildCommitProofContext(
|
|
|
130
130
|
const authorityReadOnlyMeta = {
|
|
131
131
|
treeInfo: {
|
|
132
132
|
rootIndex: proofRes.rootIndices[0],
|
|
133
|
-
proveByIndex:
|
|
133
|
+
proveByIndex: proofRes.proveByIndices[0],
|
|
134
134
|
merkleTreePubkeyIndex: authMerkleTreePubkeyIndex,
|
|
135
135
|
queuePubkeyIndex: authQueuePubkeyIndex,
|
|
136
136
|
leafIndex: authorityExisting.leafIndex,
|
|
@@ -187,7 +187,7 @@ export async function buildReadOnlyAuthorityContext(
|
|
|
187
187
|
const authorityReadOnlyMeta = {
|
|
188
188
|
treeInfo: {
|
|
189
189
|
rootIndex: proofRes.rootIndices[0],
|
|
190
|
-
proveByIndex:
|
|
190
|
+
proveByIndex: proofRes.proveByIndices[0],
|
|
191
191
|
merkleTreePubkeyIndex: authMerkleTreePubkeyIndex,
|
|
192
192
|
queuePubkeyIndex: authQueuePubkeyIndex,
|
|
193
193
|
leafIndex: authorityExisting.leafIndex,
|
|
@@ -242,7 +242,7 @@ export async function buildMutateContext(
|
|
|
242
242
|
const accountMeta = {
|
|
243
243
|
treeInfo: {
|
|
244
244
|
rootIndex: proofRes.rootIndices[0],
|
|
245
|
-
proveByIndex:
|
|
245
|
+
proveByIndex: proofRes.proveByIndices[0],
|
|
246
246
|
merkleTreePubkeyIndex,
|
|
247
247
|
queuePubkeyIndex,
|
|
248
248
|
leafIndex: existing.leafIndex,
|