SDK reference

Generated from packages/sdk/src on each request: 249 exports in 17 modules.

builders

RingsConfig interface
export interface RingsConfig
Authorization type
export type Authorization =
PreparedCall interface
export interface PreparedCall
PreparedDeposit interface
export interface PreparedDeposit
Rings class
export class Rings
sendPrepared function
export async function sendPrepared(walletClient: WalletClient, call: PreparedCall): Promise<Hex>

Send a prepared call with the user's wallet (the simulation already passed).

encryption

HPKE_PREFIX const
export const HPKE_PREFIX = "TSPP/hpke/";
ENC_INFO_TRANSFER const
export const ENC_INFO_TRANSFER = "TSPP/tx";
EncryptedScheme const
export const EncryptedScheme =
OutputEncoding const
export const OutputEncoding = { plaintext: 0, encrypted: 1, verifiable: 2 } as const;
CONFIDENTIAL_SLOT_BYTES const
export const CONFIDENTIAL_SLOT_BYTES = 89;

89 B: the on-chain size of one confidential output ciphertext with no data records.

applyTransferCipher function
export function applyTransferCipher(

The symmetric transfer cipher (CTR, so encrypt == decrypt). `secret` is one side's X25519 secret, `counterparty` the other side's public key.

encryptSlot function
export function encryptSlot(tx: ViewingKey, recipientPk: Uint8Array, plaintext: Uint8Array, salt: Uint8Array, slot: number)

Sender side: tx viewing key encrypts to the recipient's viewing key.

decryptSlot function
export function decryptSlot(owner: ViewingKey, txViewingPk: Uint8Array, ct: Uint8Array, salt: Uint8Array, slot: number)

Recipient side: own viewing key and the published tx viewing pk.

decryptSlotAsTxViewer function
export function decryptSlotAsTxViewer(tx: ViewingKey, recipientPk: Uint8Array, ct: Uint8Array, salt: Uint8Array, slot: number)

Disclosure side: the tx viewing key opens a slot addressed to `recipientPk`.

DataRecords interface
export interface DataRecords
encodeData function
export function encodeData(d: DataRecords = {}): Uint8Array
memoText const
export const memoText = (s: string): Uint8Array => enc.encode(s);
memoString const
export const memoString = (b: Uint8Array | undefined): string | undefined => (b ? dec.decode(b) : undefined);
ConfidentialPlaintext interface
export interface ConfidentialPlaintext
encodeConfidential function
export function encodeConfidential(p: ConfidentialPlaintext): Uint8Array
decodeConfidential function
export function decodeConfidential(b: Uint8Array): ConfidentialPlaintext
encodeOutputFrame function
export function encodeOutputFrame(scheme: number, body: Uint8Array, encoding: number = OutputEncoding.encrypted): Uint8Array
decodeOutputFrame function
export function decodeOutputFrame(b: Uint8Array): { encoding: number; scheme: number; body: Uint8Array }
encryptConfidentialOutput function
export function encryptConfidentialOutput(

One confidential output slot as published on chain (89 B with no data).

decryptConfidentialOutput function
export function decryptConfidentialOutput(

Owner opens a slot with its own viewing key. Returns undefined if the slot is not addressed to it.

decryptConfidentialOutputAsTxViewer function
export function decryptConfidentialOutputAsTxViewer(

Tx viewing key opens any slot of its transaction (selective disclosure).

dummyOutputBytes function
export function dummyOutputBytes(length = CONFIDENTIAL_SLOT_BYTES): Uint8Array

Random bytes with the length of a real slot, for dummy outputs.

randomSalt function
export function randomSalt(): Uint8Array

examples

ESCROW_ABI const
export const ESCROW_ABI = parseAbi([
SWAP_ABI const
export const SWAP_ABI = parseAbi([
ESCROW_STATES const
export const ESCROW_STATES = ["None", "Locked", "Approved", "Released", "Refunded"] as const;

PrivateEscrow.State.

EscrowState type
export type EscrowState = (typeof ESCROW_STATES)[number];
dealSecrets function
export function dealSecrets(creatorNullifierSecret: bigint, lockInputNullifier: bigint): { lockSecret: bigint; seed: bigint }

One-time nullifier secret of the locked note and the blinding seed of the deal's pinned outputs. Both come from the creator's nullifier secret and the first nullifier of the lock transact (public), so the creator can derive them again; nobody else can. They are shared in the ticket. They do not reveal the creator's nullifier secret (Poseidon is one-way).

pinnedOutputHash function
export function pinnedOutputHash(firstNullifier: bigint, seed: bigint, to: Pick<ShieldedAddress, "address" | "nullifierPk">, token: Address, units: bigint): bigint

Output 0 of a transact whose first nullifier is `firstNullifier` and whose blinding seed is `seed`.

DealTicket interface
export interface DealTicket
DealTicketDraft type
export type DealTicketDraft = Omit<DealTicket, "id" | "leafIndex"> & { lockedCommitment: bigint };

A ticket before the lock is on chain: no id and no leaf index yet.

encodeDealTicket function
export function encodeDealTicket(t: DealTicket): string

`rdt1:` + base64url(JSON). Share it with the counterparty over a private channel.

decodeDealTicket function
export function decodeDealTicket(s: string): DealTicket
lockedNoteOf function
export function lockedNoteOf(t: Pick<DealTicket, "vault" | "token" | "amount" | "blinding" | "lockSecret"> & { leafIndex?: bigint }): Note

The locked note of a ticket, as a spendable `Note` owned by the vault.

ticketFromReceipt function
export function ticketFromReceipt(draft: DealTicketDraft, receipt: { logs: readonly Log[] }): DealTicket

Complete a draft with the deal id and the leaf index from the receipt of the lock transaction.

EscrowDeal interface
export interface EscrowDeal
SwapOffer interface
export interface SwapOffer
ExactNoteNeededError class
export class ExactNoteNeededError extends Error
SignOwnerAuth type
export type SignOwnerAuth = (td: ReturnType<typeof ownerAuthTypedData>) => Promise<Hex>;
PreparedLock type
export type PreparedLock = PreparedCall & { draft: DealTicketDraft };
DealsConfig interface
export interface DealsConfig
Deals class
export class Deals

Builders for PrivateEscrow and PrivateSwap on top of a `Rings` instance.

field

BN254_P const
export const BN254_P = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;

Byte and BN254 field helpers. Every 32-byte value in this SDK is a big-endian field element unless a comment says otherwise (X25519 keys are little-endian per RFC 7748).

Bytes type
export type Bytes = Uint8Array;
Hex type
export type Hex = `0x${string}`;
concat function
export function concat(...parts: readonly Uint8Array[]): Uint8Array
equalBytes function
export function equalBytes(a: Uint8Array, b: Uint8Array): boolean
bytesToBigInt function
export function bytesToBigInt(b: Uint8Array): bigint
bigIntToBytes function
export function bigIntToBytes(v: bigint, len = 32): Uint8Array
hexToBytes function
export function hexToBytes(h: string): Uint8Array
bytesToHex function
export function bytesToHex(b: Uint8Array): Hex
fieldHex function
export function fieldHex(v: bigint): Hex

0x-prefixed 32-byte big-endian hex of a field element, the prover JSON encoding.

u16be function
export function u16be(v: number): Uint8Array
u32be function
export function u32be(v: number): Uint8Array
u64be function
export function u64be(v: bigint): Uint8Array
u64le function
export function u64le(v: bigint): Uint8Array
randomBytes function
export function randomBytes(n: number): Uint8Array
randomField function
export function randomField(): bigint

A uniformly random canonical BN254 field element (31 random bytes).

modP function
export function modP(v: bigint): bigint
tag4 function
export function tag4(s: string): bigint

ASCII four-letter domain tag read as a big-endian u32, e.g. "TXOS".

hash

poseidon function
export function poseidon(inputs: readonly bigint[]): bigint
hashBytes function
export function hashBytes(bytes: Uint8Array): bigint

`hash_bytes_N`: 31-byte big-endian chunks folded left with Poseidon(acc, chunk).

sha256BE function
export function sha256BE(bytes: Uint8Array): bigint

SHA-256 with the first byte zeroed, read as a field element (`Sha256BE`).

sha256Bytes function
export function sha256Bytes(...parts: Uint8Array[]): Uint8Array
hashChain function
export function hashChain(e: readonly bigint[]): bigint

Left fold, one element per Poseidon(h, e) call.

rightHashChain function
export function rightHashChain(e: readonly bigint[]): bigint

Right fold, one element per Poseidon(e, h) call.

nonZeroHashChain function
export function nonZeroHashChain(e: readonly bigint[]): bigint

`HashChain` over the nonzero elements only; 0 when there are none.

hashChain4 function
export function hashChain4(e: readonly bigint[]): bigint

Left fold, three elements per 4-input Poseidon call, zero-padded tail.

rightHashChain4 function
export function rightHashChain4(e: readonly bigint[]): bigint

Right fold, seeded with the last element; preceding elements in groups of up to 3 from the right, the short group leftmost and left-aligned: h = Poseidon(g0, g1 or 0, g2 or 0, h).

indexer

IndexedOutput interface
export interface IndexedOutput
IndexedTx interface
export interface IndexedTx
RootInfo interface
export interface RootInfo
PathInfo interface
export interface PathInfo
RegistryRecord interface
export interface RegistryRecord
IndexerApi interface
export interface IndexerApi
httpIndexer function
export function httpIndexer(url: string, opts: { fetch?: typeof fetch } = {}): IndexerApi
MemoryIndexer class
export class MemoryIndexer implements IndexerApi

In-memory indexer for tests and local demos.

keys

DST_X25519_VIEW_ROOT const
export const DST_X25519_VIEW_ROOT = "TSPP/view_root/x25519/v1";
INFO_NF_KEY_EIP712 const
export const INFO_NF_KEY_EIP712 = "TSPP/nf_key/secp256k1-eip712/v1";
INFO_VIEW_KEY_EIP712 const
export const INFO_VIEW_KEY_EIP712 = "TSPP/view_key/secp256k1-eip712/x25519/v1";
INFO_NF_KEY_ED25519 const
export const INFO_NF_KEY_ED25519 = "TSPP/nf_key/ed25519/v1";

zolana Solana-rail infos, kept to check the derivation tree against zolana vectors.

INFO_VIEW_KEY_ED25519 const
export const INFO_VIEW_KEY_ED25519 = "TSPP/view_key/ed25519/x25519/v1";
INFO_TX_VIEWING_X25519 const
export const INFO_TX_VIEWING_X25519 = "TSPP/tx_viewing/x25519/v1";
INFO_SENDER_VIEW_TAG_SECRET const
export const INFO_SENDER_VIEW_TAG_SECRET = "TSPP/sender_view_tag";
INFO_RECIPIENT_VIEW_TAG_SECRET const
export const INFO_RECIPIENT_VIEW_TAG_SECRET = "TSPP/recipient_view_tag";
INFO_SENDER_VIEW_TAG_PREFIX const
export const INFO_SENDER_VIEW_TAG_PREFIX = "TSPP/sender_view_tag/";
INFO_RECIPIENT_REQUEST_VIEW_TAG_PREFIX const
export const INFO_RECIPIENT_REQUEST_VIEW_TAG_PREFIX = "TSPP/recipient_request_view_tag/";
INFO_PAIR_DOMAIN_PREFIX const
export const INFO_PAIR_DOMAIN_PREFIX = "TSPP/pair-domain/";
INFO_PAIR_HINT_PREFIX const
export const INFO_PAIR_HINT_PREFIX = "TSPP/pair-hint/";
DERIVATION_PURPOSE const
export const DERIVATION_PURPOSE = "TSPP/derive/v1";
EVM_OWNER_SCHEME const
export const EVM_OWNER_SCHEME = 0x03;

Owner identity scheme byte for an EVM address and its in-field tag 'E'.

EVM_OWNER_TAG const
export const EVM_OWNER_TAG = 0x45n;
DERIVATION_DOMAIN const
export const DERIVATION_DOMAIN = { name: "Loop", version: "1" } as const;
DERIVATION_TYPES const
export const DERIVATION_TYPES =
DERIVATION_NOTICE const
export const DERIVATION_NOTICE =
derivationTypedData function
export function derivationTypedData(account: Address): TypedDataDefinition<typeof DERIVATION_TYPES, "Derive">

The typed data the wallet signs once. No chainId and no verifyingContract in the domain: one shielded identity per EVM address, the same on the fork and on mainnet. The purpose string is the zolana derivation payload, so no other request this app makes can reproduce the seed.

derivationSeedFromSignature function
export function derivationSeedFromSignature(signature: Hex): Uint8Array

r || s of a 65-byte ECDSA signature in canonical low-s form (64 B seed).

clamp function
export function clamp(secret: Uint8Array): Uint8Array
x25519PublicKey function
export function x25519PublicKey(secret: Uint8Array): Uint8Array

`0x04 || u` (33 B).

parseX25519PublicKey function
export function parseX25519PublicKey(pk: Uint8Array): Uint8Array
ecdh function
export function ecdh(secret: Uint8Array, peer: Uint8Array): Uint8Array

RFC 7748 ECDH; rejects an all-zero (low-order) result.

hkdfSha256 function
export function hkdfSha256(salt: Uint8Array | undefined, ikm: Uint8Array, info: Uint8Array, len: number): Uint8Array
counterViewTag function
export function counterViewTag(ikm: Uint8Array, prefix: string, counter: bigint): Uint8Array

A zero byte then 31 HKDF bytes, `info = prefix || u64_be(counter)`.

RoleSecrets interface
export interface RoleSecrets
roleExpansion function
export function roleExpansion(
evmOwnerIdentity function
export function evmOwnerIdentity(address: Address): bigint

`(0x45 << 160) | address`: hash_bytes_21(0x45 || addr), no Poseidon needed.

nullifierPublicKey function
export function nullifierPublicKey(nullifierSecret: bigint): bigint
ownerHash function
export function ownerHash(ownerIdentity: bigint, nullifierPk: bigint): bigint
ViewingKey class
export class ViewingKey
ShieldedAddress interface
export interface ShieldedAddress

What a sender needs to pay this wallet: published in the registry.

ShieldedKeys class
export class ShieldedKeys
unlockShieldedKeys function
export async function unlockShieldedKeys(

Signs the derivation typed data twice and refuses a wallet whose signatures differ (non-deterministic ECDSA): such a wallet would lose its notes.

NON_DETERMINISTIC_SIGNER_ERROR const
export const NON_DETERMINISTIC_SIGNER_ERROR =
encodeShieldedAddress function
export function encodeShieldedAddress(a: ShieldedAddress): Uint8Array

`0x03 || address(20) || nullifier_pk(32) || viewing_pk(33)` = 86 B.

decodeShieldedAddress function
export function decodeShieldedAddress(bytes: Uint8Array): ShieldedAddress

node

localBinaryProver function
export function localBinaryProver(bin: string, opts: { keysDir?: string } = {}): Prover

Local binary (`<bin> prove -keys <dir>` reading the witness on stdin). Node only.

protocol

TREE_ID const
export const TREE_ID = 1;
EMPTY_NULLIFIER_ROOT const
export const EMPTY_NULLIFIER_ROOT = 0x1d8e71a601b3e8debbba9b557b8369c7f404ae57bebf0852236b072820954277n;
EMPTY_UTXO_ROOT const
export const EMPTY_UTXO_ROOT = 0x2f68a1c58e257e42a17a6c61dff5551ed560b9922ab119d5ac8e184c9734ead9n;
ROOT_HISTORY const
export const ROOT_HISTORY = 500;
ACTION_TRANSACT const
export const ACTION_TRANSACT = 1;
ACTION_MERGE const
export const ACTION_MERGE = 2;
ZERO_ADDRESS const
export const ZERO_ADDRESS: Address = "0x0000000000000000000000000000000000000000";
ETH_TOKEN const
export const ETH_TOKEN: Address = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
assetField function
export function assetField(token: Address): bigint

asset_id(token) = hash_bytes_32(bytes32(uint160(token))) = Poseidon(uint160 >> 8, uint160 & 0xff).

scaleFor function
export function scaleFor(decimals: number): bigint

scale = 10**(decimals - 9) when decimals > 9, else 1. Amounts on chain are units = base / scale.

MAX_UNITS const
export const MAX_UNITS = (1n << 64n) - 1n;
AssetInfo interface
export interface AssetInfo
plaintextAssetId function
export function plaintextAssetId(token: Address): bigint

SDK plaintext asset id (u64 in the 50-byte confidential plaintext) = low 64 bits of asset_id(token). Any registered asset works; the recipient resolves the id against the assets it knows (AssetRegistered events) and the commitment check confirms it.

AssetRegistry class
export class AssetRegistry
DEFAULT_ASSETS const
export const DEFAULT_ASSETS: readonly AssetInfo[] = [

Robinhood Chain assets (LAUNCH.md / PROTOCOL.md section 2). For any other token, and to check these against the pool, use `Rings.resolveAsset` (it reads `pool.assetScale`).

toUnits function
export function toUnits(base: bigint, a: AssetInfo): bigint

Base amount (wei, token base units) to pool units. Refuses dust that the pool cannot hold.

fromUnits function
export function fromUnits(units: bigint, a: AssetInfo): bigint
ownerTag function
export function ownerTag(identity: bigint): Hex

viewTag(output) = bytes32(identity(owner)).

HEADER_TRANSFER const
export const HEADER_TRANSFER = 1;
encodeHeader function
export function encodeHeader(txViewingPk: Uint8Array, salt: Uint8Array): Hex

header = type_prefix u8 (1) || tx_viewing_pk (33, 0x04 || u) || salt (16) = 50 B.

decodeHeader function
export function decodeHeader(h: Hex): { txViewingPk: Uint8Array; salt: Uint8Array } | undefined
ExtData interface
export interface ExtData
externalDataHash function
export function externalDataHash(e: ExtData, ctx: { chainId: bigint; pool: Address; action?: number }): bigint
mergeExternalDataHash function
export function mergeExternalDataHash(ctx: { chainId: bigint; pool: Address }): bigint
POOL_ABI const
export const POOL_ABI = [
ERC20_ABI const
export const ERC20_ABI = [
ownerAuthTypedData function
export function ownerAuthTypedData(p: { chainId: bigint; pool: Address; publicInputHash: bigint; deadline: bigint; submitter: Address })

`submitter` is the address that will call the pool (the pool checks it against `msg.sender`): the relayer's sending address, or a contract (PrivateEscrow / PrivateSwap for a lock, the deal vault for a swap fill). No other sender can use the signature.

prover

ProverInputJson interface
export interface ProverInputJson
ProverOutputJson interface
export interface ProverOutputJson
TransactProverRequest interface
export interface TransactProverRequest
MergeProverRequest interface
export interface MergeProverRequest
ProverRequest type
export type ProverRequest = TransactProverRequest | MergeProverRequest;
ProveResult interface
export interface ProveResult
Prover interface
export interface Prover
httpProver function
export function httpProver(url: string, opts: { fetch?: typeof fetch; headers?: Record<string, string> } = {}): Prover

Remote prover over HTTP (`POST {url}/prove`). The witness holds the nullifier secret: use a prover you trust.

checkProveResult function
export function checkProveResult(

Asserts the prover's derived values equal the SDK's.

hexField const
export const hexField = fieldHex;

registry

REGISTRY_ABI const
export const REGISTRY_ABI = [
RecipientNotRegisteredError class
export class RecipientNotRegisteredError extends Error
resolveShieldedAddress function
export async function resolveShieldedAddress(

Look up a recipient. - With `publicClient` and `registry`: the answer is `ShieldedRegistry.get` on chain, always. The indexer is not asked; an RPC error is thrown (no silent fall back to the indexer). - Without them (no chain access configured): the indexer record is used. It is NOT verified. Use this mode for display only, or pass `publicClient` and `registry`.

verifyRegistryRecord function
export async function verifyRegistryRecord(

Check an indexer (cache) record against the chain. Returns true when the chain holds exactly this record. Use it before you trust a record that came from the indexer.

registerShieldedAddress function
export async function registerShieldedAddress(p:

Simulate, then send `register` for this wallet's keys. Returns the tx hash.

isRegistered function
export async function isRegistered(keys: ShieldedKeys, src: { indexer?: IndexerApi; publicClient?: PublicClient; registry?: Address })

True when the registry already holds exactly this wallet's keys.

rpc-indexer

MerkleMirror class
export class MerkleMirror
RpcIndexer class
export class RpcIndexer implements IndexerApi

select

MAX_SPEND_INPUTS const
export const MAX_SPEND_INPUTS = 40;
Shape interface
export interface Shape
TRANSFER_SHAPES const
export const TRANSFER_SHAPES: readonly Shape[] = [

Ordered by proving cost; the first that fits wins.

MERGE_INPUT_COUNTS const
export const MERGE_INPUT_COUNTS: readonly number[] = [8];
pickShape function
export function pickShape(nInputs: number, nOutputs: number, shapes: readonly Shape[] = TRANSFER_SHAPES): Shape
maxSpendInputs function
export function maxSpendInputs(nOutputs: number, shapes: readonly Shape[] = TRANSFER_SHAPES): number
SelectionError class
export class SelectionError extends Error
Selection interface
export interface Selection
selectNotes function
export function selectNotes(

Largest-first cover of `amount` in `asset`. Throws TOO_MANY_INPUTS when the balance is enough but fragmented past the widest shape: merge first (see `planMerges`).

MergeBatch interface
export interface MergeBatch
planMerges function
export function planMerges(

Plan merges for one asset: smallest notes first, batches of the widest merge width, until the asset has at most `target` notes left (default: what one 8-input transfer can spend). Each batch turns k notes into 1.

transact

SpendInput interface
export interface SpendInput
OutputRequest interface
export interface OutputRequest
TransactPlanInput interface
export interface TransactPlanInput
PlannedOutput interface
export interface PlannedOutput
TransactPlan interface
export interface TransactPlan
planTransact function
export function planTransact(p: TransactPlanInput): TransactPlan
ownNotesOf function
export function ownNotesOf(plan: TransactPlan, keys: ShieldedKeys): PlannedOutput[]

The change note this wallet will own after the tx lands (leaf index unknown until then).

utxo

UTXO_DOMAIN const
export const UTXO_DOMAIN = 3n;
DUMMY_DOMAIN const
export const DUMMY_DOMAIN = 1n;
ADDRESS_DOMAIN const
export const ADDRESS_DOMAIN = 2n;
STATE_TREE_HEIGHT const
export const STATE_TREE_HEIGHT = 32;
NULLIFIER_TREE_HEIGHT const
export const NULLIFIER_TREE_HEIGHT = 40;
INPUT_TREES const
export const INPUT_TREES = 5;
N_PUBLIC_SLOTS const
export const N_PUBLIC_SLOTS = 3;
TXOS const
export const TXOS = tag4("TXOS");
TXOB const
export const TXOB = tag4("TXOB");
TXPB const
export const TXPB = tag4("TXPB");
TMOB const
export const TMOB = tag4("TMOB");
TMDN const
export const TMDN = tag4("TMDN");
TMOK const
export const TMOK = tag4("TMOK");
TMOC const
export const TMOC = tag4("TMOC");
Note interface
export interface Note

A spendable note this wallet owns.

UtxoBody interface
export interface UtxoBody
ownerUtxoHash function
export function ownerUtxoHash(owner: bigint, blinding: bigint): bigint
ringHash function
export function ringHash(ringDataHash = 0n, ringProgramId = 0n): bigint
utxoHash function
export function utxoHash(u: UtxoBody, treeId: number): bigint
dummyUtxoHash function
export function dummyUtxoHash(blinding: bigint, treeId: number): bigint

An empty (dummy, DummyDomain) UTXO: every body field 0 except blinding.

nullifier function
export function nullifier(utxoHashValue: bigint, blinding: bigint, nullifierSecret: bigint): bigint
outputBlindingSeed function
export function outputBlindingSeed(firstNullifier: bigint, blindingSeed: bigint): bigint
outputBlinding function
export function outputBlinding(firstNullifier: bigint, outputSeed: bigint, i: number): bigint

blinding_i = Poseidon("TXOB", first_nullifier, output_blinding_seed, i).

privateTxBlinding function
export function privateTxBlinding(firstNullifier: bigint, blindingSeed: bigint): bigint
randomBlindingSeed function
export function randomBlindingSeed(): bigint
depositBlinding function
export function depositBlinding(treeAccount: Uint8Array, leafIndex: bigint): bigint

zolana deposit blinding: Sha256BE("Deposit" || tree_account || u64_be(leaf_index)). On EVM the tree account is the 20-byte pool address (PROTOCOL.md decides the exact preimage; the contract derives it, the SDK only reads it back).

mergeOutputBlinding function
export function mergeOutputBlinding(nullifierSecret: bigint, firstNullifier: bigint): bigint
mergeDummyNullifier function
export function mergeDummyNullifier(nullifierSecret: bigint, firstNullifier: bigint, slot: number): bigint
mergeOutputKey function
export function mergeOutputKey(nullifierSecret: bigint, firstNullifier: bigint): bigint
mergePrivateTxBlinding function
export function mergePrivateTxBlinding(nullifierSecret: bigint, firstNullifier: bigint): bigint
privateTxHash function
export function privateTxHash(

private_tx_hash = Poseidon(nz(input_hashes), nz(output_hashes), nz(address_nullifiers), blinding). Pass 0 for padding / dummy slots.

TreeSlot interface
export interface TreeSlot
ZERO_TREE_SLOT const
export const ZERO_TREE_SLOT: TreeSlot = { id: 0, utxoRoot: 0n, nullifierRoot: 0n };
treeSlotHash function
export function treeSlotHash(s: TreeSlot): bigint
inputTreeSlots function
export function inputTreeSlots(slots: readonly TreeSlot[]): TreeSlot[]

Pads to INPUT_TREES slots with zero slots.

treeSlotChain function
export function treeSlotChain(slots: readonly TreeSlot[]): bigint
inputFlags function
export function inputFlags(allowDummyInputs: boolean, treeIndexes: readonly number[]): bigint

bit 0 = allow_dummy_inputs; input i's 3-bit tree index at bit 1 + 3i.

mergeOutputPads function
export function mergeOutputPads(key: bigint, salt: Uint8Array): [bigint, bigint, bigint]

PoseidonCtrV1 merge-output cipher (amount, mint chunk 0, mint chunk 1).

wallet

HistoryEntry interface
export interface HistoryEntry
WorldView interface
export interface WorldView

Only public fields: what any observer of the chain sees.

worldView function
export function worldView(tx: IndexedTx): WorldView
tagToAddress function
export function tagToAddress(tag: Hex): Address

bytes32 owner tag (0x45 << 160 | addr) back to the address.

WalletState interface
export interface WalletState
PrivateWallet class
export class PrivateWallet
encodeTxViewingKey function
export function encodeTxViewingKey(txHash: Hex, secret: Uint8Array): string

`rtvk1:` || hex(txHash 32 || tx_viewing_sk 32). Read-only: it opens one tx, it cannot spend.

decodeTxViewingKey function
export function decodeTxViewingKey(s: string): { txHash: Hex; key: ViewingKey }
DisclosedTx interface
export interface DisclosedTx
openDisclosedTx function
export async function openDisclosedTx(

Third party: open every output of the one disclosed tx; checks the key matches the tx.

witness

TransferPublicInputs interface
export interface TransferPublicInputs
transferPublicInputHash function
export function transferPublicInputHash(p: TransferPublicInputs): bigint
emptyCacheReadHashChain function
export function emptyCacheReadHashChain(nInputs: number): bigint

Cache selection when no cache is read: tree id 0, chain over n_inputs zeros.

signerWidth function
export function signerWidth(nInputs: number): number

signer_width = owner_signer_slots(n) + 1, owner_signer_slots(n) = min(n, 60 - n).

fieldAmount function
export function fieldAmount(v: bigint): bigint

Signed amount into the field: deposits positive, withdrawals p - |x|.

publicSlots function
export function publicSlots(legs: readonly { asset: bigint; amount: bigint }[]): { assets: bigint[]; amounts: bigint[] }

Aggregate settlement legs by asset in first-appearance order, drop zero nets, pad with (0, 0).

MerklePath interface
export interface MerklePath
NullifierNonInclusion interface
export interface NullifierNonInclusion

Indexed (low-leaf) non-inclusion proof against the nullifier tree.

CircuitUtxo interface
export interface CircuitUtxo
WitnessInput interface
export interface WitnessInput
WitnessOutput interface
export interface WitnessOutput
TransferWitness interface
export interface TransferWitness extends TransferPublicInputs
ZolanaProverRequest type
export type ZolanaProverRequest = Record<string, unknown> & { circuitType: string; nInputs: number; nOutputs: number };
transferProverRequest function
export function transferProverRequest(w: TransferWitness): ZolanaProverRequest

The zolana prover request body for `transfer-confidential` (shape nInputs x nOutputs).

MergePublicInputs interface
export interface MergePublicInputs
mergePublicInputHash function
export function mergePublicInputHash(p: MergePublicInputs): bigint

Default merge (merge_transact, PoseidonCtrV1): 13 elements.