@utxopia/sdk 0.1.0-alpha.3 → 0.1.0-alpha.5
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/dist/bitcoin/ika.d.ts +4 -3
- package/dist/bitcoin/ika.js +4 -7
- package/dist/client.d.ts +3 -3
- package/dist/crypto-babyjub.d.ts +0 -4
- package/dist/crypto-babyjub.js +0 -4
- package/dist/crypto.d.ts +2 -5
- package/dist/crypto.js +5 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/instructions.d.ts +0 -113
- package/dist/instructions.js +0 -127
- package/dist/poseidon.d.ts +0 -4
- package/dist/poseidon.js +0 -8
- package/dist/prover/index.d.ts +0 -1
- package/dist/prover/web.d.ts +0 -15
- package/dist/prover/web.js +2 -49
- package/dist/psbt.d.ts +14 -3
- package/dist/psbt.js +23 -14
- package/dist/spend-doc.js +1 -1
- package/dist/stealth.d.ts +6 -12
- package/dist/stealth.js +0 -14
- package/dist/taproot.d.ts +32 -4
- package/dist/taproot.js +54 -32
- package/package.json +1 -32
- package/src/bitcoin/ika.ts +6 -11
- package/src/client.ts +4 -4
- package/src/crypto-babyjub.ts +0 -5
- package/src/crypto.ts +5 -24
- package/src/index.ts +4 -0
- package/src/instructions.ts +0 -214
- package/src/poseidon.ts +0 -9
- package/src/prover/index.ts +0 -8
- package/src/prover/web.ts +3 -72
- package/src/psbt.ts +32 -15
- package/src/spend-doc.ts +1 -2
- package/src/stealth.ts +7 -23
- package/src/taproot.ts +74 -39
package/dist/bitcoin/ika.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* key that Ika can sign for. Ika pre-alpha signs for the raw x-only key; it
|
|
7
7
|
* does not currently produce signatures for UTXOpia's per-deposit tweaked keys.
|
|
8
8
|
*/
|
|
9
|
+
import { type BitcoinNetwork } from "../taproot";
|
|
9
10
|
/**
|
|
10
11
|
* Reference to an Ika dWallet for address derivation.
|
|
11
12
|
*
|
|
@@ -33,10 +34,10 @@ export type IkaDWalletRef = {
|
|
|
33
34
|
* address = bech32m(hrp, [witness_version=1, ...words(output_key)])
|
|
34
35
|
*
|
|
35
36
|
* @param ref The Ika dWallet reference (literal pubkey, or future async id).
|
|
36
|
-
* @param network
|
|
37
|
+
* @param network BitcoinNetwork
|
|
37
38
|
* @returns The P2TR address (`bc1p…` / `tb1p…` / `bcrt1p…`)
|
|
38
39
|
*/
|
|
39
|
-
export declare function deriveCustodyAddressFromIkaDWallet(ref: IkaDWalletRef, network:
|
|
40
|
+
export declare function deriveCustodyAddressFromIkaDWallet(ref: IkaDWalletRef, network: BitcoinNetwork): string;
|
|
40
41
|
/**
|
|
41
42
|
* Encode a raw x-only public key as a P2TR witness program.
|
|
42
43
|
*
|
|
@@ -44,4 +45,4 @@ export declare function deriveCustodyAddressFromIkaDWallet(ref: IkaDWalletRef, n
|
|
|
44
45
|
* direct-vault address used by the current Ika pre-alpha mock signer, because
|
|
45
46
|
* the signer returns Schnorr signatures for the dWallet's raw x-only key.
|
|
46
47
|
*/
|
|
47
|
-
export declare function deriveRawXOnlyP2TRAddress(xonlyPubkey: Uint8Array, network:
|
|
48
|
+
export declare function deriveRawXOnlyP2TRAddress(xonlyPubkey: Uint8Array, network: BitcoinNetwork): string;
|
package/dist/bitcoin/ika.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* does not currently produce signatures for UTXOpia's per-deposit tweaked keys.
|
|
8
8
|
*/
|
|
9
9
|
import { taggedHash, hexToBytes, bytesToHex } from "../crypto";
|
|
10
|
-
import {
|
|
10
|
+
import { p2trAddress } from "../taproot";
|
|
11
11
|
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
12
12
|
/**
|
|
13
13
|
* Derive the BIP-341 P2TR (key-path-only) address controlled by an Ika dWallet.
|
|
@@ -19,7 +19,7 @@ import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
|
19
19
|
* address = bech32m(hrp, [witness_version=1, ...words(output_key)])
|
|
20
20
|
*
|
|
21
21
|
* @param ref The Ika dWallet reference (literal pubkey, or future async id).
|
|
22
|
-
* @param network
|
|
22
|
+
* @param network BitcoinNetwork
|
|
23
23
|
* @returns The P2TR address (`bc1p…` / `tb1p…` / `bcrt1p…`)
|
|
24
24
|
*/
|
|
25
25
|
export function deriveCustodyAddressFromIkaDWallet(ref, network) {
|
|
@@ -32,9 +32,7 @@ export function deriveCustodyAddressFromIkaDWallet(ref, network) {
|
|
|
32
32
|
const outputPoint = internalPoint.add(tweakPoint);
|
|
33
33
|
// Drop the 1-byte parity prefix to get the x-only output key.
|
|
34
34
|
const outputKey = hexToBytes(outputPoint.toHex(true).slice(2));
|
|
35
|
-
|
|
36
|
-
const words = bech32m.toWords(outputKey);
|
|
37
|
-
return bech32m.encode(hrp, [1, ...words]);
|
|
35
|
+
return p2trAddress(outputKey, network);
|
|
38
36
|
}
|
|
39
37
|
/**
|
|
40
38
|
* Encode a raw x-only public key as a P2TR witness program.
|
|
@@ -47,8 +45,7 @@ export function deriveRawXOnlyP2TRAddress(xonlyPubkey, network) {
|
|
|
47
45
|
if (xonlyPubkey.length !== 32) {
|
|
48
46
|
throw new Error("xonlyPubkey must be 32 bytes");
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
return bech32m.encode(hrp, [1, ...bech32m.toWords(xonlyPubkey)]);
|
|
48
|
+
return p2trAddress(xonlyPubkey, network);
|
|
52
49
|
}
|
|
53
50
|
function extractXOnly(ref) {
|
|
54
51
|
if (ref.type === "literal-xonly") {
|
package/dist/client.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { type NetworkConfig, type NetworkId } from "./config";
|
|
|
20
20
|
import { type AuthSignatureKeyDerivationOptions, type UTXOpiaKeys, type StealthMetaAddress, type WalletSignerAdapter, type KeySetupResult } from "./keys";
|
|
21
21
|
import { type ViewOnlyKeys, type StealthOutputWithKeys, type NonInteractiveDepositResult, type TweakDepositResult } from "./stealth";
|
|
22
22
|
import { type UtxoDescriptor } from "./psbt";
|
|
23
|
-
import { type DepositOpReturnContext } from "./taproot";
|
|
23
|
+
import { type DepositOpReturnContext, type BitcoinNetwork } from "./taproot";
|
|
24
24
|
export interface UTXOpiaClientConfig {
|
|
25
25
|
network?: NetworkId;
|
|
26
26
|
/** Override backend URL (default: from network config) */
|
|
@@ -159,7 +159,7 @@ export declare class UTXOpiaClient {
|
|
|
159
159
|
depositIndex: number;
|
|
160
160
|
ikaXOnlyPubkey: Uint8Array;
|
|
161
161
|
recipient?: StealthMetaAddress;
|
|
162
|
-
network?:
|
|
162
|
+
network?: BitcoinNetwork;
|
|
163
163
|
}): Promise<TweakDepositResult>;
|
|
164
164
|
/**
|
|
165
165
|
* Prepare a BTC deposit: generate stealth deposit address + OP_RETURN.
|
|
@@ -167,7 +167,7 @@ export declare class UTXOpiaClient {
|
|
|
167
167
|
*/
|
|
168
168
|
prepareDeposit(opts: {
|
|
169
169
|
recipient?: StealthMetaAddress;
|
|
170
|
-
network?:
|
|
170
|
+
network?: BitcoinNetwork;
|
|
171
171
|
opReturnContext: DepositOpReturnContext;
|
|
172
172
|
}): Promise<NonInteractiveDepositResult>;
|
|
173
173
|
/**
|
package/dist/crypto-babyjub.d.ts
CHANGED
|
@@ -22,10 +22,6 @@ export declare const BABYJUB_D = 168696n;
|
|
|
22
22
|
* = field_prime / 8 (cofactor 8)
|
|
23
23
|
*/
|
|
24
24
|
export declare const BABYJUB_ORDER = 2736030358979909402780800718157159386076813972158567259200215660948447373041n;
|
|
25
|
-
/**
|
|
26
|
-
* Baby Jubjub cofactor
|
|
27
|
-
*/
|
|
28
|
-
export declare const BABYJUB_COFACTOR = 8n;
|
|
29
25
|
/**
|
|
30
26
|
* Generator point (BASE8) - matches circomlib's BabyPbk() generator
|
|
31
27
|
* This is the base point of the prime-order subgroup (cofactor-cleared).
|
package/dist/crypto-babyjub.js
CHANGED
|
@@ -26,10 +26,6 @@ export const BABYJUB_D = 168696n;
|
|
|
26
26
|
* = field_prime / 8 (cofactor 8)
|
|
27
27
|
*/
|
|
28
28
|
export const BABYJUB_ORDER = 2736030358979909402780800718157159386076813972158567259200215660948447373041n;
|
|
29
|
-
/**
|
|
30
|
-
* Baby Jubjub cofactor
|
|
31
|
-
*/
|
|
32
|
-
export const BABYJUB_COFACTOR = 8n;
|
|
33
29
|
/**
|
|
34
30
|
* Generator point (BASE8) - matches circomlib's BabyPbk() generator
|
|
35
31
|
* This is the base point of the prime-order subgroup (cofactor-cleared).
|
package/dist/crypto.d.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module crypto
|
|
14
14
|
*/
|
|
15
|
+
import { bytesToHex as nobleBytesToHex } from "@noble/hashes/utils.js";
|
|
15
16
|
/** BN254 field prime (used by circom/snarkjs, also Baby Jubjub base field) */
|
|
16
17
|
export declare const BN254_FIELD_PRIME = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
17
18
|
export { BABYJUB_FIELD_PRIME, BABYJUB_A, BABYJUB_D, BABYJUB_ORDER, BABYJUB_BASE8, BABYJUB_IDENTITY, babyJubAdd, babyJubDouble, babyJubMul, babyJubNegate, isOnBabyJubCurve, isIdentity, babyJubCompress, babyJubDecompress, generateBabyJubKeyPair, deriveBabyJubKeyFromSeed, babyJubScalarFromBytes, babyJubScalarToBytes, type BabyJubPoint, } from "./crypto-babyjub";
|
|
@@ -35,7 +36,7 @@ export declare function hexToBytes(hex: string): Uint8Array;
|
|
|
35
36
|
/**
|
|
36
37
|
* Convert Uint8Array to hex string
|
|
37
38
|
*/
|
|
38
|
-
export declare
|
|
39
|
+
export declare const bytesToHex: typeof nobleBytesToHex;
|
|
39
40
|
/**
|
|
40
41
|
* SHA-256 hash using @noble/hashes
|
|
41
42
|
*/
|
|
@@ -53,7 +54,3 @@ export declare function taggedHash(tag: string, data: Uint8Array): Uint8Array;
|
|
|
53
54
|
* Derive a scalar from bytes (reduces modulo Baby Jubjub subgroup order)
|
|
54
55
|
*/
|
|
55
56
|
export declare function scalarFromBytes(bytes: Uint8Array): bigint;
|
|
56
|
-
/**
|
|
57
|
-
* Convert a bigint scalar to 32 bytes (big-endian)
|
|
58
|
-
*/
|
|
59
|
-
export declare function scalarToBytes(scalar: bigint): Uint8Array;
|
package/dist/crypto.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @module crypto
|
|
14
14
|
*/
|
|
15
15
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
16
|
+
import { bytesToHex as nobleBytesToHex, hexToBytes as nobleHexToBytes } from "@noble/hashes/utils.js";
|
|
16
17
|
// =============================================================================
|
|
17
18
|
// Field Constants
|
|
18
19
|
// =============================================================================
|
|
@@ -63,21 +64,14 @@ export function bytesToBigint(bytes) {
|
|
|
63
64
|
* Convert hex string to Uint8Array
|
|
64
65
|
*/
|
|
65
66
|
export function hexToBytes(hex) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
bytes[i / 2] = parseInt(cleanHex.substr(i, 2), 16);
|
|
70
|
-
}
|
|
71
|
-
return bytes;
|
|
67
|
+
// The 0x prefix is ours; noble rejects it. Everything after is noble's, which
|
|
68
|
+
// also means malformed hex now throws instead of decoding to zero bytes.
|
|
69
|
+
return nobleHexToBytes(hex.startsWith("0x") ? hex.slice(2) : hex);
|
|
72
70
|
}
|
|
73
71
|
/**
|
|
74
72
|
* Convert Uint8Array to hex string
|
|
75
73
|
*/
|
|
76
|
-
export
|
|
77
|
-
return Array.from(bytes)
|
|
78
|
-
.map((b) => b.toString(16).padStart(2, "0"))
|
|
79
|
-
.join("");
|
|
80
|
-
}
|
|
74
|
+
export const bytesToHex = nobleBytesToHex;
|
|
81
75
|
// =============================================================================
|
|
82
76
|
// Hashing Utilities
|
|
83
77
|
// =============================================================================
|
|
@@ -126,15 +120,3 @@ export function scalarFromBytes(bytes) {
|
|
|
126
120
|
}
|
|
127
121
|
return mod(result, BABYJUB_ORDER);
|
|
128
122
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Convert a bigint scalar to 32 bytes (big-endian)
|
|
131
|
-
*/
|
|
132
|
-
export function scalarToBytes(scalar) {
|
|
133
|
-
const bytes = new Uint8Array(32);
|
|
134
|
-
let temp = mod(scalar, BABYJUB_ORDER);
|
|
135
|
-
for (let i = 31; i >= 0; i--) {
|
|
136
|
-
bytes[i] = Number(temp & 0xffn);
|
|
137
|
-
temp = temp >> 8n;
|
|
138
|
-
}
|
|
139
|
-
return bytes;
|
|
140
|
-
}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export { fetchTokenConfig, getTokenId, fetchSupportedTokens, fetchEnabledTokens,
|
|
|
34
34
|
export { MAGICBLOCK_DELEGATION_PROGRAM_ID, MAGICBLOCK_DEVNET_ROUTER_URL, MAGICBLOCK_DEVNET_ROUTER_WS_URL, MAGICBLOCK_EPHEMERAL_VAULT_ID, MAGICBLOCK_MAGIC_CONTEXT_ID, MAGICBLOCK_MAGIC_PROGRAM_ID, MAGICBLOCK_MAX_PER_MEMBERS, MAGICBLOCK_PERMISSION_PROGRAM_ID, MAGICBLOCK_PER_MEMBER_FLAGS, MAGICBLOCK_VALIDATOR_IDENTITIES, buildDefaultPrivacyDomain, buildMagicBlockPerMemberFlags, deriveMagicBlockCommitRecordPDA, deriveMagicBlockCommitStatePDA, deriveMagicBlockDelegateBufferPDA, deriveMagicBlockDelegationMetadataPDA, deriveMagicBlockDelegationRecordPDA, deriveMagicBlockPermissionPDA, deriveMagicBlockUndelegateBufferPDA, requiresMagicBlockEndpoint, getMagicBlockEndpoint, getMagicBlockValidatorIdentity, createMagicBlockRouterConnection, type BuildPrivacyDomainOptions, type MagicBlockEndpointConfig, type MagicBlockExecutionMode, type MagicBlockPolicyMode, type MagicBlockPerMemberFlagName, type MagicBlockValidatorRegion, type PrivacyDomainConfig, type PrivacyDomainKind, } from "./magicblock";
|
|
35
35
|
export { generateNote, createNoteFromSecrets, serializeNote, deserializeNote, noteHasComputedHashes, getNotePublicKeyX, computeNoteCommitment, computeNoteNullifier, formatBtc, parseBtc, deriveNote, deriveNotes, deriveMasterKey, deriveNoteFromMaster, estimateSeedStrength, createNote, prepareWithdrawal, createStealthNote, serializeStealthNote, deserializeStealthNote, type Note, type SerializedNote, type NoteData, type StealthNote, type SerializedStealthNote, createJoinSplitNote, computeJoinSplitNoteNullifier, serializeJoinSplitNote, deserializeJoinSplitNote, type JoinSplitNote, type SerializedJoinSplitNote, } from "./note";
|
|
36
36
|
export { createMerkleProof, createMerkleProofFromBigints, proofToCircomFormat, proofToOnChainFormat, createEmptyMerkleProof, leafIndexToPathIndices, pathIndicesToLeafIndex, validateMerkleProofStructure, parseMerkleProofResponse, TREE_DEPTH, ROOT_HISTORY_SIZE, MAX_LEAVES, ZERO_VALUE, type MerkleProof, } from "./merkle";
|
|
37
|
-
export { deriveTaprootAddress, deriveTaprootAddressWithRefund, depositTweakCommitment, deriveDepositAddress, depositLeafScript, DEPOSIT_NUMS_INTERNAL_KEY, buildRefundScript, computeTapLeafHash, verifyTaprootAddress, createP2TRScriptPubkey, parseP2TRScriptPubkey, isValidBitcoinAddress, getInternalKey, createCustomInternalKey, createOpReturnScriptFromPayload, buildDepositOpReturn, parseDepositOpReturn, encodeDepositOpReturnHeader, decodeDepositOpReturnHeader, validateDepositOpReturnContext, computeDepositPoolTag, DEPOSIT_DESTINATION_CHAIN, DEPOSIT_BITCOIN_NETWORK, DEPOSIT_OP_RETURN_VERSION, DEPOSIT_POOL_TAG_SIZE, DEPOSIT_OP_RETURN_SIZE, type DepositDestinationChain, type DepositBitcoinNetwork, type DepositOpReturnContext, type ParsedDepositOpReturn, } from "./taproot";
|
|
37
|
+
export { deriveTaprootAddress, deriveTaprootAddressWithRefund, depositTweakCommitment, deriveDepositAddress, depositLeafScript, DEPOSIT_NUMS_INTERNAL_KEY, buildRefundScript, computeTapLeafHash, verifyTaprootAddress, createP2TRScriptPubkey, parseP2TRScriptPubkey, isValidBitcoinAddress, getInternalKey, createCustomInternalKey, createOpReturnScriptFromPayload, buildDepositOpReturn, parseDepositOpReturn, encodeDepositOpReturnHeader, decodeDepositOpReturnHeader, validateDepositOpReturnContext, computeDepositPoolTag, DEPOSIT_DESTINATION_CHAIN, DEPOSIT_BITCOIN_NETWORK, DEPOSIT_OP_RETURN_VERSION, DEPOSIT_POOL_TAG_SIZE, DEPOSIT_OP_RETURN_SIZE, bech32Hrp, networkForHrp, p2trAddress, type BitcoinNetwork, type DepositDestinationChain, type DepositBitcoinNetwork, type DepositOpReturnContext, type ParsedDepositOpReturn, } from "./taproot";
|
|
38
38
|
export { encodeClaimLink, decodeClaimLink, parseClaimUrl, } from "./claim-link";
|
|
39
39
|
export type { ProofData, MerkleProofInput, CircuitType, JoinSplitProofInputs, } from "./prover/web";
|
|
40
40
|
export { uploadTransactionToBuffer, uploadProofToBuffer, closeBuffer, readBufferData, fetchRawTransaction, fetchMerkleProof, prepareVerifyDeposit, buildMerkleProof, needsBuffer as bufferNeedsBuffer, getProofSource, calculateUploadTransactions, CHADBUFFER_PROGRAM_ID, AUTHORITY_SIZE, MAX_DATA_PER_WRITE, SOLANA_TX_SIZE_LIMIT, type ProofUploadResult, } from "./chadbuffer";
|
package/dist/index.js
CHANGED
|
@@ -94,7 +94,7 @@ export { createMerkleProof, createMerkleProofFromBigints, proofToCircomFormat, p
|
|
|
94
94
|
// ==========================================================================
|
|
95
95
|
// Taproot address utilities
|
|
96
96
|
// ==========================================================================
|
|
97
|
-
export { deriveTaprootAddress, deriveTaprootAddressWithRefund, depositTweakCommitment, deriveDepositAddress, depositLeafScript, DEPOSIT_NUMS_INTERNAL_KEY, buildRefundScript, computeTapLeafHash, verifyTaprootAddress, createP2TRScriptPubkey, parseP2TRScriptPubkey, isValidBitcoinAddress, getInternalKey, createCustomInternalKey, createOpReturnScriptFromPayload, buildDepositOpReturn, parseDepositOpReturn, encodeDepositOpReturnHeader, decodeDepositOpReturnHeader, validateDepositOpReturnContext, computeDepositPoolTag, DEPOSIT_DESTINATION_CHAIN, DEPOSIT_BITCOIN_NETWORK, DEPOSIT_OP_RETURN_VERSION, DEPOSIT_POOL_TAG_SIZE, DEPOSIT_OP_RETURN_SIZE, } from "./taproot";
|
|
97
|
+
export { deriveTaprootAddress, deriveTaprootAddressWithRefund, depositTweakCommitment, deriveDepositAddress, depositLeafScript, DEPOSIT_NUMS_INTERNAL_KEY, buildRefundScript, computeTapLeafHash, verifyTaprootAddress, createP2TRScriptPubkey, parseP2TRScriptPubkey, isValidBitcoinAddress, getInternalKey, createCustomInternalKey, createOpReturnScriptFromPayload, buildDepositOpReturn, parseDepositOpReturn, encodeDepositOpReturnHeader, decodeDepositOpReturnHeader, validateDepositOpReturnContext, computeDepositPoolTag, DEPOSIT_DESTINATION_CHAIN, DEPOSIT_BITCOIN_NETWORK, DEPOSIT_OP_RETURN_VERSION, DEPOSIT_POOL_TAG_SIZE, DEPOSIT_OP_RETURN_SIZE, bech32Hrp, networkForHrp, p2trAddress, } from "./taproot";
|
|
98
98
|
// ==========================================================================
|
|
99
99
|
// Claim link utilities
|
|
100
100
|
// ==========================================================================
|
package/dist/instructions.d.ts
CHANGED
|
@@ -858,69 +858,6 @@ export declare function bigintTo32Bytes(value: bigint): Uint8Array;
|
|
|
858
858
|
*/
|
|
859
859
|
export declare function bytes32ToBigint(bytes: Uint8Array): bigint;
|
|
860
860
|
export { hexToBytes, bytesToHex } from "./crypto";
|
|
861
|
-
/** initializePermissioned instruction options */
|
|
862
|
-
export interface InitializePermissionedOptions {
|
|
863
|
-
/** PDA bump for pool state */
|
|
864
|
-
poolBump: number;
|
|
865
|
-
/** PDA bump for commitment tree */
|
|
866
|
-
treeBump: number;
|
|
867
|
-
/** Deposit fee in basis points (u16 LE) */
|
|
868
|
-
depositFeeBps: number;
|
|
869
|
-
/** Withdrawal fee in basis points (u16 LE) */
|
|
870
|
-
withdrawalFeeBps: number;
|
|
871
|
-
/** Auditor's Solana pubkey (32 bytes) */
|
|
872
|
-
auditor: Uint8Array;
|
|
873
|
-
/** Auditor's viewing public key (32 bytes) */
|
|
874
|
-
auditorViewingPubkey: Uint8Array;
|
|
875
|
-
/** Account addresses — same layout as initialize (disc=0) */
|
|
876
|
-
accounts: {
|
|
877
|
-
/** 0. pool_state (writable) */
|
|
878
|
-
poolState: Address;
|
|
879
|
-
/** 1. commitment_tree (writable) */
|
|
880
|
-
commitmentTree: Address;
|
|
881
|
-
/** 2. zkbtc_mint (writable) */
|
|
882
|
-
zkbtcMint: Address;
|
|
883
|
-
/** 3. pool_vault (writable) */
|
|
884
|
-
poolVault: Address;
|
|
885
|
-
/** 4. deposit_vault (writable) */
|
|
886
|
-
depositVault: Address;
|
|
887
|
-
/** 5. authority (signer, writable — pays for storage) */
|
|
888
|
-
authority: Address;
|
|
889
|
-
/** 6. system_program (readonly) */
|
|
890
|
-
systemProgram: Address;
|
|
891
|
-
};
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* Build initializePermissioned instruction data (disc=21).
|
|
895
|
-
*
|
|
896
|
-
* Layout (after disc byte — same as initialize plus two 32-byte fields):
|
|
897
|
-
* pool_bump(1) + tree_bump(1) + deposit_fee_bps(2 LE) + withdrawal_fee_bps(2 LE)
|
|
898
|
-
* + auditor(32) + auditor_viewing_pubkey(32)
|
|
899
|
-
* = 70 bytes of payload; 71 bytes total with disc.
|
|
900
|
-
*/
|
|
901
|
-
export declare function buildInitializePermissionedInstructionData(options: {
|
|
902
|
-
poolBump: number;
|
|
903
|
-
treeBump: number;
|
|
904
|
-
depositFeeBps: number;
|
|
905
|
-
withdrawalFeeBps: number;
|
|
906
|
-
auditor: Uint8Array;
|
|
907
|
-
auditorViewingPubkey: Uint8Array;
|
|
908
|
-
}): Uint8Array;
|
|
909
|
-
/**
|
|
910
|
-
* Build a complete initializePermissioned instruction (disc=21).
|
|
911
|
-
*
|
|
912
|
-
* Initializes a pool in permissioned mode; deposits/shields require auditor co-signing.
|
|
913
|
-
*
|
|
914
|
-
* Accounts (identical to initialize, disc=0):
|
|
915
|
-
* 0. pool_state (writable)
|
|
916
|
-
* 1. commitment_tree (writable)
|
|
917
|
-
* 2. zkbtc_mint (writable)
|
|
918
|
-
* 3. pool_vault (writable)
|
|
919
|
-
* 4. deposit_vault (writable)
|
|
920
|
-
* 5. authority (writable signer)
|
|
921
|
-
* 6. system_program (readonly)
|
|
922
|
-
*/
|
|
923
|
-
export declare function buildInitializePermissionedInstruction(options: InitializePermissionedOptions): Instruction;
|
|
924
861
|
/** completeDepositPermissioned instruction options */
|
|
925
862
|
export interface CompleteDepositPermissionedOptions {
|
|
926
863
|
/** SPV-proven sweep txid (32 bytes, internal byte order) */
|
|
@@ -1150,56 +1087,6 @@ export declare function buildRegisterExitDestinationInstruction(options: {
|
|
|
1150
1087
|
exitDestination: Address;
|
|
1151
1088
|
};
|
|
1152
1089
|
}): Instruction;
|
|
1153
|
-
/** setAuditorFrozen instruction options */
|
|
1154
|
-
export interface SetAuditorFrozenOptions {
|
|
1155
|
-
/** true = freeze the auditor role; false = un-freeze */
|
|
1156
|
-
frozen: boolean;
|
|
1157
|
-
accounts: {
|
|
1158
|
-
/** 0. pool_state (writable) */
|
|
1159
|
-
poolState: Address;
|
|
1160
|
-
/** 1. auditor (signer) */
|
|
1161
|
-
auditor: Address;
|
|
1162
|
-
};
|
|
1163
|
-
}
|
|
1164
|
-
/**
|
|
1165
|
-
* Build setAuditorFrozen instruction data (disc=28).
|
|
1166
|
-
*
|
|
1167
|
-
* Layout: disc(1) + frozen(1) — frozen byte: 0 = not frozen, 1 = frozen.
|
|
1168
|
-
*/
|
|
1169
|
-
export declare function buildSetAuditorFrozenInstructionData(frozen: boolean): Uint8Array;
|
|
1170
|
-
/**
|
|
1171
|
-
* Build a complete setAuditorFrozen instruction (disc=28).
|
|
1172
|
-
*
|
|
1173
|
-
* Accounts:
|
|
1174
|
-
* 0. pool_state (writable)
|
|
1175
|
-
* 1. auditor (signer)
|
|
1176
|
-
*/
|
|
1177
|
-
export declare function buildSetAuditorFrozenInstruction(options: SetAuditorFrozenOptions): Instruction;
|
|
1178
|
-
/** setAuditorViewingPubkey instruction options */
|
|
1179
|
-
export interface SetAuditorViewingPubkeyOptions {
|
|
1180
|
-
/** New 32-byte viewing pubkey for the auditor */
|
|
1181
|
-
viewingPubkey: Uint8Array;
|
|
1182
|
-
accounts: {
|
|
1183
|
-
/** 0. pool_state (writable) */
|
|
1184
|
-
poolState: Address;
|
|
1185
|
-
/** 1. auditor (signer) */
|
|
1186
|
-
auditor: Address;
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
/**
|
|
1190
|
-
* Build setAuditorViewingPubkey instruction data (disc=29).
|
|
1191
|
-
*
|
|
1192
|
-
* Layout: disc(1) + viewing_pubkey(32) = 33 bytes.
|
|
1193
|
-
*/
|
|
1194
|
-
export declare function buildSetAuditorViewingPubkeyInstructionData(viewingPubkey: Uint8Array): Uint8Array;
|
|
1195
|
-
/**
|
|
1196
|
-
* Build a complete setAuditorViewingPubkey instruction (disc=29).
|
|
1197
|
-
*
|
|
1198
|
-
* Accounts:
|
|
1199
|
-
* 0. pool_state (writable)
|
|
1200
|
-
* 1. auditor (signer)
|
|
1201
|
-
*/
|
|
1202
|
-
export declare function buildSetAuditorViewingPubkeyInstruction(options: SetAuditorViewingPubkeyOptions): Instruction;
|
|
1203
1090
|
export interface RotateAuditorOptions {
|
|
1204
1091
|
auditor: Uint8Array;
|
|
1205
1092
|
viewingPubkey: Uint8Array;
|
package/dist/instructions.js
CHANGED
|
@@ -1498,75 +1498,6 @@ export function bytes32ToBigint(bytes) {
|
|
|
1498
1498
|
// hexToBytes / bytesToHex live in ./crypto (single source); re-exported here
|
|
1499
1499
|
// to preserve this module's public surface.
|
|
1500
1500
|
export { hexToBytes, bytesToHex } from "./crypto";
|
|
1501
|
-
/**
|
|
1502
|
-
* Build initializePermissioned instruction data (disc=21).
|
|
1503
|
-
*
|
|
1504
|
-
* Layout (after disc byte — same as initialize plus two 32-byte fields):
|
|
1505
|
-
* pool_bump(1) + tree_bump(1) + deposit_fee_bps(2 LE) + withdrawal_fee_bps(2 LE)
|
|
1506
|
-
* + auditor(32) + auditor_viewing_pubkey(32)
|
|
1507
|
-
* = 70 bytes of payload; 71 bytes total with disc.
|
|
1508
|
-
*/
|
|
1509
|
-
export function buildInitializePermissionedInstructionData(options) {
|
|
1510
|
-
if (options.auditor.length !== 32) {
|
|
1511
|
-
throw new Error(`auditor must be 32 bytes, got ${options.auditor.length}`);
|
|
1512
|
-
}
|
|
1513
|
-
if (options.auditorViewingPubkey.length !== 32) {
|
|
1514
|
-
throw new Error(`auditorViewingPubkey must be 32 bytes, got ${options.auditorViewingPubkey.length}`);
|
|
1515
|
-
}
|
|
1516
|
-
// disc(1) + pool_bump(1) + tree_bump(1) + deposit_fee_bps(2) + withdrawal_fee_bps(2) + auditor(32) + auditor_viewing_pubkey(32) = 71
|
|
1517
|
-
const data = new Uint8Array(71);
|
|
1518
|
-
const view = new DataView(data.buffer);
|
|
1519
|
-
let offset = 0;
|
|
1520
|
-
data[offset++] = PERMISSIONED_DISC.INITIALIZE_PERMISSIONED; // disc = 21
|
|
1521
|
-
data[offset++] = options.poolBump;
|
|
1522
|
-
data[offset++] = options.treeBump;
|
|
1523
|
-
view.setUint16(offset, options.depositFeeBps, true);
|
|
1524
|
-
offset += 2;
|
|
1525
|
-
view.setUint16(offset, options.withdrawalFeeBps, true);
|
|
1526
|
-
offset += 2;
|
|
1527
|
-
data.set(options.auditor, offset);
|
|
1528
|
-
offset += 32;
|
|
1529
|
-
data.set(options.auditorViewingPubkey, offset);
|
|
1530
|
-
return data;
|
|
1531
|
-
}
|
|
1532
|
-
/**
|
|
1533
|
-
* Build a complete initializePermissioned instruction (disc=21).
|
|
1534
|
-
*
|
|
1535
|
-
* Initializes a pool in permissioned mode; deposits/shields require auditor co-signing.
|
|
1536
|
-
*
|
|
1537
|
-
* Accounts (identical to initialize, disc=0):
|
|
1538
|
-
* 0. pool_state (writable)
|
|
1539
|
-
* 1. commitment_tree (writable)
|
|
1540
|
-
* 2. zkbtc_mint (writable)
|
|
1541
|
-
* 3. pool_vault (writable)
|
|
1542
|
-
* 4. deposit_vault (writable)
|
|
1543
|
-
* 5. authority (writable signer)
|
|
1544
|
-
* 6. system_program (readonly)
|
|
1545
|
-
*/
|
|
1546
|
-
export function buildInitializePermissionedInstruction(options) {
|
|
1547
|
-
const config = getConfig();
|
|
1548
|
-
const data = buildInitializePermissionedInstructionData({
|
|
1549
|
-
poolBump: options.poolBump,
|
|
1550
|
-
treeBump: options.treeBump,
|
|
1551
|
-
depositFeeBps: options.depositFeeBps,
|
|
1552
|
-
withdrawalFeeBps: options.withdrawalFeeBps,
|
|
1553
|
-
auditor: options.auditor,
|
|
1554
|
-
auditorViewingPubkey: options.auditorViewingPubkey,
|
|
1555
|
-
});
|
|
1556
|
-
return {
|
|
1557
|
-
programAddress: config.utxopiaProgramId,
|
|
1558
|
-
accounts: [
|
|
1559
|
-
{ address: options.accounts.poolState, role: AccountRole.WRITABLE },
|
|
1560
|
-
{ address: options.accounts.commitmentTree, role: AccountRole.WRITABLE },
|
|
1561
|
-
{ address: options.accounts.zkbtcMint, role: AccountRole.WRITABLE },
|
|
1562
|
-
{ address: options.accounts.poolVault, role: AccountRole.WRITABLE },
|
|
1563
|
-
{ address: options.accounts.depositVault, role: AccountRole.WRITABLE },
|
|
1564
|
-
{ address: options.accounts.authority, role: AccountRole.WRITABLE_SIGNER },
|
|
1565
|
-
{ address: options.accounts.systemProgram, role: AccountRole.READONLY },
|
|
1566
|
-
],
|
|
1567
|
-
data,
|
|
1568
|
-
};
|
|
1569
|
-
}
|
|
1570
1501
|
/**
|
|
1571
1502
|
* Build completeDepositPermissioned instruction data (disc=22).
|
|
1572
1503
|
*
|
|
@@ -1777,64 +1708,6 @@ export function buildRegisterExitDestinationInstruction(options) {
|
|
|
1777
1708
|
data,
|
|
1778
1709
|
};
|
|
1779
1710
|
}
|
|
1780
|
-
/**
|
|
1781
|
-
* Build setAuditorFrozen instruction data (disc=28).
|
|
1782
|
-
*
|
|
1783
|
-
* Layout: disc(1) + frozen(1) — frozen byte: 0 = not frozen, 1 = frozen.
|
|
1784
|
-
*/
|
|
1785
|
-
export function buildSetAuditorFrozenInstructionData(frozen) {
|
|
1786
|
-
return new Uint8Array([INSTRUCTION.SET_AUDITOR_FROZEN, frozen ? 1 : 0]);
|
|
1787
|
-
}
|
|
1788
|
-
/**
|
|
1789
|
-
* Build a complete setAuditorFrozen instruction (disc=28).
|
|
1790
|
-
*
|
|
1791
|
-
* Accounts:
|
|
1792
|
-
* 0. pool_state (writable)
|
|
1793
|
-
* 1. auditor (signer)
|
|
1794
|
-
*/
|
|
1795
|
-
export function buildSetAuditorFrozenInstruction(options) {
|
|
1796
|
-
const config = getConfig();
|
|
1797
|
-
return {
|
|
1798
|
-
programAddress: config.utxopiaProgramId,
|
|
1799
|
-
accounts: [
|
|
1800
|
-
{ address: options.accounts.poolState, role: AccountRole.WRITABLE },
|
|
1801
|
-
{ address: options.accounts.auditor, role: AccountRole.READONLY_SIGNER },
|
|
1802
|
-
],
|
|
1803
|
-
data: buildSetAuditorFrozenInstructionData(options.frozen),
|
|
1804
|
-
};
|
|
1805
|
-
}
|
|
1806
|
-
/**
|
|
1807
|
-
* Build setAuditorViewingPubkey instruction data (disc=29).
|
|
1808
|
-
*
|
|
1809
|
-
* Layout: disc(1) + viewing_pubkey(32) = 33 bytes.
|
|
1810
|
-
*/
|
|
1811
|
-
export function buildSetAuditorViewingPubkeyInstructionData(viewingPubkey) {
|
|
1812
|
-
if (viewingPubkey.length !== 32) {
|
|
1813
|
-
throw new Error(`viewingPubkey must be 32 bytes, got ${viewingPubkey.length}`);
|
|
1814
|
-
}
|
|
1815
|
-
const data = new Uint8Array(33);
|
|
1816
|
-
data[0] = INSTRUCTION.SET_AUDITOR_VIEWING_PUBKEY;
|
|
1817
|
-
data.set(viewingPubkey, 1);
|
|
1818
|
-
return data;
|
|
1819
|
-
}
|
|
1820
|
-
/**
|
|
1821
|
-
* Build a complete setAuditorViewingPubkey instruction (disc=29).
|
|
1822
|
-
*
|
|
1823
|
-
* Accounts:
|
|
1824
|
-
* 0. pool_state (writable)
|
|
1825
|
-
* 1. auditor (signer)
|
|
1826
|
-
*/
|
|
1827
|
-
export function buildSetAuditorViewingPubkeyInstruction(options) {
|
|
1828
|
-
const config = getConfig();
|
|
1829
|
-
return {
|
|
1830
|
-
programAddress: config.utxopiaProgramId,
|
|
1831
|
-
accounts: [
|
|
1832
|
-
{ address: options.accounts.poolState, role: AccountRole.WRITABLE },
|
|
1833
|
-
{ address: options.accounts.auditor, role: AccountRole.READONLY_SIGNER },
|
|
1834
|
-
],
|
|
1835
|
-
data: buildSetAuditorViewingPubkeyInstructionData(options.viewingPubkey),
|
|
1836
|
-
};
|
|
1837
|
-
}
|
|
1838
1711
|
export function buildRotateAuditorInstructionData(auditor, viewingPubkey) {
|
|
1839
1712
|
if (auditor.length !== 32 || auditor.every((byte) => byte === 0)) {
|
|
1840
1713
|
throw new Error("auditor must be a nonzero 32-byte public key");
|
package/dist/poseidon.d.ts
CHANGED
|
@@ -47,7 +47,3 @@ export declare function reduceToField(bytes: Uint8Array): bigint;
|
|
|
47
47
|
* poseidon2_hash(reduce_to_field_exact(mint), [0u8; 32]).
|
|
48
48
|
*/
|
|
49
49
|
export declare function computeTokenId(mintBytes: Uint8Array): bigint;
|
|
50
|
-
/**
|
|
51
|
-
* Convenience: compute token_id from a Solana address string
|
|
52
|
-
*/
|
|
53
|
-
export declare function computeTokenIdFromAddress(mintAddress: string): bigint;
|
package/dist/poseidon.js
CHANGED
|
@@ -126,11 +126,3 @@ export function computeTokenId(mintBytes) {
|
|
|
126
126
|
const reduced = reduceToField(mintBytes);
|
|
127
127
|
return poseidonHashSync([reduced, 0n]);
|
|
128
128
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Convenience: compute token_id from a Solana address string
|
|
131
|
-
*/
|
|
132
|
-
export function computeTokenIdFromAddress(mintAddress) {
|
|
133
|
-
// Base58 decode — import from @solana/kit if available, otherwise use raw bytes
|
|
134
|
-
// For now, caller should pass raw bytes via computeTokenId
|
|
135
|
-
throw new Error("Use computeTokenId(mintBytes) with raw pubkey bytes");
|
|
136
|
-
}
|
package/dist/prover/index.d.ts
CHANGED
package/dist/prover/web.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* - Nullifier = Poseidon(nullifyingKey, leafIndex)
|
|
10
10
|
* - Signature = EdDSA-Poseidon over (merkleRoot, boundParamsHash, nullifiers..., commitmentsOut...)
|
|
11
11
|
*/
|
|
12
|
-
import type { Address } from "@solana/kit";
|
|
13
12
|
export interface MerkleProofInput {
|
|
14
13
|
siblings: bigint[];
|
|
15
14
|
indices: number[];
|
|
@@ -20,16 +19,10 @@ export interface ProofData {
|
|
|
20
19
|
verificationKey?: Uint8Array;
|
|
21
20
|
}
|
|
22
21
|
export type CircuitType = `joinsplit_${number}x${number}`;
|
|
23
|
-
/** Names of non-JoinSplit auxiliary circuits (selective disclosure). */
|
|
24
|
-
export type AuxCircuitName = "ownership" | "range_sum" | "range_sum_4" | "range_sum_16";
|
|
25
22
|
/**
|
|
26
23
|
* Set the base path for circuit artifacts
|
|
27
24
|
*/
|
|
28
25
|
export declare function setCircuitPath(path: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* Get the current circuit base path
|
|
31
|
-
*/
|
|
32
|
-
export declare function getCircuitPath(): string;
|
|
33
26
|
/**
|
|
34
27
|
* Pin the circuit artifacts this app is willing to prove with.
|
|
35
28
|
*
|
|
@@ -126,11 +119,3 @@ export declare function proofToBytes(proof: ProofData): Uint8Array;
|
|
|
126
119
|
* Cleanup all cached resources
|
|
127
120
|
*/
|
|
128
121
|
export declare function cleanup(): Promise<void>;
|
|
129
|
-
/**
|
|
130
|
-
* Groth16 verifier program ID (from current config)
|
|
131
|
-
*/
|
|
132
|
-
export declare function getGroth16VerifierProgramId(): Address;
|
|
133
|
-
/**
|
|
134
|
-
* Build instruction data for Groth16 verification
|
|
135
|
-
*/
|
|
136
|
-
export declare function buildVerifyInstructionData(proof: Uint8Array, publicSignals: string[], vkHash: string): Uint8Array;
|
package/dist/prover/web.js
CHANGED
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
* - Signature = EdDSA-Poseidon over (merkleRoot, boundParamsHash, nullifiers..., commitmentsOut...)
|
|
11
11
|
*/
|
|
12
12
|
import { poseidonHashSync, computeJoinSplitCommitmentSync, computeJoinSplitNullifierSync, } from "../poseidon";
|
|
13
|
-
import { BN254_FIELD_PRIME } from "../crypto";
|
|
13
|
+
import { BN254_FIELD_PRIME, bytesToHex } from "../crypto";
|
|
14
14
|
import { TREE_DEPTH } from "../merkle";
|
|
15
|
-
import { getConfig } from "../config";
|
|
16
15
|
import { MAX_SAFE_JOINSPLIT_SIZE } from "../vk-registry";
|
|
17
16
|
/** Maximum satoshis (total BTC supply) */
|
|
18
17
|
const MAX_SATOSHIS = 21000000n * 100000000n;
|
|
@@ -53,12 +52,6 @@ export function setCircuitPath(path) {
|
|
|
53
52
|
artifactBytesCache.clear();
|
|
54
53
|
artifactDownloadCache.clear();
|
|
55
54
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Get the current circuit base path
|
|
58
|
-
*/
|
|
59
|
-
export function getCircuitPath() {
|
|
60
|
-
return circuitBasePath;
|
|
61
|
-
}
|
|
62
55
|
// Lazy-loaded snarkjs module
|
|
63
56
|
let snarkjs = null;
|
|
64
57
|
const circuitCache = new Map();
|
|
@@ -115,7 +108,6 @@ export function setCircuitArtifactDigests(digests) {
|
|
|
115
108
|
// Anything admitted under the old policy must be re-checked under the new one.
|
|
116
109
|
artifactBytesCache.clear();
|
|
117
110
|
}
|
|
118
|
-
const toHex = (buf) => Array.from(new Uint8Array(buf), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
119
111
|
async function verifyArtifactBytes(url, bytes) {
|
|
120
112
|
if (!artifactDigests)
|
|
121
113
|
return;
|
|
@@ -125,7 +117,7 @@ async function verifyArtifactBytes(url, bytes) {
|
|
|
125
117
|
throw new Error(`No integrity digest recorded for circuit artifact ${url} — refusing to prove. ` +
|
|
126
118
|
`Regenerate the artifact manifest so it covers every shape this origin serves.`);
|
|
127
119
|
}
|
|
128
|
-
const actual =
|
|
120
|
+
const actual = bytesToHex(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength))));
|
|
129
121
|
if (actual !== artifactDigests[key]) {
|
|
130
122
|
throw new Error(`Circuit artifact ${key} failed its integrity check (expected ${artifactDigests[key]}, ` +
|
|
131
123
|
`got ${actual}). Refusing to prove against an artifact this build does not recognise.`);
|
|
@@ -556,42 +548,3 @@ export async function cleanup() {
|
|
|
556
548
|
// ==========================================================================
|
|
557
549
|
// Solana Instruction Building (for Groth16 on-chain verification)
|
|
558
550
|
// ==========================================================================
|
|
559
|
-
/**
|
|
560
|
-
* Groth16 verifier program ID (from current config)
|
|
561
|
-
*/
|
|
562
|
-
export function getGroth16VerifierProgramId() {
|
|
563
|
-
const config = getConfig();
|
|
564
|
-
return config.groth16VerifierProgramId;
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Build instruction data for Groth16 verification
|
|
568
|
-
*/
|
|
569
|
-
export function buildVerifyInstructionData(proof, publicSignals, vkHash) {
|
|
570
|
-
const piBytes = publicSignals.flatMap((pi) => {
|
|
571
|
-
const bytes = new Array(32).fill(0);
|
|
572
|
-
const bigint = BigInt(pi);
|
|
573
|
-
for (let i = 31; i >= 0; i--) {
|
|
574
|
-
bytes[i] = Number((bigint >> BigInt((31 - i) * 8)) & 0xffn);
|
|
575
|
-
}
|
|
576
|
-
return bytes;
|
|
577
|
-
});
|
|
578
|
-
const cleanHex = vkHash.startsWith("0x") ? vkHash.slice(2) : vkHash;
|
|
579
|
-
const vkHashBytes = new Uint8Array(cleanHex.length / 2);
|
|
580
|
-
for (let i = 0; i < vkHashBytes.length; i++) {
|
|
581
|
-
vkHashBytes[i] = parseInt(cleanHex.substr(i * 2, 2), 16);
|
|
582
|
-
}
|
|
583
|
-
const totalSize = proof.length + 4 + piBytes.length + 32;
|
|
584
|
-
const data = new Uint8Array(totalSize);
|
|
585
|
-
let offset = 0;
|
|
586
|
-
data.set(proof, offset);
|
|
587
|
-
offset += proof.length;
|
|
588
|
-
const piCount = publicSignals.length;
|
|
589
|
-
data[offset++] = piCount & 0xff;
|
|
590
|
-
data[offset++] = (piCount >> 8) & 0xff;
|
|
591
|
-
data[offset++] = (piCount >> 16) & 0xff;
|
|
592
|
-
data[offset++] = (piCount >> 24) & 0xff;
|
|
593
|
-
data.set(new Uint8Array(piBytes), offset);
|
|
594
|
-
offset += piBytes.length;
|
|
595
|
-
data.set(vkHashBytes, offset);
|
|
596
|
-
return data;
|
|
597
|
-
}
|