npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@atoshi/privacy-sdk

v0.3.2

Published

TypeScript SDK for Atoshi privacy transactions

Readme

Atoshi Privacy SDK

TypeScript SDK for privacy transactions on Atoshi Chain.

🚀 Features

  • 🔐 Privacy Wallet: Manage keypairs and private notes
  • 💸 Deposit: Convert public tokens to private notes
  • 🔓 Withdraw: Convert private notes back to public tokens
  • 🔄 Transfer: Private transfers between users
  • 🌐 RPC Client: Communicate with privacy node

📦 Installation

npm install @atoshi/privacy-sdk
# or
yarn add @atoshi/privacy-sdk
# or
pnpm add @atoshi/privacy-sdk

🏁 Quick Start

import { PrivacyWallet, TransactionBuilder, PrivacyRpcClient } from '@atoshi/privacy-sdk';
import { ethers } from 'ethers';

// Initialize wallet
const wallet = new PrivacyWallet();
await wallet.init();

// Generate or import keypair
const keypair = await wallet.generateKeypair();
console.log('Public Key:', keypair.publicKey.toString());

// Or import existing keypair
// await wallet.importKeypair(BigInt('your_private_key'));

// Setup transaction builder
const config = {
  nodeUrl: 'http://localhost:8080',
  l1RpcUrl: 'http://localhost:8545',
  shieldContract: '0x...',
  circuitsPath: './circuits/build',
  keysPath: './circuits/keys',
};

const builder = new TransactionBuilder(wallet, config);

// Connect signer
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
await builder.init(signer);

// Deposit 1 ETH
const depositResult = await builder.deposit({
  amount: ethers.parseEther('1'),
  tokenAddress: ethers.ZeroAddress,
});
console.log('Deposit:', depositResult);

// Check balance
const balance = wallet.getBalance(0n); // 0n = native token
console.log('Private Balance:', ethers.formatEther(balance));

// Withdraw
const withdrawResult = await builder.withdraw({
  noteIndex: 0,
  recipient: '0x...',
});
console.log('Withdraw:', withdrawResult);

📖 API Reference

PrivacyWallet

class PrivacyWallet {
  // Initialize wallet
  async init(): Promise<void>;
  
  // Generate new keypair
  async generateKeypair(): Promise<Keypair>;
  
  // Import existing keypair
  async importKeypair(privateKey: bigint): Promise<Keypair>;
  
  // Get current keypair
  getKeypair(): Keypair | null;
  
  // Get public key
  getPublicKey(): bigint | null;
  
  // Create a new note
  async createNote(amount: bigint, tokenId: bigint, recipient?: bigint): Promise<Note>;
  
  // Get all notes
  getAllNotes(): NoteRecord[];
  
  // Get unspent notes
  getUnspentNotes(): NoteRecord[];
  
  // Get balance for a token
  getBalance(tokenId: bigint): bigint;
  
  // Export wallet for backup
  export(): string;
  
  // Import wallet from backup
  async import(data: string): Promise<void>;
}

TransactionBuilder

class TransactionBuilder {
  // Initialize with signer
  async init(signer?: ethers.Signer): Promise<void>;
  
  // Deposit tokens
  async deposit(params: DepositParams): Promise<TransactionResult>;
  
  // Withdraw tokens
  async withdraw(params: WithdrawParams): Promise<TransactionResult>;
  
  // Private transfer
  async transfer(params: TransferParams): Promise<TransactionResult>;
}

PrivacyRpcClient

class PrivacyRpcClient {
  // Health check
  async health(): Promise<boolean>;
  
  // Get node state
  async getState(): Promise<NodeState>;
  
  // Get Merkle root
  async getRoot(): Promise<{ root: bigint; nextIndex: number }>;
  
  // Check if nullifier is spent
  async isNullifierSpent(nullifier: bigint): Promise<boolean>;
  
  // Get Merkle proof
  async getMerkleProof(leafIndex: number): Promise<MerkleProof>;
}

🔧 Configuration

interface SdkConfig {
  // Privacy node RPC URL
  nodeUrl: string;
  
  // L1 chain RPC URL
  l1RpcUrl: string;
  
  // Shield contract address
  shieldContract: string;
  
  // Path to circuit WASM files
  circuitsPath?: string;
  
  // Path to proving keys
  keysPath?: string;
}

📝 Examples

Deposit ERC20 Token

import { ethers } from 'ethers';

// First approve the Shield contract
const token = new ethers.Contract(tokenAddress, ERC20_ABI, signer);
await token.approve(shieldContract, amount);

// Then deposit
const result = await builder.deposit({
  amount: ethers.parseUnits('100', 18),
  tokenAddress: tokenAddress,
});

Private Transfer

// Get recipient's public key (they share this publicly)
const recipientPubKey = BigInt('recipient_public_key');

// Transfer
const result = await builder.transfer({
  noteIndex: 0,
  recipientPublicKey: recipientPubKey,
});

Backup and Restore

// Export wallet
const backup = wallet.export();
localStorage.setItem('wallet_backup', backup);

// Restore wallet
const newWallet = new PrivacyWallet();
await newWallet.init();
await newWallet.import(localStorage.getItem('wallet_backup')!);

🔐 Security

  • Private keys are never sent to any server
  • ZK proofs are generated locally
  • Notes are encrypted and stored locally
  • Always backup your wallet data

📄 License

MIT License