Skip to main content
Version: develop

Types

Branded types

Branded types prevent accidentally mixing different kinds of hex strings.

TypeShapeDescription
ZkpAddress`zk${string}`Bech32m ZK balance address
EvmAddress`0x${string}`EVM account or contract address
HexSignature`0x${string}`ECDSA secp256k1 signature (65 bytes)

Token types

TypeDescription
TokenToken name string (e.g., 'zkUSD', 'zkEUR')
TokenMapRecord<string, EvmAddress> -- maps token names to contract addresses

Cryptographic types

TypeDescription
Point{ x: bigint, y: bigint } -- Grumpkin curve point
GrumpkinPublicKeyAlias for Point -- encryption public key (EPK)
ElGamalCiphertext{ R: Point, C: Point } -- encrypted value
EncryptionSecretKeyBranded bigint -- Grumpkin scalar
ControllerSpendingKeyBranded Uint8Array -- secp256k1 private key

Transaction types

TypeDescription
PreparedTransaction{ tokenAddress, functionName, args } -- ready to submit
UnsignedTransaction{ tokenAddress, functionName, args, typedData, nonce, signatureArgName } -- needs EIP-712 signature before submission

UnsignedTransaction details

Used for any action whose calldata embeds an EIP-712 signature — controller auth for ZKP actions, permit for publicToEncryptedTransferWithAuth.

  • args -- named by ABI parameter, excludes the signature itself.
  • signatureArgName -- which ABI input (or dotted path) the signature is placed under when assembling a PreparedTransaction. Closed set: 'signature' (permit) or 'auth.signature' (controller-signed ZKP actions — inserted inside the auth tuple).
  • Produced by prepareEncryptedTransfer, prepareEncryptedToPublicTransfer, preparePublicToEncryptedTransferWithAuth. Consumed by signTransaction / signAuthorization / toSignedTransaction.

Log types

TypeDescription
EncryptedBalanceLogRaw on-chain event (amounts may be ciphertexts)
DecryptedBalanceLogPlaintext version (amounts are bigint)

Both are discriminated unions with type: 'deposit' | 'withdrawal' | 'transfer_in' | 'transfer_out'. Common fields: txHash, blockNumber, amount. Transfer types also include transferId and counterparty info.

Callback types

TypeDescription
ProgressCallback(info: { step: number, total: number, stage: string }) => void

Backend interfaces

TypeDescription
Solver{ init(), solve(point), destroy() } -- discrete log solver
Prover{ prove(inputs), prewarm?(), destroy() } -- ZK proof generator

EIP-712 types

TypeDescription
TypedDataToSign{ domain, types, primaryType, message } -- EIP-712 typed data