UPC — Universal Private ComplianceSDK Reference
Client API
createASPClient — the main entry point for managing ASPs, adding members, and generating proofs.
createASPClient
import { createASPClient } from '@permissionless-technologies/upc-sdk'
import { MemoryProvider } from '@permissionless-technologies/upc-sdk/providers'
const asp = createASPClient({
publicClient, // viem PublicClient
walletClient?, // viem WalletClient (needed for write operations)
registryAddress: Address, // AttestationHub contract address
provider: IASPProvider, // Storage provider for the Merkle tree
hashFunction?: IHashFunction, // default: PoseidonBLS12381
})Methods
asp.register(params)
Register your ASP in the on-chain AttestationHub.
const { aspId, txHash } = await asp.register({
name: 'My ASP',
description: 'OFAC sanctions screen',
url: 'https://my-asp.example.com',
walletClient,
})asp.addMember(address)
Add an approved address to the local Merkle tree.
await asp.addMember('0xApprovedAddress')asp.addMembers(addresses)
Add multiple members at once.
await asp.addMembers(['0xAddress1', '0xAddress2', '0xAddress3'])asp.removeMember(address)
Remove an address from the tree (tree is rebuilt on next publish).
await asp.removeMember('0xRemovedAddress')asp.publishRoot(params)
Publish the current Merkle root to the AttestationHub on-chain.
const { txHash } = await asp.publishRoot({ walletClient })asp.generateProof(params)
Generate a ZK membership proof for an identity.
const proof = await asp.generateProof({
identity: myAddress, // Address to prove membership for
aspId: 1n, // Which ASP's tree to prove against
nonce?: bigint, // Anti-replay nonce (default: auto-generated)
})Returns a Proof object containing proof bytes and public inputs.
asp.verifyProof(params)
Verify a membership proof on-chain.
const isValid = await asp.verifyProof({
proof,
aspId: 1n,
})asp.isMember(address)
Check if an address is in the current Merkle tree (local check, no ZK proof).
const member = await asp.isMember('0xAddress')asp.getRoot()
Get the current Merkle root.
const root = asp.getRoot()asp.getLatestOnChainRoot(aspId)
Get the latest published root from the AttestationHub.
const onChainRoot = await asp.getLatestOnChainRoot(1n)