Demo Project
A complete example project demonstrating how to use PrivacyCash SDK: https://github.com/Privacy-Cash/solana-sdk-demo-interfaceInstallation
Requires Node.js 24+. The SDK is written in TypeScript and includes type definitions.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
npm install privacycash --save
async function getSignedSignature(signed: Signed) {
if (signed.signature) {
return
}
const encodedMessage = new TextEncoder().encode(`Privacy Money account sign in`)
const cacheKey = `zkcash-signature-${signed.publicKey.toBase58()}`
// ask for sign
let signature: Uint8Array
try {
signature = await signed.provider.signMessage(encodedMessage)
} catch (err: any) {
if (err instanceof Error && err.message?.toLowerCase().includes('user rejected')) {
throw new Error('User rejected the signature request')
}
throw new Error('Failed to sign message: ' + err.message)
}
if (currentSigned.pubKeyStr != signed.publicKey.toString()) {
throw new Error(`Don't switch account when signing in. Refresh the page and try again.`)
}
// If wallet.signMessage returned an object, extract `signature`
// @ts-ignore
if (signature.signature) {
// @ts-ignore
signature = signature.signature
}
if (!(signature instanceof Uint8Array)) {
throw new Error('signature is not an Uint8Array type')
}
signed.signature = signature
}
export type Signed = {
publicKey: PublicKey,
signature?: Uint8Array,
provider: any
}
export * from "privacycash/utils"
let encryptionService = new EncryptionService();
encryptionService.deriveEncryptionKeyFromSignature(signed.signature);
const { WasmFactory } = await import('@lightprotocol/hasher.rs');
const hasher = await WasmFactory.getInstance();
"scripts": {
"postinstall": "cp node_modules/@lightprotocol/hasher.rs/dist/hasher_wasm_simd_bg.wasm node_modules/@lightprotocol/hasher.rs/dist/browser-fat/es/ && cp node_modules/@lightprotocol/hasher.rs/dist/light_wasm_hasher_bg.wasm node_modules/@lightprotocol/hasher.rs/dist/browser-fat/es/",
},..}
