vellum-sdk
v0.1.1
Published
Vellum Privacy Middleware SDK for RWA Issuers
Maintainers
Readme
Vellum SDK
Version 0.1.0
The Vellum SDK is a plug-and-play middleware for RWA issuers on the Mantle Network. It allows you to embed conditional privacy flows into your protocol, enabling the tokenization of assets like invoices with ZK-enforced compliance (EdDSA signatures, Poseidon nullifiers, and ECDH encryption).
This SDK handles the "heavy lifting" of zero-knowledge privacy: client-side encryption, IPFS pinning, ZK input piping, and atomic minting transactions.
Vellum SDK Usage
1. Installation
npm install vellum-sdk viem2. Import Core Functions
You can import the core logic pipelines directly if you are managing your own state, or use the React hooks for quicker integration.
import { forgeInputs, atomicMintBundle, queryCompliance } from 'vellum-sdk';3. Pipeline: Forge, Prove, Mint
The standard flow for an issuer involves three stages: piping the data, generating the proof, and bundling the transaction.
Step A: Pipe Issuer Data Run the client-side pipeline to encrypt the PDF (ZK-bound AES), pin to IPFS, and hash details for the circuit.
const { privateInputs, publicInputs, pinMetadata } = await forgeInputs({
amount: 50000,
dueDate: 1767225600, // Unix Timestamp
invoiceId: "INV-902-ACME",
file: pdfFileObject // Optional
});Step B: Prove (Using SnarkJS)
Pass the privateInputs and publicInputs to your Circom prover (SnarkJS).
// This typically runs in a Web Worker
const { proof, publicSignals } = await snarkjs.groth16.fullProve(
{ ...privateInputs, ...publicInputs },
"circuit.wasm",
"circuit_final.zkey"
);Step C: Bundle Calldata & Mint
Generate the ABI-encoded calldata required for the VellumWrapper contract. This ensures the ciphertext on-chain matches the proof.
const calldata = atomicMintBundle(
proof,
publicInputs,
pinMetadata.ciphertext,
pinMetadata.IpfsHash,
privateInputs.nonce
);
// Send via Viem
await walletClient.writeContract({
address: VELLUM_ADDRESS,
abi: VellumABI,
functionName: 'mint',
args: [...calldata] // Spreads proof, inputs, ciphertext, hash
});4. Query & Decrypt
Auditors or the issuer can retrieve the encrypted data from Mantle event logs and decrypt it using the private key.
const logs = await publicClient.getLogs({ ... });
const decryptedLog = await queryCompliance(
logs[0].args.tokenId,
userEphemeralPriv, // The private key key used in Step A
logs[0].args.nonce
);
console.log(decryptedLog.amount); // 50000Examples
For a full React implementation, see the examples/ folder.
// Reference Logic Flow for Embeds
const runEmbedFlow = async (data) => {
// 1. Forge
const pipeline = await forgeInputs(data);
// 2. Prove
const zkResult = await prove(pipeline.inputs);
// 3. Mint
const tx = await mint(zkResult, pipeline.meta);
return tx.hash;
};Centrifuge Pilot Roadmap
- Q1: Embed in TaaS for Bonds.
- Q2: Integration with secondary market liquidity pools.
License
MIT
