@collectorcrypt/vrf-client 0.1.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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @collectorcrypt/vrf-client
3
+ *
4
+ * TypeScript SDK for the cc-vrf on-chain VRF program. Wraps the Anchor IDL,
5
+ * Light Protocol compressed-PDA plumbing, and the RFC 9381 ECVRF library so
6
+ * consumers can publish, commit, and verify VRF proofs with one import.
7
+ */
8
+ export { generateKeyPair, publicKeyFromSeed, proveVRF, verifyVRF, vrfProofToHash, bytesToHex, hexToBytes, } from "@collectorcrypt/ecvrf";
9
+ export { CC_VRF_PROGRAM_ID, SUITE_EDWARDS25519_SHA512_TAI } from "./constants";
10
+ export { deriveAuthorityAddress, deriveProofCommitAddress, deriveProofCommitWithBetaAddress, memoHash, alphaHash, proofHash, encodeLabel, } from "./addresses";
11
+ export { forceLightV2, buildCreateContext, buildCommitProofContext, buildReadOnlyAuthorityContext, buildMutateContext, } from "./light";
12
+ export { getProgram } from "./program";
13
+ export { buildInitAuthorityIx, buildFreezeAuthorityIx, buildRevokeAuthorityIx, buildCommitProofIx, buildCommitProofEventIx, buildCommitProofWithBetaIx, fetchAuthority, fetchProofCommit, fetchProofCommitWithBeta, fetchProofCommitEvents, decodeAuthority, decodeProofCommit, decodeProofCommitWithBeta, asTx, } from "./operations";
14
+ export type { InitAuthorityInput, FreezeAuthorityInput, CommitProofInput, ProofCommitEvent, } from "./operations";
15
+ export { verifyEndToEnd, verifyAuthorityCommitEndToEnd, pickCanonicalCommit, } from "./verifyEndToEnd";
16
+ export type { OnChainAuthority, OnChainCommit, VerifyAuthorityCommitEndToEndInput, VerifyAuthorityCommitEndToEndResult, VerifyEndToEndInput, VerifyEndToEndResult, PickCanonicalResult, } from "./verifyEndToEnd";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,UAAU,EACV,UAAU,GACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,gCAAgC,EAChC,QAAQ,EACR,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,yBAAyB,EACzB,IAAI,GACL,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,cAAc,EACd,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kCAAkC,EAClC,mCAAmC,EACnC,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /**
3
+ * @collectorcrypt/vrf-client
4
+ *
5
+ * TypeScript SDK for the cc-vrf on-chain VRF program. Wraps the Anchor IDL,
6
+ * Light Protocol compressed-PDA plumbing, and the RFC 9381 ECVRF library so
7
+ * consumers can publish, commit, and verify VRF proofs with one import.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.pickCanonicalCommit = exports.verifyAuthorityCommitEndToEnd = exports.verifyEndToEnd = exports.asTx = exports.decodeProofCommitWithBeta = exports.decodeProofCommit = exports.decodeAuthority = exports.fetchProofCommitEvents = exports.fetchProofCommitWithBeta = exports.fetchProofCommit = exports.fetchAuthority = exports.buildCommitProofWithBetaIx = exports.buildCommitProofEventIx = exports.buildCommitProofIx = exports.buildRevokeAuthorityIx = exports.buildFreezeAuthorityIx = exports.buildInitAuthorityIx = exports.getProgram = exports.buildMutateContext = exports.buildReadOnlyAuthorityContext = exports.buildCommitProofContext = exports.buildCreateContext = exports.forceLightV2 = exports.encodeLabel = exports.proofHash = exports.alphaHash = exports.memoHash = exports.deriveProofCommitWithBetaAddress = exports.deriveProofCommitAddress = exports.deriveAuthorityAddress = exports.SUITE_EDWARDS25519_SHA512_TAI = exports.CC_VRF_PROGRAM_ID = exports.hexToBytes = exports.bytesToHex = exports.vrfProofToHash = exports.verifyVRF = exports.proveVRF = exports.publicKeyFromSeed = exports.generateKeyPair = void 0;
11
+ // Re-export the ECVRF primitives so consumers don't need a second import.
12
+ var ecvrf_1 = require("@collectorcrypt/ecvrf");
13
+ Object.defineProperty(exports, "generateKeyPair", { enumerable: true, get: function () { return ecvrf_1.generateKeyPair; } });
14
+ Object.defineProperty(exports, "publicKeyFromSeed", { enumerable: true, get: function () { return ecvrf_1.publicKeyFromSeed; } });
15
+ Object.defineProperty(exports, "proveVRF", { enumerable: true, get: function () { return ecvrf_1.proveVRF; } });
16
+ Object.defineProperty(exports, "verifyVRF", { enumerable: true, get: function () { return ecvrf_1.verifyVRF; } });
17
+ Object.defineProperty(exports, "vrfProofToHash", { enumerable: true, get: function () { return ecvrf_1.vrfProofToHash; } });
18
+ Object.defineProperty(exports, "bytesToHex", { enumerable: true, get: function () { return ecvrf_1.bytesToHex; } });
19
+ Object.defineProperty(exports, "hexToBytes", { enumerable: true, get: function () { return ecvrf_1.hexToBytes; } });
20
+ var constants_1 = require("./constants");
21
+ Object.defineProperty(exports, "CC_VRF_PROGRAM_ID", { enumerable: true, get: function () { return constants_1.CC_VRF_PROGRAM_ID; } });
22
+ Object.defineProperty(exports, "SUITE_EDWARDS25519_SHA512_TAI", { enumerable: true, get: function () { return constants_1.SUITE_EDWARDS25519_SHA512_TAI; } });
23
+ var addresses_1 = require("./addresses");
24
+ Object.defineProperty(exports, "deriveAuthorityAddress", { enumerable: true, get: function () { return addresses_1.deriveAuthorityAddress; } });
25
+ Object.defineProperty(exports, "deriveProofCommitAddress", { enumerable: true, get: function () { return addresses_1.deriveProofCommitAddress; } });
26
+ Object.defineProperty(exports, "deriveProofCommitWithBetaAddress", { enumerable: true, get: function () { return addresses_1.deriveProofCommitWithBetaAddress; } });
27
+ Object.defineProperty(exports, "memoHash", { enumerable: true, get: function () { return addresses_1.memoHash; } });
28
+ Object.defineProperty(exports, "alphaHash", { enumerable: true, get: function () { return addresses_1.alphaHash; } });
29
+ Object.defineProperty(exports, "proofHash", { enumerable: true, get: function () { return addresses_1.proofHash; } });
30
+ Object.defineProperty(exports, "encodeLabel", { enumerable: true, get: function () { return addresses_1.encodeLabel; } });
31
+ var light_1 = require("./light");
32
+ Object.defineProperty(exports, "forceLightV2", { enumerable: true, get: function () { return light_1.forceLightV2; } });
33
+ Object.defineProperty(exports, "buildCreateContext", { enumerable: true, get: function () { return light_1.buildCreateContext; } });
34
+ Object.defineProperty(exports, "buildCommitProofContext", { enumerable: true, get: function () { return light_1.buildCommitProofContext; } });
35
+ Object.defineProperty(exports, "buildReadOnlyAuthorityContext", { enumerable: true, get: function () { return light_1.buildReadOnlyAuthorityContext; } });
36
+ Object.defineProperty(exports, "buildMutateContext", { enumerable: true, get: function () { return light_1.buildMutateContext; } });
37
+ var program_1 = require("./program");
38
+ Object.defineProperty(exports, "getProgram", { enumerable: true, get: function () { return program_1.getProgram; } });
39
+ var operations_1 = require("./operations");
40
+ Object.defineProperty(exports, "buildInitAuthorityIx", { enumerable: true, get: function () { return operations_1.buildInitAuthorityIx; } });
41
+ Object.defineProperty(exports, "buildFreezeAuthorityIx", { enumerable: true, get: function () { return operations_1.buildFreezeAuthorityIx; } });
42
+ Object.defineProperty(exports, "buildRevokeAuthorityIx", { enumerable: true, get: function () { return operations_1.buildRevokeAuthorityIx; } });
43
+ Object.defineProperty(exports, "buildCommitProofIx", { enumerable: true, get: function () { return operations_1.buildCommitProofIx; } });
44
+ Object.defineProperty(exports, "buildCommitProofEventIx", { enumerable: true, get: function () { return operations_1.buildCommitProofEventIx; } });
45
+ Object.defineProperty(exports, "buildCommitProofWithBetaIx", { enumerable: true, get: function () { return operations_1.buildCommitProofWithBetaIx; } });
46
+ Object.defineProperty(exports, "fetchAuthority", { enumerable: true, get: function () { return operations_1.fetchAuthority; } });
47
+ Object.defineProperty(exports, "fetchProofCommit", { enumerable: true, get: function () { return operations_1.fetchProofCommit; } });
48
+ Object.defineProperty(exports, "fetchProofCommitWithBeta", { enumerable: true, get: function () { return operations_1.fetchProofCommitWithBeta; } });
49
+ Object.defineProperty(exports, "fetchProofCommitEvents", { enumerable: true, get: function () { return operations_1.fetchProofCommitEvents; } });
50
+ Object.defineProperty(exports, "decodeAuthority", { enumerable: true, get: function () { return operations_1.decodeAuthority; } });
51
+ Object.defineProperty(exports, "decodeProofCommit", { enumerable: true, get: function () { return operations_1.decodeProofCommit; } });
52
+ Object.defineProperty(exports, "decodeProofCommitWithBeta", { enumerable: true, get: function () { return operations_1.decodeProofCommitWithBeta; } });
53
+ Object.defineProperty(exports, "asTx", { enumerable: true, get: function () { return operations_1.asTx; } });
54
+ var verifyEndToEnd_1 = require("./verifyEndToEnd");
55
+ Object.defineProperty(exports, "verifyEndToEnd", { enumerable: true, get: function () { return verifyEndToEnd_1.verifyEndToEnd; } });
56
+ Object.defineProperty(exports, "verifyAuthorityCommitEndToEnd", { enumerable: true, get: function () { return verifyEndToEnd_1.verifyAuthorityCommitEndToEnd; } });
57
+ Object.defineProperty(exports, "pickCanonicalCommit", { enumerable: true, get: function () { return verifyEndToEnd_1.pickCanonicalCommit; } });
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,0EAA0E;AAC1E,+CAQ+B;AAP7B,wGAAA,eAAe,OAAA;AACf,0GAAA,iBAAiB,OAAA;AACjB,iGAAA,QAAQ,OAAA;AACR,kGAAA,SAAS,OAAA;AACT,uGAAA,cAAc,OAAA;AACd,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AAGZ,yCAA+E;AAAtE,8GAAA,iBAAiB,OAAA;AAAE,0HAAA,6BAA6B,OAAA;AAEzD,yCAQqB;AAPnB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,6HAAA,gCAAgC,OAAA;AAChC,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AACT,wGAAA,WAAW,OAAA;AAGb,iCAMiB;AALf,qGAAA,YAAY,OAAA;AACZ,2GAAA,kBAAkB,OAAA;AAClB,gHAAA,uBAAuB,OAAA;AACvB,sHAAA,6BAA6B,OAAA;AAC7B,2GAAA,kBAAkB,OAAA;AAGpB,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,2CAesB;AAdpB,kHAAA,oBAAoB,OAAA;AACpB,oHAAA,sBAAsB,OAAA;AACtB,oHAAA,sBAAsB,OAAA;AACtB,gHAAA,kBAAkB,OAAA;AAClB,qHAAA,uBAAuB,OAAA;AACvB,wHAAA,0BAA0B,OAAA;AAC1B,4GAAA,cAAc,OAAA;AACd,8GAAA,gBAAgB,OAAA;AAChB,sHAAA,wBAAwB,OAAA;AACxB,oHAAA,sBAAsB,OAAA;AACtB,6GAAA,eAAe,OAAA;AACf,+GAAA,iBAAiB,OAAA;AACjB,uHAAA,yBAAyB,OAAA;AACzB,kGAAA,IAAI,OAAA;AAUN,mDAI0B;AAHxB,gHAAA,cAAc,OAAA;AACd,+HAAA,6BAA6B,OAAA;AAC7B,qHAAA,mBAAmB,OAAA"}
@@ -0,0 +1,98 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { CompressedAccountWithMerkleContext, Rpc } from "@lightprotocol/stateless.js";
3
+ /**
4
+ * Force the SDK into V2 mode so our address derivations + state-tree usage
5
+ * match the on-chain program's ADDRESS_TREE_V2 expectation.
6
+ */
7
+ export declare function forceLightV2(): void;
8
+ /**
9
+ * For CREATE flows (init_authority, commit_proof): builds the validity-proof
10
+ * bundle + packed remaining-accounts list needed to mint a new compressed
11
+ * PDA at the given address.
12
+ */
13
+ export declare function buildCreateContext(rpc: Rpc, programId: PublicKey, newCompressedAddress: PublicKey, existingInputs?: {
14
+ hash: Uint8Array;
15
+ tree: PublicKey;
16
+ queue: PublicKey;
17
+ }[]): Promise<{
18
+ proof: {
19
+ 0: import("@lightprotocol/stateless.js").ValidityProof | null;
20
+ };
21
+ packedAddressTreeInfo: {
22
+ rootIndex: number;
23
+ addressMerkleTreePubkeyIndex: number;
24
+ addressQueuePubkeyIndex: number;
25
+ };
26
+ outputStateTreeIndex: number;
27
+ remainingAccountMetas: import("@solana/web3.js").AccountMeta[];
28
+ }>;
29
+ /**
30
+ * For commit_proof specifically: one input (the existing authority, treated
31
+ * as read-only on chain) + one new address (the commit). Both indices come
32
+ * from the same getValidityProofV0 call so they reference the same proof
33
+ * and the same packed-accounts list.
34
+ */
35
+ export declare function buildCommitProofContext(rpc: Rpc, programId: PublicKey, authorityExisting: CompressedAccountWithMerkleContext, newCommitAddress: PublicKey): Promise<{
36
+ proof: {
37
+ 0: import("@lightprotocol/stateless.js").ValidityProof | null;
38
+ };
39
+ authorityReadOnlyMeta: {
40
+ treeInfo: {
41
+ rootIndex: number;
42
+ proveByIndex: boolean;
43
+ merkleTreePubkeyIndex: number;
44
+ queuePubkeyIndex: number;
45
+ leafIndex: number;
46
+ };
47
+ address: number[] | null;
48
+ };
49
+ packedAddressTreeInfo: {
50
+ rootIndex: number;
51
+ addressMerkleTreePubkeyIndex: number;
52
+ addressQueuePubkeyIndex: number;
53
+ };
54
+ outputStateTreeIndex: number;
55
+ remainingAccountMetas: import("@solana/web3.js").AccountMeta[];
56
+ }>;
57
+ /**
58
+ * For event-mode commits: builds a validity-proof bundle for an existing
59
+ * authority treated as read-only. No new compressed address is created.
60
+ */
61
+ export declare function buildReadOnlyAuthorityContext(rpc: Rpc, programId: PublicKey, authorityExisting: CompressedAccountWithMerkleContext): Promise<{
62
+ proof: {
63
+ 0: import("@lightprotocol/stateless.js").ValidityProof | null;
64
+ };
65
+ authorityReadOnlyMeta: {
66
+ treeInfo: {
67
+ rootIndex: number;
68
+ proveByIndex: boolean;
69
+ merkleTreePubkeyIndex: number;
70
+ queuePubkeyIndex: number;
71
+ leafIndex: number;
72
+ };
73
+ address: number[] | null;
74
+ };
75
+ remainingAccountMetas: import("@solana/web3.js").AccountMeta[];
76
+ }>;
77
+ /**
78
+ * For MUTATE flows (freeze_authority, revoke_authority): builds the
79
+ * validity-proof bundle + account meta for an existing compressed PDA.
80
+ */
81
+ export declare function buildMutateContext(rpc: Rpc, programId: PublicKey, existing: CompressedAccountWithMerkleContext): Promise<{
82
+ proof: {
83
+ 0: import("@lightprotocol/stateless.js").ValidityProof | null;
84
+ };
85
+ accountMeta: {
86
+ treeInfo: {
87
+ rootIndex: number;
88
+ proveByIndex: boolean;
89
+ merkleTreePubkeyIndex: number;
90
+ queuePubkeyIndex: number;
91
+ leafIndex: number;
92
+ };
93
+ address: number[] | null;
94
+ outputStateTreeIndex: number;
95
+ };
96
+ remainingAccountMetas: import("@solana/web3.js").AccountMeta[];
97
+ }>;
98
+ //# sourceMappingURL=light.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../src/light.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAGL,kCAAkC,EAGlC,GAAG,EAIJ,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,wBAAgB,YAAY,SAG3B;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,oBAAoB,EAAE,SAAS,EAC/B,cAAc,GAAE;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;CAClB,EAAO;;;;;;;;;;;GAwCT;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,kCAAkC,EACrD,gBAAgB,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;GAkE5B;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,kCAAkC;;;;;;;;;;;;;;;GAwCtD;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,kCAAkC;;;;;;;;;;;;;;;;GA+C7C"}
package/dist/light.js ADDED
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.forceLightV2 = forceLightV2;
4
+ exports.buildCreateContext = buildCreateContext;
5
+ exports.buildCommitProofContext = buildCommitProofContext;
6
+ exports.buildReadOnlyAuthorityContext = buildReadOnlyAuthorityContext;
7
+ exports.buildMutateContext = buildMutateContext;
8
+ const web3_js_1 = require("@solana/web3.js");
9
+ const stateless_js_1 = require("@lightprotocol/stateless.js");
10
+ /**
11
+ * Force the SDK into V2 mode so our address derivations + state-tree usage
12
+ * match the on-chain program's ADDRESS_TREE_V2 expectation.
13
+ */
14
+ function forceLightV2() {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ stateless_js_1.featureFlags.version = stateless_js_1.VERSION.V2;
17
+ }
18
+ /**
19
+ * For CREATE flows (init_authority, commit_proof): builds the validity-proof
20
+ * bundle + packed remaining-accounts list needed to mint a new compressed
21
+ * PDA at the given address.
22
+ */
23
+ async function buildCreateContext(rpc, programId, newCompressedAddress, existingInputs = []) {
24
+ forceLightV2();
25
+ const addressTree = new web3_js_1.PublicKey(stateless_js_1.batchAddressTree);
26
+ const proofRes = await rpc.getValidityProofV0(existingInputs.map((i) => ({
27
+ hash: (0, stateless_js_1.bn)(i.hash),
28
+ tree: i.tree,
29
+ queue: i.queue,
30
+ })), [
31
+ {
32
+ tree: addressTree,
33
+ queue: addressTree,
34
+ address: (0, stateless_js_1.bn)(newCompressedAddress.toBytes()),
35
+ },
36
+ ]);
37
+ const stateTreeInfos = await rpc.getStateTreeInfos();
38
+ const stateTreeInfo = (0, stateless_js_1.selectStateTreeInfo)(stateTreeInfos);
39
+ const systemAccountConfig = stateless_js_1.SystemAccountMetaConfig.new(programId);
40
+ const remainingAccounts = stateless_js_1.PackedAccounts.newWithSystemAccountsV2(systemAccountConfig);
41
+ const addressMtIdx = remainingAccounts.insertOrGet(addressTree);
42
+ const outputStIdx = remainingAccounts.insertOrGet(stateTreeInfo.queue);
43
+ const packedAddressTreeInfo = {
44
+ rootIndex: proofRes.rootIndices[proofRes.rootIndices.length - 1],
45
+ addressMerkleTreePubkeyIndex: addressMtIdx,
46
+ addressQueuePubkeyIndex: addressMtIdx,
47
+ };
48
+ return {
49
+ proof: { 0: proofRes.compressedProof },
50
+ packedAddressTreeInfo,
51
+ outputStateTreeIndex: outputStIdx,
52
+ remainingAccountMetas: remainingAccounts.toAccountMetas().remainingAccounts,
53
+ };
54
+ }
55
+ /**
56
+ * For commit_proof specifically: one input (the existing authority, treated
57
+ * as read-only on chain) + one new address (the commit). Both indices come
58
+ * from the same getValidityProofV0 call so they reference the same proof
59
+ * and the same packed-accounts list.
60
+ */
61
+ async function buildCommitProofContext(rpc, programId, authorityExisting, newCommitAddress) {
62
+ forceLightV2();
63
+ const addressTree = new web3_js_1.PublicKey(stateless_js_1.batchAddressTree);
64
+ const proofRes = await rpc.getValidityProofV0([
65
+ {
66
+ hash: authorityExisting.hash,
67
+ tree: authorityExisting.treeInfo.tree,
68
+ queue: authorityExisting.treeInfo.queue,
69
+ },
70
+ ], [
71
+ {
72
+ tree: addressTree,
73
+ queue: addressTree,
74
+ address: (0, stateless_js_1.bn)(newCommitAddress.toBytes()),
75
+ },
76
+ ]);
77
+ const stateTreeInfos = await rpc.getStateTreeInfos();
78
+ const stateTreeInfo = (0, stateless_js_1.selectStateTreeInfo)(stateTreeInfos);
79
+ const systemAccountConfig = stateless_js_1.SystemAccountMetaConfig.new(programId);
80
+ const remainingAccounts = stateless_js_1.PackedAccounts.newWithSystemAccountsV2(systemAccountConfig);
81
+ // Order matters: insert in the order the program will reference them via
82
+ // packed indices. Both the authority's tree and the address tree are
83
+ // shared in V2 (batched merkle tree), but we still pack the auth's tree
84
+ // first since the authority meta is constructed first below.
85
+ const authMerkleTreePubkeyIndex = remainingAccounts.insertOrGet(authorityExisting.treeInfo.tree);
86
+ const authQueuePubkeyIndex = remainingAccounts.insertOrGet(authorityExisting.treeInfo.queue);
87
+ const addressMtIdx = remainingAccounts.insertOrGet(addressTree);
88
+ const outputStIdx = remainingAccounts.insertOrGet(stateTreeInfo.queue);
89
+ const authorityReadOnlyMeta = {
90
+ treeInfo: {
91
+ rootIndex: proofRes.rootIndices[0],
92
+ proveByIndex: true,
93
+ merkleTreePubkeyIndex: authMerkleTreePubkeyIndex,
94
+ queuePubkeyIndex: authQueuePubkeyIndex,
95
+ leafIndex: authorityExisting.leafIndex,
96
+ },
97
+ address: authorityExisting.address,
98
+ };
99
+ const packedAddressTreeInfo = {
100
+ rootIndex: proofRes.rootIndices[proofRes.rootIndices.length - 1],
101
+ addressMerkleTreePubkeyIndex: addressMtIdx,
102
+ addressQueuePubkeyIndex: addressMtIdx,
103
+ };
104
+ return {
105
+ proof: { 0: proofRes.compressedProof },
106
+ authorityReadOnlyMeta,
107
+ packedAddressTreeInfo,
108
+ outputStateTreeIndex: outputStIdx,
109
+ remainingAccountMetas: remainingAccounts.toAccountMetas().remainingAccounts,
110
+ };
111
+ }
112
+ /**
113
+ * For event-mode commits: builds a validity-proof bundle for an existing
114
+ * authority treated as read-only. No new compressed address is created.
115
+ */
116
+ async function buildReadOnlyAuthorityContext(rpc, programId, authorityExisting) {
117
+ forceLightV2();
118
+ const proofRes = await rpc.getValidityProofV0([
119
+ {
120
+ hash: authorityExisting.hash,
121
+ tree: authorityExisting.treeInfo.tree,
122
+ queue: authorityExisting.treeInfo.queue,
123
+ },
124
+ ], []);
125
+ const systemAccountConfig = stateless_js_1.SystemAccountMetaConfig.new(programId);
126
+ const remainingAccounts = stateless_js_1.PackedAccounts.newWithSystemAccountsV2(systemAccountConfig);
127
+ const authMerkleTreePubkeyIndex = remainingAccounts.insertOrGet(authorityExisting.treeInfo.tree);
128
+ const authQueuePubkeyIndex = remainingAccounts.insertOrGet(authorityExisting.treeInfo.queue);
129
+ const authorityReadOnlyMeta = {
130
+ treeInfo: {
131
+ rootIndex: proofRes.rootIndices[0],
132
+ proveByIndex: true,
133
+ merkleTreePubkeyIndex: authMerkleTreePubkeyIndex,
134
+ queuePubkeyIndex: authQueuePubkeyIndex,
135
+ leafIndex: authorityExisting.leafIndex,
136
+ },
137
+ address: authorityExisting.address,
138
+ };
139
+ return {
140
+ proof: { 0: proofRes.compressedProof },
141
+ authorityReadOnlyMeta,
142
+ remainingAccountMetas: remainingAccounts.toAccountMetas().remainingAccounts,
143
+ };
144
+ }
145
+ /**
146
+ * For MUTATE flows (freeze_authority, revoke_authority): builds the
147
+ * validity-proof bundle + account meta for an existing compressed PDA.
148
+ */
149
+ async function buildMutateContext(rpc, programId, existing) {
150
+ forceLightV2();
151
+ const proofRes = await rpc.getValidityProofV0([
152
+ {
153
+ hash: existing.hash,
154
+ tree: existing.treeInfo.tree,
155
+ queue: existing.treeInfo.queue,
156
+ },
157
+ ], []);
158
+ const stateTreeInfos = await rpc.getStateTreeInfos();
159
+ const stateTreeInfo = (0, stateless_js_1.selectStateTreeInfo)(stateTreeInfos);
160
+ const systemAccountConfig = stateless_js_1.SystemAccountMetaConfig.new(programId);
161
+ const remainingAccounts = stateless_js_1.PackedAccounts.newWithSystemAccountsV2(systemAccountConfig);
162
+ const merkleTreePubkeyIndex = remainingAccounts.insertOrGet(existing.treeInfo.tree);
163
+ const queuePubkeyIndex = remainingAccounts.insertOrGet(existing.treeInfo.queue);
164
+ const outputStateTreeIndex = remainingAccounts.insertOrGet(stateTreeInfo.queue);
165
+ const accountMeta = {
166
+ treeInfo: {
167
+ rootIndex: proofRes.rootIndices[0],
168
+ proveByIndex: true,
169
+ merkleTreePubkeyIndex,
170
+ queuePubkeyIndex,
171
+ leafIndex: existing.leafIndex,
172
+ },
173
+ address: existing.address,
174
+ outputStateTreeIndex,
175
+ };
176
+ return {
177
+ proof: { 0: proofRes.compressedProof },
178
+ accountMeta,
179
+ remainingAccountMetas: remainingAccounts.toAccountMetas().remainingAccounts,
180
+ };
181
+ }
182
+ //# sourceMappingURL=light.js.map
@@ -0,0 +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,kBAAkB,CACtC,GAAQ,EACR,SAAoB,EACpB,oBAA+B,EAC/B,iBAIM,EAAE;IAER,YAAY,E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,mBAAmB,CAAC,CAAC;IAC9D,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,WAAW,CACzD,QAAQ,CAAC,QAAQ,CAAC,IAAI,CACvB,CAAC;IACF,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,WAAW,CACpD,QAAQ,CAAC,QAAQ,CAAC,KAAK,CACxB,CAAC;IACF,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,WAAW,CACxD,aAAa,CAAC,KAAK,CACpB,CAAC;IAEF,MAAM,WAAW,GAAG;QAClB,QAAQ,EAAE;YACR,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;YAClC,YAAY,EAAE,IAAI;YAClB,qBAAqB;YACrB,gBAAgB;YAChB,SAAS,EAAE,QAAQ,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"}
@@ -0,0 +1,172 @@
1
+ import * as anchor from "@coral-xyz/anchor";
2
+ import { Program } from "@coral-xyz/anchor";
3
+ import { Connection, PublicKey, Transaction, TransactionInstruction } from "@solana/web3.js";
4
+ import { CompressedAccountWithMerkleContext, Rpc } from "@lightprotocol/stateless.js";
5
+ import { OnChainAuthority, OnChainCommit } from "./verifyEndToEnd";
6
+ /**
7
+ * Decode a VrfAuthority record from a fetched compressed-account row.
8
+ * Wraps the Anchor coder so callers can stay in terms of typed fields.
9
+ */
10
+ export declare function decodeAuthority(program: Program, dataBytes: Uint8Array): {
11
+ owner: PublicKey;
12
+ pk: number[];
13
+ suite: number;
14
+ frozen: boolean;
15
+ revoked: boolean;
16
+ label: number[];
17
+ createdSlot: anchor.BN;
18
+ };
19
+ export declare function decodeProofCommit(program: Program, dataBytes: Uint8Array): {
20
+ authority: PublicKey;
21
+ memoHash: number[];
22
+ proofHash: number[];
23
+ alphaHash: number[];
24
+ committedSlot: anchor.BN;
25
+ };
26
+ export declare function decodeProofCommitWithBeta(program: Program, dataBytes: Uint8Array): {
27
+ authority: PublicKey;
28
+ memoHash: number[];
29
+ proofHash: number[];
30
+ alphaHash: number[];
31
+ betaLo: number[];
32
+ betaHi: number[];
33
+ committedSlot: anchor.BN;
34
+ };
35
+ /**
36
+ * Fetch a VrfAuthority compressed account by (owner, label). Returns null
37
+ * if no such authority exists.
38
+ */
39
+ export declare function fetchAuthority(program: Program, rpc: Rpc, owner: PublicKey, label: string | Uint8Array): Promise<{
40
+ authorityAddress: PublicKey;
41
+ account: CompressedAccountWithMerkleContext;
42
+ decoded: ReturnType<typeof decodeAuthority>;
43
+ onChainAuthority: OnChainAuthority;
44
+ } | null>;
45
+ /**
46
+ * Fetch a VrfProofCommit by (authority, memo). Returns null if no such
47
+ * commit exists yet.
48
+ */
49
+ export declare function fetchProofCommit(program: Program, rpc: Rpc, authority: PublicKey, memo: string | Uint8Array): Promise<{
50
+ commitAddress: PublicKey;
51
+ account: CompressedAccountWithMerkleContext;
52
+ decoded: ReturnType<typeof decodeProofCommit>;
53
+ onChainCommit: OnChainCommit;
54
+ } | null>;
55
+ export interface InitAuthorityInput {
56
+ owner: PublicKey;
57
+ pk: Uint8Array;
58
+ suite: number;
59
+ label: string | Uint8Array;
60
+ }
61
+ /**
62
+ * Build the init_authority instruction. Caller is responsible for adding it
63
+ * to a transaction with the owner as signer and submitting it.
64
+ */
65
+ export declare function buildInitAuthorityIx(program: Program, rpc: Rpc, input: InitAuthorityInput): Promise<{
66
+ ix: TransactionInstruction;
67
+ authorityAddress: PublicKey;
68
+ }>;
69
+ export interface FreezeAuthorityInput {
70
+ owner: PublicKey;
71
+ label: string | Uint8Array;
72
+ }
73
+ export declare function buildFreezeAuthorityIx(program: Program, rpc: Rpc, input: FreezeAuthorityInput): Promise<TransactionInstruction>;
74
+ export declare function buildRevokeAuthorityIx(program: Program, rpc: Rpc, input: FreezeAuthorityInput): Promise<TransactionInstruction>;
75
+ export interface CommitProofInput {
76
+ owner: PublicKey;
77
+ label: string | Uint8Array;
78
+ memo: string | Uint8Array;
79
+ alpha: Uint8Array;
80
+ proof: Uint8Array;
81
+ }
82
+ /**
83
+ * Build the commit_proof instruction. The authority is looked up via
84
+ * (owner, label) — must already exist on chain. memo/alpha/proof are hashed
85
+ * via SHA-256 and stored in the new VrfProofCommit PDA.
86
+ */
87
+ export declare function buildCommitProofIx(program: Program, rpc: Rpc, input: CommitProofInput): Promise<{
88
+ ix: TransactionInstruction;
89
+ commitAddress: PublicKey;
90
+ }>;
91
+ /**
92
+ * Build the commit_proof_event instruction (event mode). Proves the authority
93
+ * read-only, requires it to be frozen and unrevoked, and emits a Solana log
94
+ * event rather than writing a compressed PDA.
95
+ *
96
+ * The trade-off is that the chain doesn't enforce one-commit-per-memo;
97
+ * verifiers must scan for duplicate `memo_hash` events and pick the one where
98
+ * ECVRF math passes.
99
+ */
100
+ export declare function buildCommitProofEventIx(program: Program, rpc: Rpc, input: CommitProofInput): Promise<TransactionInstruction>;
101
+ /**
102
+ * One row decoded from a `VrfProofCommitted` log event. `txSignature` is the
103
+ * Solana tx the event was emitted in; `slot` is the slot that tx confirmed in.
104
+ *
105
+ * `onChainCommit` is the same shape the verifier helpers expect, so the same
106
+ * verification path works for PDA-mode and event-mode commits.
107
+ */
108
+ export interface ProofCommitEvent {
109
+ owner: PublicKey;
110
+ label: Uint8Array;
111
+ txSignature: string;
112
+ slot: number;
113
+ onChainCommit: OnChainCommit;
114
+ }
115
+ /**
116
+ * Fetch all `VrfProofCommitted` events emitted for a given `(owner, label,
117
+ * memo)` tuple, ordered oldest → newest. Returns an empty array if none
118
+ * exist.
119
+ *
120
+ * IMPORTANT: this can return MORE than one row. The on-chain program does
121
+ * not enforce uniqueness in event mode. A safe verifier:
122
+ *
123
+ * 1. Collects all matches for the requested memo.
124
+ * 2. Runs `verifyAuthorityCommitEndToEnd` against each candidate proof.
125
+ * 3. Accepts the unique row where the ECVRF math passes.
126
+ *
127
+ * Because ECVRF proofs are deterministic for a fixed (pk, alpha), at most
128
+ * one of the candidates can have a valid `proof_hash`. The presence of extra
129
+ * events is detectable noise, not a successful forgery — but a naive verifier
130
+ * that picks "the latest event" without running ECVRF can be misled, which is
131
+ * the only soundness gap relative to the PDA path.
132
+ *
133
+ * `connection` and `programId` are passed in explicitly so log scanning works
134
+ * against a plain Solana RPC. Fetching compressed authority state still needs
135
+ * a Photon-capable RPC unless the verifier already has that state.
136
+ *
137
+ * `limit` caps how many recent signatures to scan (default 1000); pagination
138
+ * happens automatically via `getSignaturesForAddress`'s `before` cursor.
139
+ */
140
+ export declare function fetchProofCommitEvents(program: Program, connection: Connection, owner: PublicKey, label: string | Uint8Array, memo: string | Uint8Array, options?: {
141
+ limit?: number;
142
+ }): Promise<ProofCommitEvent[]>;
143
+ /**
144
+ * Build the commit_proof_with_beta instruction (PDA mode + on-chain beta).
145
+ * Like buildCommitProofIx, but additionally stores the 64-byte ECVRF beta
146
+ * (output of vrfProofToHash) in the new compressed PDA so other Solana
147
+ * programs can read it via a Light SDK CPI.
148
+ *
149
+ * Stored at the same seed prefix as regular commits, so one authority+memo can
150
+ * only use one registry mode.
151
+ */
152
+ export declare function buildCommitProofWithBetaIx(program: Program, rpc: Rpc, input: CommitProofInput & {
153
+ beta: Uint8Array;
154
+ }): Promise<{
155
+ ix: TransactionInstruction;
156
+ commitAddress: PublicKey;
157
+ }>;
158
+ /**
159
+ * Fetch a VrfProofCommitWithBeta by (authority, memo). Returns null if no such
160
+ * commit exists yet. Reassembles the 64-byte beta from its two on-chain halves.
161
+ */
162
+ export declare function fetchProofCommitWithBeta(program: Program, rpc: Rpc, authority: PublicKey, memo: string | Uint8Array): Promise<{
163
+ commitAddress: PublicKey;
164
+ account: CompressedAccountWithMerkleContext;
165
+ decoded: ReturnType<typeof decodeProofCommitWithBeta>;
166
+ onChainCommit: OnChainCommit;
167
+ /** Full 64-byte beta, reassembled from beta_lo + beta_hi. */
168
+ beta: Uint8Array;
169
+ } | null>;
170
+ /** Convenience: wrap a single ix into a Transaction. */
171
+ export declare function asTx(ix: TransactionInstruction): Transaction;
172
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAA2B,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,kCAAkC,EAClC,GAAG,EACJ,MAAM,6BAA6B,CAAC;AAoBrC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,GAMhE;IACH,KAAK,EAAE,SAAS,CAAC;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC;CACxB,CACF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,GAKlE;IACH,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC,EAAE,CAAC;CAC1B,CACF;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE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