@claviss/sdk 0.1.0

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.
Files changed (42) hide show
  1. package/README.md +33 -0
  2. package/dist/chain/abi.d.ts +1149 -0
  3. package/dist/chain/abi.js +5 -0
  4. package/dist/chain/chains.d.ts +106 -0
  5. package/dist/chain/chains.js +24 -0
  6. package/dist/chain/index.d.ts +2 -0
  7. package/dist/chain/index.js +2 -0
  8. package/dist/index.d.ts +22 -0
  9. package/dist/index.js +22 -0
  10. package/dist/pool/crypto.d.ts +17 -0
  11. package/dist/pool/crypto.js +79 -0
  12. package/dist/pool/index.d.ts +3 -0
  13. package/dist/pool/index.js +3 -0
  14. package/dist/pool/note.d.ts +22 -0
  15. package/dist/pool/note.js +66 -0
  16. package/dist/pool/prover.d.ts +35 -0
  17. package/dist/pool/prover.js +48 -0
  18. package/dist/shielded/index.d.ts +4 -0
  19. package/dist/shielded/index.js +4 -0
  20. package/dist/shielded/keypair.d.ts +23 -0
  21. package/dist/shielded/keypair.js +72 -0
  22. package/dist/shielded/note.d.ts +22 -0
  23. package/dist/shielded/note.js +32 -0
  24. package/dist/shielded/prover.d.ts +56 -0
  25. package/dist/shielded/prover.js +100 -0
  26. package/dist/shielded/scan.d.ts +21 -0
  27. package/dist/shielded/scan.js +28 -0
  28. package/dist/stealth/index.d.ts +2 -0
  29. package/dist/stealth/index.js +2 -0
  30. package/dist/stealth/scanner.d.ts +20 -0
  31. package/dist/stealth/scanner.js +31 -0
  32. package/dist/stealth/stealth.d.ts +41 -0
  33. package/dist/stealth/stealth.js +122 -0
  34. package/dist/zk/calldata.d.ts +21 -0
  35. package/dist/zk/calldata.js +11 -0
  36. package/dist/zk/index.d.ts +3 -0
  37. package/dist/zk/index.js +3 -0
  38. package/dist/zk/merkle.d.ts +36 -0
  39. package/dist/zk/merkle.js +92 -0
  40. package/dist/zk/prover.d.ts +20 -0
  41. package/dist/zk/prover.js +27 -0
  42. package/package.json +49 -0
@@ -0,0 +1,5 @@
1
+ // Generated from the Foundry artifacts (contracts/out) — regenerate after contract changes:
2
+ // npm run gen:abi
3
+ export const CredentialGroupsAbi = [{ "type": "constructor", "inputs": [{ "name": "verifier_", "type": "address", "internalType": "contract ICredentialVerifier" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "acceptAuthority", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "createGroup", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "currentRoot", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "groupAuthority", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "isKnownRoot", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }, { "name": "root", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "nullifierUsed", "inputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }, { "name": "", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "publishRoot", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }, { "name": "newRoot", "type": "bytes32", "internalType": "bytes32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "rootCount", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }], "outputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "transferAuthority", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }, { "name": "newAuthority", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "verifier", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract ICredentialVerifier" }], "stateMutability": "view" }, { "type": "function", "name": "verify", "inputs": [{ "name": "groupId", "type": "uint64", "internalType": "uint64" }, { "name": "externalNullifier", "type": "bytes32", "internalType": "bytes32" }, { "name": "pA", "type": "uint256[2]", "internalType": "uint256[2]" }, { "name": "pB", "type": "uint256[2][2]", "internalType": "uint256[2][2]" }, { "name": "pC", "type": "uint256[2]", "internalType": "uint256[2]" }, { "name": "signals", "type": "uint256[4]", "internalType": "uint256[4]" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "event", "name": "AuthorityTransferStarted", "inputs": [{ "name": "groupId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "current", "type": "address", "indexed": false, "internalType": "address" }, { "name": "pending", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "AuthorityTransferred", "inputs": [{ "name": "groupId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "oldAuthority", "type": "address", "indexed": false, "internalType": "address" }, { "name": "newAuthority", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "Disclosed", "inputs": [{ "name": "groupId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "nullifierHash", "type": "bytes32", "indexed": true, "internalType": "bytes32" }, { "name": "merkleRoot", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "externalNullifier", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "signalHash", "type": "bytes32", "indexed": false, "internalType": "bytes32" }], "anonymous": false }, { "type": "event", "name": "GroupCreated", "inputs": [{ "name": "groupId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "authority", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "RootPublished", "inputs": [{ "name": "groupId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "root", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "index", "type": "uint32", "indexed": false, "internalType": "uint32" }], "anonymous": false }, { "type": "error", "name": "GroupExists", "inputs": [] }, { "type": "error", "name": "InvalidProof", "inputs": [] }, { "type": "error", "name": "NotAuthority", "inputs": [] }, { "type": "error", "name": "NotPendingAuthority", "inputs": [] }, { "type": "error", "name": "NullifierAlreadyUsed", "inputs": [] }, { "type": "error", "name": "ScopeMismatch", "inputs": [] }, { "type": "error", "name": "UnknownGroup", "inputs": [] }, { "type": "error", "name": "UnknownRoot", "inputs": [] }, { "type": "error", "name": "ZeroAddress", "inputs": [] }, { "type": "error", "name": "ZeroRoot", "inputs": [] }];
4
+ export const PrivacyPoolsAbi = [{ "type": "constructor", "inputs": [{ "name": "verifier_", "type": "address", "internalType": "contract IWithdrawVerifier" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "acceptAuthority", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "commitmentLeaf", "inputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }, { "name": "", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "createPool", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }, { "name": "denomination", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "currentRoot", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "deposit", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }, { "name": "commitment", "type": "bytes32", "internalType": "bytes32" }], "outputs": [], "stateMutability": "payable" }, { "type": "function", "name": "isKnownRoot", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }, { "name": "root", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "nullifierSpent", "inputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }, { "name": "", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "poolInfo", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }], "outputs": [{ "name": "authority", "type": "address", "internalType": "address" }, { "name": "denomination", "type": "uint256", "internalType": "uint256" }, { "name": "numCommitments", "type": "uint64", "internalType": "uint64" }, { "name": "balance", "type": "uint256", "internalType": "uint256" }, { "name": "associationRoot", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "publishPoolRoot", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }, { "name": "newRoot", "type": "bytes32", "internalType": "bytes32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setAssociationRoot", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }, { "name": "associationRoot", "type": "bytes32", "internalType": "bytes32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "transferAuthority", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }, { "name": "newAuthority", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "verifier", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract IWithdrawVerifier" }], "stateMutability": "view" }, { "type": "function", "name": "withdraw", "inputs": [{ "name": "poolId", "type": "uint64", "internalType": "uint64" }, { "name": "recipient", "type": "address", "internalType": "address payable" }, { "name": "fee", "type": "uint256", "internalType": "uint256" }, { "name": "pA", "type": "uint256[2]", "internalType": "uint256[2]" }, { "name": "pB", "type": "uint256[2][2]", "internalType": "uint256[2][2]" }, { "name": "pC", "type": "uint256[2]", "internalType": "uint256[2]" }, { "name": "signals", "type": "uint256[6]", "internalType": "uint256[6]" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "event", "name": "AssociationRootSet", "inputs": [{ "name": "poolId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "associationRoot", "type": "bytes32", "indexed": false, "internalType": "bytes32" }], "anonymous": false }, { "type": "event", "name": "AuthorityTransferStarted", "inputs": [{ "name": "poolId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "current", "type": "address", "indexed": false, "internalType": "address" }, { "name": "pending", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "AuthorityTransferred", "inputs": [{ "name": "poolId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "oldAuthority", "type": "address", "indexed": false, "internalType": "address" }, { "name": "newAuthority", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "Deposited", "inputs": [{ "name": "poolId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "commitment", "type": "bytes32", "indexed": true, "internalType": "bytes32" }, { "name": "leafIndex", "type": "uint64", "indexed": false, "internalType": "uint64" }], "anonymous": false }, { "type": "event", "name": "PoolCreated", "inputs": [{ "name": "poolId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "authority", "type": "address", "indexed": false, "internalType": "address" }, { "name": "denomination", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "PoolRootPublished", "inputs": [{ "name": "poolId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "root", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "index", "type": "uint32", "indexed": false, "internalType": "uint32" }], "anonymous": false }, { "type": "event", "name": "Withdrawn", "inputs": [{ "name": "poolId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "nullifierHash", "type": "bytes32", "indexed": true, "internalType": "bytes32" }, { "name": "recipient", "type": "address", "indexed": false, "internalType": "address" }, { "name": "fee", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "error", "name": "DuplicateCommitment", "inputs": [] }, { "type": "error", "name": "FeeExceedsDenomination", "inputs": [] }, { "type": "error", "name": "FeeMismatch", "inputs": [] }, { "type": "error", "name": "InvalidProof", "inputs": [] }, { "type": "error", "name": "NotAuthority", "inputs": [] }, { "type": "error", "name": "NotPendingAuthority", "inputs": [] }, { "type": "error", "name": "NullifierAlreadySpent", "inputs": [] }, { "type": "error", "name": "PoolExists", "inputs": [] }, { "type": "error", "name": "RecipientMismatch", "inputs": [] }, { "type": "error", "name": "ReentrantCall", "inputs": [] }, { "type": "error", "name": "TransferFailed", "inputs": [] }, { "type": "error", "name": "UnknownAssociationRoot", "inputs": [] }, { "type": "error", "name": "UnknownPool", "inputs": [] }, { "type": "error", "name": "UnknownRoot", "inputs": [] }, { "type": "error", "name": "WrongDepositValue", "inputs": [] }, { "type": "error", "name": "ZeroAddress", "inputs": [] }, { "type": "error", "name": "ZeroDenomination", "inputs": [] }, { "type": "error", "name": "ZeroRoot", "inputs": [] }];
5
+ export const ShieldedPoolsAbi = [{ "type": "constructor", "inputs": [{ "name": "verifier_", "type": "address", "internalType": "contract ITransactionVerifier" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "acceptAuthority", "inputs": [{ "name": "shieldedId", "type": "uint64", "internalType": "uint64" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "createShielded", "inputs": [{ "name": "shieldedId", "type": "uint64", "internalType": "uint64" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "currentRoot", "inputs": [{ "name": "shieldedId", "type": "uint64", "internalType": "uint64" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "isKnownRoot", "inputs": [{ "name": "shieldedId", "type": "uint64", "internalType": "uint64" }, { "name": "root", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "nullifierSpent", "inputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }, { "name": "", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "publishShieldedRoot", "inputs": [{ "name": "shieldedId", "type": "uint64", "internalType": "uint64" }, { "name": "newRoot", "type": "bytes32", "internalType": "bytes32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "shieldedInfo", "inputs": [{ "name": "shieldedId", "type": "uint64", "internalType": "uint64" }], "outputs": [{ "name": "authority", "type": "address", "internalType": "address" }, { "name": "numCommitments", "type": "uint64", "internalType": "uint64" }, { "name": "balance", "type": "uint256", "internalType": "uint256" }, { "name": "rootCount", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "transact", "inputs": [{ "name": "shieldedId", "type": "uint64", "internalType": "uint64" }, { "name": "ext", "type": "tuple", "internalType": "struct ShieldedPools.ExtData", "components": [{ "name": "recipient", "type": "address", "internalType": "address" }, { "name": "relayer", "type": "address", "internalType": "address" }, { "name": "extAmount", "type": "int256", "internalType": "int256" }, { "name": "fee", "type": "uint256", "internalType": "uint256" }, { "name": "encryptedOutput1", "type": "bytes", "internalType": "bytes" }, { "name": "encryptedOutput2", "type": "bytes", "internalType": "bytes" }] }, { "name": "pA", "type": "uint256[2]", "internalType": "uint256[2]" }, { "name": "pB", "type": "uint256[2][2]", "internalType": "uint256[2][2]" }, { "name": "pC", "type": "uint256[2]", "internalType": "uint256[2]" }, { "name": "signals", "type": "uint256[7]", "internalType": "uint256[7]" }], "outputs": [], "stateMutability": "payable" }, { "type": "function", "name": "transferAuthority", "inputs": [{ "name": "shieldedId", "type": "uint64", "internalType": "uint64" }, { "name": "newAuthority", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "verifier", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract ITransactionVerifier" }], "stateMutability": "view" }, { "type": "event", "name": "AuthorityTransferStarted", "inputs": [{ "name": "shieldedId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "current", "type": "address", "indexed": false, "internalType": "address" }, { "name": "pending", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "AuthorityTransferred", "inputs": [{ "name": "shieldedId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "oldAuthority", "type": "address", "indexed": false, "internalType": "address" }, { "name": "newAuthority", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "ShieldedCreated", "inputs": [{ "name": "shieldedId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "authority", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "ShieldedRootPublished", "inputs": [{ "name": "shieldedId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "root", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "index", "type": "uint32", "indexed": false, "internalType": "uint32" }], "anonymous": false }, { "type": "event", "name": "Transacted", "inputs": [{ "name": "shieldedId", "type": "uint64", "indexed": true, "internalType": "uint64" }, { "name": "nullifier1", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "nullifier2", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "outCommitment1", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "outCommitment2", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "leafIndexStart", "type": "uint64", "indexed": false, "internalType": "uint64" }, { "name": "encryptedOutput1", "type": "bytes", "indexed": false, "internalType": "bytes" }, { "name": "encryptedOutput2", "type": "bytes", "indexed": false, "internalType": "bytes" }], "anonymous": false }, { "type": "error", "name": "AmountOutOfRange", "inputs": [] }, { "type": "error", "name": "DuplicateNullifier", "inputs": [] }, { "type": "error", "name": "ExtDataHashMismatch", "inputs": [] }, { "type": "error", "name": "InsufficientPoolBalance", "inputs": [] }, { "type": "error", "name": "InvalidProof", "inputs": [] }, { "type": "error", "name": "NotAuthority", "inputs": [] }, { "type": "error", "name": "NotPendingAuthority", "inputs": [] }, { "type": "error", "name": "NullifierAlreadySpent", "inputs": [] }, { "type": "error", "name": "PublicAmountMismatch", "inputs": [] }, { "type": "error", "name": "ReentrantCall", "inputs": [] }, { "type": "error", "name": "ShieldedExists", "inputs": [] }, { "type": "error", "name": "TransferFailed", "inputs": [] }, { "type": "error", "name": "UnknownRoot", "inputs": [] }, { "type": "error", "name": "UnknownShielded", "inputs": [] }, { "type": "error", "name": "WrongDepositValue", "inputs": [] }, { "type": "error", "name": "ZeroAddress", "inputs": [] }, { "type": "error", "name": "ZeroRoot", "inputs": [] }];
@@ -0,0 +1,106 @@
1
+ export declare const robinhoodTestnet: {
2
+ blockExplorers: {
3
+ readonly default: {
4
+ readonly name: "Blockscout";
5
+ readonly url: "https://explorer.testnet.chain.robinhood.com";
6
+ };
7
+ };
8
+ blockTime?: number | undefined | undefined;
9
+ contracts?: {
10
+ [x: string]: import("viem").ChainContract | {
11
+ [sourceId: number]: import("viem").ChainContract | undefined;
12
+ } | undefined;
13
+ ensRegistry?: import("viem").ChainContract | undefined;
14
+ ensUniversalResolver?: import("viem").ChainContract | undefined;
15
+ multicall3?: import("viem").ChainContract | undefined;
16
+ erc6492Verifier?: import("viem").ChainContract | undefined;
17
+ } | undefined;
18
+ ensTlds?: readonly string[] | undefined;
19
+ id: 46630;
20
+ name: "Robinhood Chain Testnet";
21
+ nativeCurrency: {
22
+ readonly name: "Ether";
23
+ readonly symbol: "ETH";
24
+ readonly decimals: 18;
25
+ };
26
+ experimental_preconfirmationTime?: number | undefined | undefined;
27
+ rpcUrls: {
28
+ readonly default: {
29
+ readonly http: readonly ["https://rpc.testnet.chain.robinhood.com"];
30
+ };
31
+ };
32
+ sourceId?: number | undefined | undefined;
33
+ supportsTransactionReplacementDetection?: boolean | undefined | undefined;
34
+ testnet: true;
35
+ custom?: Record<string, unknown> | undefined;
36
+ extendSchema?: Record<string, unknown> | undefined;
37
+ fees?: import("viem").ChainFees<undefined> | undefined;
38
+ formatters?: undefined;
39
+ prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
40
+ client: import("viem").Client;
41
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
42
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
43
+ client: import("viem").Client;
44
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
45
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
46
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
47
+ }] | undefined;
48
+ serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
49
+ verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
50
+ };
51
+ export declare const robinhoodMainnet: {
52
+ blockExplorers: {
53
+ readonly default: {
54
+ readonly name: "Blockscout";
55
+ readonly url: "https://robinhoodchain.blockscout.com";
56
+ };
57
+ };
58
+ blockTime?: number | undefined | undefined;
59
+ contracts?: {
60
+ [x: string]: import("viem").ChainContract | {
61
+ [sourceId: number]: import("viem").ChainContract | undefined;
62
+ } | undefined;
63
+ ensRegistry?: import("viem").ChainContract | undefined;
64
+ ensUniversalResolver?: import("viem").ChainContract | undefined;
65
+ multicall3?: import("viem").ChainContract | undefined;
66
+ erc6492Verifier?: import("viem").ChainContract | undefined;
67
+ } | undefined;
68
+ ensTlds?: readonly string[] | undefined;
69
+ id: 4663;
70
+ name: "Robinhood Chain";
71
+ nativeCurrency: {
72
+ readonly name: "Ether";
73
+ readonly symbol: "ETH";
74
+ readonly decimals: 18;
75
+ };
76
+ experimental_preconfirmationTime?: number | undefined | undefined;
77
+ rpcUrls: {
78
+ readonly default: {
79
+ readonly http: readonly ["https://rpc.mainnet.chain.robinhood.com"];
80
+ };
81
+ };
82
+ sourceId?: number | undefined | undefined;
83
+ supportsTransactionReplacementDetection?: boolean | undefined | undefined;
84
+ testnet?: boolean | undefined | undefined;
85
+ custom?: Record<string, unknown> | undefined;
86
+ extendSchema?: Record<string, unknown> | undefined;
87
+ fees?: import("viem").ChainFees<undefined> | undefined;
88
+ formatters?: undefined;
89
+ prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
90
+ client: import("viem").Client;
91
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
92
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
93
+ client: import("viem").Client;
94
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
95
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
96
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
97
+ }] | undefined;
98
+ serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
99
+ verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
100
+ };
101
+ /** Deployed contract addresses for one environment. */
102
+ export interface ClavisAddresses {
103
+ credentialGroups: `0x${string}`;
104
+ privacyPools: `0x${string}`;
105
+ shieldedPools: `0x${string}`;
106
+ }
@@ -0,0 +1,24 @@
1
+ import { defineChain } from "viem";
2
+ export const robinhoodTestnet = defineChain({
3
+ id: 46630,
4
+ name: "Robinhood Chain Testnet",
5
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
6
+ rpcUrls: {
7
+ default: { http: ["https://rpc.testnet.chain.robinhood.com"] },
8
+ },
9
+ blockExplorers: {
10
+ default: { name: "Blockscout", url: "https://explorer.testnet.chain.robinhood.com" },
11
+ },
12
+ testnet: true,
13
+ });
14
+ export const robinhoodMainnet = defineChain({
15
+ id: 4663,
16
+ name: "Robinhood Chain",
17
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
18
+ rpcUrls: {
19
+ default: { http: ["https://rpc.mainnet.chain.robinhood.com"] },
20
+ },
21
+ blockExplorers: {
22
+ default: { name: "Blockscout", url: "https://robinhoodchain.blockscout.com" },
23
+ },
24
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./chains.js";
2
+ export * from "./abi.js";
@@ -0,0 +1,2 @@
1
+ export * from "./chains.js";
2
+ export * from "./abi.js";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Clavis EVM SDK — privacy primitives for Robinhood Chain.
3
+ *
4
+ * zk Selective disclosure: prove membership/eligibility without
5
+ * revealing which identity. (CredentialGroups)
6
+ * stealth One-time receive addresses (secp256k1, ERC-5564 style) so a main
7
+ * wallet isn't exposed.
8
+ * pool Compliant fixed-denomination privacy pool: ZK deposit/withdraw
9
+ * that severs the on-chain link, gated by an association set.
10
+ * (PrivacyPools)
11
+ * shielded Hidden-amount UTXO pool: arbitrary amounts, partial spends,
12
+ * change, multi-recipient — values stay encrypted. (ShieldedPools)
13
+ * chain Robinhood Chain definitions (viem) + contract ABIs.
14
+ *
15
+ * Every privacy feature keeps a disclosure/audit path: the pool is gated by an
16
+ * association set rather than being an unconditional tumbler.
17
+ */
18
+ export * as zk from "./zk/index.js";
19
+ export * as stealth from "./stealth/index.js";
20
+ export * as pool from "./pool/index.js";
21
+ export * as shielded from "./shielded/index.js";
22
+ export * as chain from "./chain/index.js";
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Clavis EVM SDK — privacy primitives for Robinhood Chain.
3
+ *
4
+ * zk Selective disclosure: prove membership/eligibility without
5
+ * revealing which identity. (CredentialGroups)
6
+ * stealth One-time receive addresses (secp256k1, ERC-5564 style) so a main
7
+ * wallet isn't exposed.
8
+ * pool Compliant fixed-denomination privacy pool: ZK deposit/withdraw
9
+ * that severs the on-chain link, gated by an association set.
10
+ * (PrivacyPools)
11
+ * shielded Hidden-amount UTXO pool: arbitrary amounts, partial spends,
12
+ * change, multi-recipient — values stay encrypted. (ShieldedPools)
13
+ * chain Robinhood Chain definitions (viem) + contract ABIs.
14
+ *
15
+ * Every privacy feature keeps a disclosure/audit path: the pool is gated by an
16
+ * association set rather than being an unconditional tumbler.
17
+ */
18
+ export * as zk from "./zk/index.js";
19
+ export * as stealth from "./stealth/index.js";
20
+ export * as pool from "./pool/index.js";
21
+ export * as shielded from "./shielded/index.js";
22
+ export * as chain from "./chain/index.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Derive a recipient's X25519 receiving keypair from a 32+ byte seed — e.g. the
3
+ * bytes of a wallet signature over a fixed message, so the identity is
4
+ * recoverable from the wallet alone and nothing is ever stored.
5
+ */
6
+ export declare function receiveKeypairFromSeed(seed: Uint8Array): {
7
+ priv: Uint8Array;
8
+ pub: Uint8Array;
9
+ };
10
+ /** Shareable encoding of a receiving public key (a "private-payment address"). */
11
+ export declare function encodeReceiveAddress(pub: Uint8Array): string;
12
+ export declare function decodeReceiveAddress(s: string): Uint8Array;
13
+ /** Encrypt a note string to a recipient's receiving public key. */
14
+ export declare function encryptNote(noteStr: string, recipientPub: Uint8Array): Promise<string>;
15
+ export declare function isEncryptedNote(s: string): boolean;
16
+ /** Decrypt an encrypted note with the recipient's receiving private key. */
17
+ export declare function decryptNote(blobStr: string, recipientPriv: Uint8Array): Promise<string>;
@@ -0,0 +1,79 @@
1
+ import { x25519 } from "@noble/curves/ed25519";
2
+ import { hkdf } from "@noble/hashes/hkdf";
3
+ import { sha256 } from "@noble/hashes/sha256";
4
+ // Encrypt a pool note to a recipient so a claim link can travel over a public
5
+ // channel: only the holder of the matching private key can decrypt it. ECIES =
6
+ // ephemeral X25519 ECDH -> HKDF-SHA256 -> AES-256-GCM. No extra deps (WebCrypto
7
+ // is present in the browser and in Node 20+).
8
+ const ENC_PREFIX = "clavis-enc-v1";
9
+ function b64url(bytes) {
10
+ let s = "";
11
+ for (const b of bytes)
12
+ s += String.fromCharCode(b);
13
+ return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
14
+ }
15
+ function unb64url(s) {
16
+ const b64 = s.replace(/-/g, "+").replace(/_/g, "/");
17
+ const pad = "=".repeat((4 - (b64.length % 4)) % 4);
18
+ const bin = atob(b64 + pad);
19
+ const out = new Uint8Array(bin.length);
20
+ for (let i = 0; i < bin.length; i++)
21
+ out[i] = bin.charCodeAt(i);
22
+ return out;
23
+ }
24
+ // A concrete ArrayBuffer copy, so the WebCrypto BufferSource types don't trip on
25
+ // the ArrayBufferLike/SharedArrayBuffer generic.
26
+ function buf(u) {
27
+ return u.slice().buffer;
28
+ }
29
+ /**
30
+ * Derive a recipient's X25519 receiving keypair from a 32+ byte seed — e.g. the
31
+ * bytes of a wallet signature over a fixed message, so the identity is
32
+ * recoverable from the wallet alone and nothing is ever stored.
33
+ */
34
+ export function receiveKeypairFromSeed(seed) {
35
+ const priv = sha256(seed); // 32 bytes; X25519 clamps internally
36
+ return { priv, pub: x25519.getPublicKey(priv) };
37
+ }
38
+ /** Shareable encoding of a receiving public key (a "private-payment address"). */
39
+ export function encodeReceiveAddress(pub) {
40
+ return b64url(pub);
41
+ }
42
+ export function decodeReceiveAddress(s) {
43
+ const pub = unb64url(s.trim());
44
+ if (pub.length !== 32)
45
+ throw new Error("invalid private-payment address");
46
+ return pub;
47
+ }
48
+ async function aesKey(shared) {
49
+ const raw = hkdf(sha256, shared, undefined, "clavis-pool-note", 32);
50
+ return crypto.subtle.importKey("raw", buf(raw), "AES-GCM", false, ["encrypt", "decrypt"]);
51
+ }
52
+ /** Encrypt a note string to a recipient's receiving public key. */
53
+ export async function encryptNote(noteStr, recipientPub) {
54
+ const eph = x25519.utils.randomPrivateKey();
55
+ const ephPub = x25519.getPublicKey(eph);
56
+ const shared = x25519.getSharedSecret(eph, recipientPub);
57
+ const key = await aesKey(shared);
58
+ const iv = crypto.getRandomValues(new Uint8Array(12));
59
+ const ct = new Uint8Array(await crypto.subtle.encrypt({ name: "AES-GCM", iv }, key, buf(new TextEncoder().encode(noteStr))));
60
+ const blob = new Uint8Array(32 + 12 + ct.length);
61
+ blob.set(ephPub, 0);
62
+ blob.set(iv, 32);
63
+ blob.set(ct, 44);
64
+ return `${ENC_PREFIX}:${b64url(blob)}`;
65
+ }
66
+ export function isEncryptedNote(s) {
67
+ return s.trim().startsWith(ENC_PREFIX + ":");
68
+ }
69
+ /** Decrypt an encrypted note with the recipient's receiving private key. */
70
+ export async function decryptNote(blobStr, recipientPriv) {
71
+ const blob = unb64url(blobStr.trim().slice(ENC_PREFIX.length + 1));
72
+ const ephPub = blob.slice(0, 32);
73
+ const iv = blob.slice(32, 44);
74
+ const ct = blob.slice(44);
75
+ const shared = x25519.getSharedSecret(recipientPriv, ephPub);
76
+ const key = await aesKey(shared);
77
+ const pt = await crypto.subtle.decrypt({ name: "AES-GCM", iv: buf(iv) }, key, buf(ct));
78
+ return new TextDecoder().decode(pt);
79
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./note.js";
2
+ export * from "./crypto.js";
3
+ export * from "./prover.js";
@@ -0,0 +1,3 @@
1
+ export * from "./note.js";
2
+ export * from "./crypto.js";
3
+ export * from "./prover.js";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A pool note. Whoever holds (nullifier, secret) can withdraw the deposit whose
3
+ * commitment = Poseidon(nullifier, secret). Losing it loses the funds — there is
4
+ * no server-side copy.
5
+ */
6
+ export interface Note {
7
+ poolId: bigint;
8
+ nullifier: bigint;
9
+ secret: bigint;
10
+ }
11
+ /** Generate a fresh note for a pool. */
12
+ export declare function randomNote(poolId: bigint | number): Note;
13
+ /** Note commitment = Poseidon(nullifier, secret) — the tree leaf. */
14
+ export declare function commitment(note: Note): Promise<bigint>;
15
+ /** nullifierHash = Poseidon(nullifier) — revealed at withdraw, public. */
16
+ export declare function nullifierHash(note: Note): Promise<bigint>;
17
+ /** Serialize a note to the backup string the user must save to claim funds. */
18
+ export declare function encodeNote(note: Note): string;
19
+ /** Parse a backup string back into a note. */
20
+ export declare function decodeNote(s: string): Note;
21
+ /** 32-byte big-endian encoding of a field element (tree leaf / PDA seed). */
22
+ export declare function toBytes32(v: bigint): Uint8Array;
@@ -0,0 +1,66 @@
1
+ import { buildPoseidon } from "circomlibjs";
2
+ // BN254 scalar field order. nullifier/secret must be reduced mod this.
3
+ const FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
4
+ let _poseidon;
5
+ async function poseidon() {
6
+ if (!_poseidon)
7
+ _poseidon = await buildPoseidon();
8
+ return _poseidon;
9
+ }
10
+ function randomFieldElement() {
11
+ // 31 bytes = 248 bits < field order, so a single reduction is unbiased enough.
12
+ const bytes = new Uint8Array(31);
13
+ globalThis.crypto.getRandomValues(bytes);
14
+ let v = 0n;
15
+ for (const b of bytes)
16
+ v = (v << 8n) | BigInt(b);
17
+ return v % FIELD;
18
+ }
19
+ /** Generate a fresh note for a pool. */
20
+ export function randomNote(poolId) {
21
+ return {
22
+ poolId: BigInt(poolId),
23
+ nullifier: randomFieldElement(),
24
+ secret: randomFieldElement(),
25
+ };
26
+ }
27
+ /** Note commitment = Poseidon(nullifier, secret) — the tree leaf. */
28
+ export async function commitment(note) {
29
+ const p = await poseidon();
30
+ return BigInt(p.F.toString(p([note.nullifier, note.secret])));
31
+ }
32
+ /** nullifierHash = Poseidon(nullifier) — revealed at withdraw, public. */
33
+ export async function nullifierHash(note) {
34
+ const p = await poseidon();
35
+ return BigInt(p.F.toString(p([note.nullifier])));
36
+ }
37
+ const PREFIX = "clavis-note-v1";
38
+ function toHex(v) {
39
+ return v.toString(16);
40
+ }
41
+ /** Serialize a note to the backup string the user must save to claim funds. */
42
+ export function encodeNote(note) {
43
+ return [PREFIX, note.poolId.toString(), toHex(note.nullifier), toHex(note.secret)].join(":");
44
+ }
45
+ /** Parse a backup string back into a note. */
46
+ export function decodeNote(s) {
47
+ const parts = s.trim().split(":");
48
+ if (parts.length !== 4 || parts[0] !== PREFIX) {
49
+ throw new Error("invalid note backup string");
50
+ }
51
+ return {
52
+ poolId: BigInt(parts[1]),
53
+ nullifier: BigInt("0x" + parts[2]),
54
+ secret: BigInt("0x" + parts[3]),
55
+ };
56
+ }
57
+ /** 32-byte big-endian encoding of a field element (tree leaf / PDA seed). */
58
+ export function toBytes32(v) {
59
+ const out = new Uint8Array(32);
60
+ let x = v;
61
+ for (let i = 31; i >= 0; i--) {
62
+ out[i] = Number(x & 0xffn);
63
+ x >>= 8n;
64
+ }
65
+ return out;
66
+ }
@@ -0,0 +1,35 @@
1
+ import { PoseidonMerkleTree } from "../zk/merkle.js";
2
+ import { type ProofCalldata, type RawProof } from "../zk/calldata.js";
3
+ import { Note } from "./note.js";
4
+ /**
5
+ * Split a 20-byte EVM address into the circuit's two 128-bit limbs. The address
6
+ * is zero-padded to 32 bytes first (bytes32(uint256(uint160(addr)))), matching
7
+ * PrivacyPools.withdraw's check.
8
+ */
9
+ export declare function recipientLimbs(recipient: `0x${string}`): {
10
+ hi: bigint;
11
+ lo: bigint;
12
+ };
13
+ export interface WithdrawInputs {
14
+ note: Note;
15
+ /** Pool deposit tree and the note's leaf index in it. */
16
+ depositTree: PoseidonMerkleTree;
17
+ depositLeafIndex: number;
18
+ /** Association-set tree and the note's leaf index in it. For a non-gated pool
19
+ * this is the same tree as `depositTree`. */
20
+ assocTree: PoseidonMerkleTree;
21
+ assocLeafIndex: number;
22
+ recipient: `0x${string}`;
23
+ fee: bigint;
24
+ }
25
+ export type { ProofCalldata, RawProof };
26
+ /**
27
+ * Raw snarkjs proof + public signals. Use this for the relay path (the relayer
28
+ * formats calldata server-side). Requires app/public/withdraw.{wasm,zkey}.
29
+ */
30
+ export declare function proveWithdrawRaw(inputs: WithdrawInputs, wasmPath: string, zkeyPath: string): Promise<RawProof>;
31
+ /**
32
+ * Withdraw proof as PrivacyPools.withdraw calldata.
33
+ * signals = [nullifierHash, depositRoot, associationRoot, recipientHi, recipientLo, fee].
34
+ */
35
+ export declare function proveWithdraw(inputs: WithdrawInputs, wasmPath: string, zkeyPath: string): Promise<ProofCalldata>;
@@ -0,0 +1,48 @@
1
+ import { groth16 } from "snarkjs";
2
+ import { toCalldata } from "../zk/calldata.js";
3
+ /**
4
+ * Split a 20-byte EVM address into the circuit's two 128-bit limbs. The address
5
+ * is zero-padded to 32 bytes first (bytes32(uint256(uint160(addr)))), matching
6
+ * PrivacyPools.withdraw's check.
7
+ */
8
+ export function recipientLimbs(recipient) {
9
+ const r = BigInt(recipient);
10
+ if (r >= 1n << 160n)
11
+ throw new Error("invalid address");
12
+ return { hi: r >> 128n, lo: r & ((1n << 128n) - 1n) };
13
+ }
14
+ function buildWitness(inputs) {
15
+ const { note, depositTree, depositLeafIndex, assocTree, assocLeafIndex, recipient, fee } = inputs;
16
+ const dep = depositTree.proof(depositLeafIndex);
17
+ const assoc = assocTree.proof(assocLeafIndex);
18
+ const { hi, lo } = recipientLimbs(recipient);
19
+ return {
20
+ nullifier: note.nullifier.toString(),
21
+ secret: note.secret.toString(),
22
+ depositPathElements: dep.pathElements.map((x) => x.toString()),
23
+ depositPathIndices: dep.pathIndices.map((x) => x.toString()),
24
+ assocPathElements: assoc.pathElements.map((x) => x.toString()),
25
+ assocPathIndices: assoc.pathIndices.map((x) => x.toString()),
26
+ depositRoot: depositTree.root().toString(),
27
+ associationRoot: assocTree.root().toString(),
28
+ recipientHi: hi.toString(),
29
+ recipientLo: lo.toString(),
30
+ fee: fee.toString(),
31
+ };
32
+ }
33
+ /**
34
+ * Raw snarkjs proof + public signals. Use this for the relay path (the relayer
35
+ * formats calldata server-side). Requires app/public/withdraw.{wasm,zkey}.
36
+ */
37
+ export async function proveWithdrawRaw(inputs, wasmPath, zkeyPath) {
38
+ const witness = buildWitness(inputs);
39
+ const { proof, publicSignals } = await groth16.fullProve(witness, wasmPath, zkeyPath);
40
+ return { proof, publicSignals };
41
+ }
42
+ /**
43
+ * Withdraw proof as PrivacyPools.withdraw calldata.
44
+ * signals = [nullifierHash, depositRoot, associationRoot, recipientHi, recipientLo, fee].
45
+ */
46
+ export async function proveWithdraw(inputs, wasmPath, zkeyPath) {
47
+ return toCalldata(await proveWithdrawRaw(inputs, wasmPath, zkeyPath));
48
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./keypair.js";
2
+ export * from "./note.js";
3
+ export * from "./prover.js";
4
+ export * from "./scan.js";
@@ -0,0 +1,4 @@
1
+ export * from "./keypair.js";
2
+ export * from "./note.js";
3
+ export * from "./prover.js";
4
+ export * from "./scan.js";
@@ -0,0 +1,23 @@
1
+ export declare const FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
2
+ export declare function poseidon(): Promise<any>;
3
+ export declare function H(xs: bigint[]): Promise<bigint>;
4
+ /**
5
+ * A shielded identity. `privateKey`/`publicKey` are the in-circuit spending key
6
+ * (used to derive note nullifiers); `encPriv`/`encPub` are an X25519 pair used
7
+ * to encrypt note secrets to the owner. Both are derived from one wallet
8
+ * signature, so the whole identity is recoverable and nothing is stored.
9
+ */
10
+ export interface ShieldedKeypair {
11
+ privateKey: bigint;
12
+ publicKey: bigint;
13
+ encPriv: Uint8Array;
14
+ encPub: Uint8Array;
15
+ }
16
+ /** Derive a shielded identity from a 32+ byte seed (e.g. a wallet signature). */
17
+ export declare function deriveShieldedKeypair(seed: Uint8Array): Promise<ShieldedKeypair>;
18
+ /** Shareable shielded address = base64url(publicKey || encPub). */
19
+ export declare function encodeShieldedAddress(kp: ShieldedKeypair): string;
20
+ export declare function decodeShieldedAddress(s: string): {
21
+ publicKey: bigint;
22
+ encPub: Uint8Array;
23
+ };