Skip to main content

SDK Overview

r14 SDK is the primary Rust crate for building dapps on Root14. It re-exports core types, provides wallet persistence, Merkle tree utilities, Soroban contract interaction, proof serialization, and optional ZK proof generation.

Modules​

ModuleWhat it does
crate rootRe-exports core types and Poseidon functions
walletWallet JSON persistence, hex-to-Fr conversion
merkleOffline and indexer-backed Merkle root computation
sorobanStellar CLI wrapper for on-chain contract calls
serializeGroth16 proof/VK to hex for Soroban contracts
proveZK proof generation (feature-gated behind prove)

Feature Flags​

[dependencies]
r14-sdk = "0.1" # core modules only
r14-sdk = { version = "0.1", features = ["prove"] } # + ZK proving

The prove feature pulls in r14 circuit (arkworks Groth16) and the serialization helpers needed to submit proofs on-chain. Without it, the crate compiles faster and avoids heavy cryptographic dependencies - useful for indexers, wallets, or any service that only reads/submits pre-built proofs.

Re-exported Types​

These are available at the crate root (r14_sdk::SecretKey, etc.) so downstream code never needs to depend on r14 types or r14 poseidon directly.

ItemSourceDescription
SecretKeyr14 typesWrapper around Fr. Create with SecretKey::random(&mut rng).
Noter14 typesUTXO: value + app_tag + owner + nonce.
Nullifierr14 typesSpend tag derived from secret key and nonce. Prevents double-spend.
MerklePathr14 typesSibling hashes + index bits for a Merkle inclusion proof.
MerkleRootr14 typesWrapper around Fr representing the tree root.
MERKLE_DEPTHr14 typesTree depth, currently 20.
commitment()r14 poseidonPoseidon(value, app_tag, owner, nonce) - leaf hash.
nullifier()r14 poseidonPoseidon(sk, nonce) - spend nullifier.
owner_hash()r14 poseidonPoseidon(sk) - public owner identifier.
hash2()r14 poseidonTwo-input Poseidon hash used for Merkle nodes.

Minimal Example​

use r14_sdk::{SecretKey, Note, commitment, owner_hash, wallet};

fn main() {
let mut rng = wallet::crypto_rng();
let sk = SecretKey::random(&mut rng);
let owner = owner_hash(&sk);

let note = Note::new(1_000_000, 0, owner, Fr::rand(&mut rng));
let cm = commitment(&note);

println!("commitment: {}", wallet::fr_to_hex(&cm));
}