@utxopia/sdk 0.1.0-alpha.4 → 0.1.0-alpha.6

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.
@@ -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 "mainnet" | "testnet" | "regtest"
37
+ * @param network BitcoinNetwork
37
38
  * @returns The P2TR address (`bc1p…` / `tb1p…` / `bcrt1p…`)
38
39
  */
39
- export declare function deriveCustodyAddressFromIkaDWallet(ref: IkaDWalletRef, network: "mainnet" | "testnet" | "regtest"): string;
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: "mainnet" | "testnet" | "regtest"): string;
48
+ export declare function deriveRawXOnlyP2TRAddress(xonlyPubkey: Uint8Array, network: BitcoinNetwork): string;
@@ -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 { bech32m } from "bech32";
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 "mainnet" | "testnet" | "regtest"
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
- const hrp = network === "mainnet" ? "bc" : network === "regtest" ? "bcrt" : "tb";
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
- const hrp = network === "mainnet" ? "bc" : network === "regtest" ? "bcrt" : "tb";
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?: "mainnet" | "testnet" | "regtest";
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?: "mainnet" | "testnet" | "regtest";
170
+ network?: BitcoinNetwork;
171
171
  opReturnContext: DepositOpReturnContext;
172
172
  }): Promise<NonInteractiveDepositResult>;
173
173
  /**
package/dist/client.js CHANGED
@@ -183,8 +183,6 @@ export class UTXOpiaClient {
183
183
  const cached = this._tokenIdCache.get(mintAddress);
184
184
  if (cached !== undefined)
185
185
  return cached;
186
- // Requires PublicKey — import dynamically to avoid hard dep
187
- const mintBytes = hexToBytes(mintAddress.padStart(64, "0"));
188
186
  // If it's a base58 address, convert via PublicKey
189
187
  let bytes;
190
188
  try {
@@ -200,7 +198,9 @@ export class UTXOpiaClient {
200
198
  }
201
199
  }
202
200
  catch {
203
- bytes = mintBytes;
201
+ // Lazy on purpose: a base58 mint padded to 64 is not hex, so computing
202
+ // this eagerly threw before the branch above ever ran.
203
+ bytes = hexToBytes(mintAddress.padStart(64, "0"));
204
204
  }
205
205
  const tokenId = computeTokenId(bytes);
206
206
  this._tokenIdCache.set(mintAddress, tokenId);
package/dist/config.js CHANGED
@@ -175,8 +175,11 @@ export const MAINNET_CONFIG = {
175
175
  // Bitcoin Network
176
176
  bitcoinNetwork: "mainnet",
177
177
  esploraUrl: "https://mempool.space/api",
178
- // Circuit CDN
179
- circuitCdnUrl: "https://circuit.utxopia.com",
178
+ // Circuit CDN. Must carry the full versioned path: `resolveCircuitPath` turns a bare host
179
+ // into `<host>/circuits/groth16`, which is a DIFFERENT, stale build that still serves 200s
180
+ // for every shape with a different delta. Proofs built from it verify locally and are
181
+ // rejected on chain as "proof invalid".
182
+ circuitCdnUrl: "https://circuit.utxopia.com/circuits/v2/groth16",
180
183
  // Groth16 Verifier (placeholder)
181
184
  groth16VerifierProgramId: address("11111111111111111111111111111111"),
182
185
  // VK Hashes (placeholder - update when deployed)
@@ -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).
@@ -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 function bytesToHex(bytes: Uint8Array): string;
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
- const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
67
- const bytes = new Uint8Array(cleanHex.length / 2);
68
- for (let i = 0; i < cleanHex.length; i += 2) {
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 function bytesToHex(bytes) {
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";
@@ -54,7 +54,7 @@ export { createFetchConnectionAdapter, createConnectionAdapterFromWeb3, createCo
54
54
  export { resolveSnsName, resolveStealthName, parseSnsStealthData, isSnsStealthAddress, isAuditorDisclosable, SnsComplianceFlags, SNS_COMPLIANCE_AUDITOR_OFFSET, SNS_COMPLIANCE_AUDITOR_BYTES, deriveParentDomainKey, SNS_STEALTH_DATA_SIZE, type SnsStealthAddress, } from "./sns-resolver";
55
55
  export { COMMITMENT_TREE_DISCRIMINATOR, parseCommitmentTreeData, isValidRoot, fetchCommitmentTree, getCommitmentIndex, saveCommitmentIndex, CommitmentTreeIndex, buildCommitmentTreeFromChain, fetchLeafIndexForCommitment, fetchMerkleProofForCommitment, getMerkleProofFromTree, type CommitmentTreeState, type RpcClient, type OnChainMerkleProof, } from "./commitment-tree";
56
56
  export { INSTRUCTION_DISCRIMINATORS, buildShieldInstructionData, buildShieldInstruction, type ShieldInstructionOptions, buildApproveRedemptionSigningInstructionData, buildApproveRedemptionSigningInstruction, buildCancelRedemptionInstructionData, buildCancelRedemptionInstruction, type CancelRedemptionInstructionOptions, bigintTo32Bytes, bytes32ToBigint, buildTransactInstructionData, buildTransactInstruction, buildRedeemInstructionData, buildUnshieldInstructionData, buildUnshieldInstruction, buildProposePoolUpdateInstructionData, buildProposePoolUpdateInstruction, buildExecutePoolUpdateInstructionData, buildExecutePoolUpdateInstruction, buildCancelPoolUpdateInstructionData, buildCancelPoolUpdateInstruction, buildRotateTreeInstructionData, buildRotateTreeInstruction, type RotateTreeOptions, buildMagicBlockDelegateInstructionData, buildMagicBlockDelegateInstruction, buildMagicBlockCommitInstructionData, buildMagicBlockCommitInstruction, buildMagicBlockPerPermissionInstructionData, buildMagicBlockPerPermissionInstruction, buildPolicyRequestHash, buildPolicyIntentParts, buildRegisterExitDestinationInstruction, buildRegisterExitDestinationInstructionData, MAX_POLICY_INTENT_PARTS, buildInitializePolicyApprovalInstructionData, buildInitializePolicyApprovalInstruction, buildPolicyApprovalDecisionInstruction, buildPolicyApprovalCommitInstruction, buildCompleteDepositPermissionedInstructionData, buildCompleteDepositPermissionedInstruction, buildShieldPermissionedInstructionData, buildShieldPermissionedInstruction, buildRotateAuditorInstructionData, buildRotateAuditorInstruction, type MagicBlockDelegateTarget, type MagicBlockDelegateInstructionOptions, type MagicBlockCommitInstructionOptions, type MagicBlockPerPermissionOperation, type MagicBlockPerPermissionMember, type MagicBlockPerPermissionInstructionOptions, type PolicyApprovalDecision, type InitializePolicyApprovalOptions, type CompleteDepositPermissionedOptions, type ShieldPermissionedInstructionOptions, type RotateAuditorOptions, buildVerifyTransactionInstructionData, buildCompleteDepositInstructionData, buildVerifyDepositInstructionData, buildVerifyDepositPermissionedInstructionData, buildSetPoolConfigInstructionData, parsePoolConfig, type ParsedPoolConfig, POOL_CONFIG_DISCRIMINATOR, POOL_CONFIG_LEN, POOL_SCRIPT_MAX_LEN, type Instruction, type ApproveRedemptionSigningInstructionOptions, type TransactInstructionOptions, type UnshieldInstructionOptions, type ProposePoolUpdateOptions, type ExecutePoolUpdateOptions, type CancelPoolUpdateOptions, } from "./instructions";
57
- export { VK_REGISTRY_DISCRIMINATOR, VK_REGISTRY_LEN, MAX_IC_POINTS, MAX_SAFE_JOINSPLIT_SIZE, INIT_VK_REGISTRY_DISCRIMINATOR, UPDATE_VK_REGISTRY_DISCRIMINATOR, joinSplitNumPublicInputs, computeVkHash, vkeyJsonToVkMaterial, buildVkRegistryData, parseVkRegistry, assertVkRegistryForShape, isVkRegistryReady, type JoinSplitVkMaterial, type SnarkjsVkeyJson, type ParsedVkRegistry, } from "./vk-registry";
57
+ export { VK_REGISTRY_DISCRIMINATOR, VK_REGISTRY_LEN, MAX_IC_POINTS, MAX_SAFE_JOINSPLIT_SIZE, INIT_VK_REGISTRY_DISCRIMINATOR, UPDATE_VK_REGISTRY_DISCRIMINATOR, joinSplitNumPublicInputs, computeVkHash, vkeyJsonToVkMaterial, buildVkRegistryData, parseVkRegistry, assertVkRegistryForShape, assertVkeyMatchesRegistry, isVkRegistryReady, type JoinSplitVkMaterial, type SnarkjsVkeyJson, type ParsedVkRegistry, } from "./vk-registry";
58
58
  export { fetchExplorerDeposits, fetchExplorerTransfers, fetchExplorerRedemptions, parseNullifierRecord, parseRedemptionRequest, NULLIFIER_RECORD_SIZE, REDEMPTION_REQUEST_SIZE, NULLIFIER_RECORD_DISCRIMINATOR, REDEMPTION_REQUEST_DISCRIMINATOR, OPERATION_TYPE_LABELS, type ExplorerDeposit, type ExplorerTransferEvent, type ExplorerRedemption, type IndexerLeaf, } from "./explorer";
59
59
  export { parseProgramEvents, parseNullifierSpentEvent, parseStealthAnnouncementEvent, parseSenderMemoEvent, parseBtcOriginAttestationEvent, parseAuditorCiphertextEvent, EVENT_NULLIFIER_SPENT, EVENT_STEALTH_ANNOUNCEMENT, EVENT_NULLIFIERS_BATCH, EVENT_ANNOUNCEMENTS_BATCH, EVENT_SENDER_MEMO, EVENT_BTC_ORIGIN_ATTESTATION, EVENT_AUDITOR_CIPHERTEXT, type NullifierSpentEvent, type StealthAnnouncementEvent, type SenderMemoEvent, type BtcOriginAttestationEvent, type AuditorCiphertextEvent, type ProgramEvent, } from "./events";
60
60
  export { AnnouncementClient, type AnnouncementClientConfig, type AnnouncementListener, } from "./announcement-client";
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
  // ==========================================================================
@@ -187,7 +187,7 @@ buildSetPoolConfigInstructionData, parsePoolConfig, POOL_CONFIG_DISCRIMINATOR, P
187
187
  // ==========================================================================
188
188
  // VK Registry (JoinSplit Groth16 on-chain verification keys)
189
189
  // ==========================================================================
190
- export { VK_REGISTRY_DISCRIMINATOR, VK_REGISTRY_LEN, MAX_IC_POINTS, MAX_SAFE_JOINSPLIT_SIZE, INIT_VK_REGISTRY_DISCRIMINATOR, UPDATE_VK_REGISTRY_DISCRIMINATOR, joinSplitNumPublicInputs, computeVkHash, vkeyJsonToVkMaterial, buildVkRegistryData, parseVkRegistry, assertVkRegistryForShape, isVkRegistryReady, } from "./vk-registry";
190
+ export { VK_REGISTRY_DISCRIMINATOR, VK_REGISTRY_LEN, MAX_IC_POINTS, MAX_SAFE_JOINSPLIT_SIZE, INIT_VK_REGISTRY_DISCRIMINATOR, UPDATE_VK_REGISTRY_DISCRIMINATOR, joinSplitNumPublicInputs, computeVkHash, vkeyJsonToVkMaterial, buildVkRegistryData, parseVkRegistry, assertVkRegistryForShape, assertVkeyMatchesRegistry, isVkRegistryReady, } from "./vk-registry";
191
191
  // ==========================================================================
192
192
  // ChadBuffer Relay
193
193
  // ==========================================================================
@@ -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;
@@ -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");
@@ -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
- }
@@ -7,4 +7,3 @@
7
7
  * - @utxopia/sdk/prover/mobile for React Native Groth16 prover
8
8
  */
9
9
  export * from "./web";
10
- export type { MerkleProofInput, ProofData, CircuitType, JoinSplitProofInputs, } from "./web";
@@ -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,18 @@ 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
- * Set the base path for circuit artifacts
23
+ * Fetch a circuit's `*.vkey.json` from the same base path its zkey comes from.
24
+ *
25
+ * Deliberately reads `circuitBasePath` rather than taking a URL: the point of the check this
26
+ * feeds (`assertVkeyMatchesRegistry`) is that the vkey describes the artifacts actually being
27
+ * proved with, and a caller-supplied URL could describe a different build entirely.
27
28
  */
28
- export declare function setCircuitPath(path: string): void;
29
+ export declare function fetchCircuitVkey(circuitType: CircuitType): Promise<unknown>;
29
30
  /**
30
- * Get the current circuit base path
31
+ * Set the base path for circuit artifacts
31
32
  */
32
- export declare function getCircuitPath(): string;
33
+ export declare function setCircuitPath(path: string): void;
33
34
  /**
34
35
  * Pin the circuit artifacts this app is willing to prove with.
35
36
  *
@@ -126,11 +127,3 @@ export declare function proofToBytes(proof: ProofData): Uint8Array;
126
127
  * Cleanup all cached resources
127
128
  */
128
129
  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;