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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ajna-inc/zk-aadhar

v0.1.2

Published

Zero-knowledge proof system for India's Aadhaar offline KYC verification

Readme

@ajna-inc/zk-aadhar

Zero-knowledge proof system for India's Aadhaar offline KYC verification using STARK proofs.

Features

  • 🔐 Zero-Knowledge Proofs - Prove age/attributes without revealing PII
  • STARK-based - Fast proof generation (~12ms) using Plonky3
  • 🔒 Digital Signature Verification - Validates UIDAI's RSA signature
  • 🌐 DIDComm Compatible - Proof-of-Execution format support
  • 🚫 Replay Protection - Context binding prevents proof reuse

Installation

npm install @ajna-inc/zk-aadhar

Quick Start

const {
  parseAadharXml,
  proveAgeThreshold,
  verifyAgeThreshold,
  createDidcommAgeResponse,
  getVersion
} = require('@ajna-inc/zk-aadhar');

// 1. Parse Aadhaar XML (from offline KYC ZIP)
const aadhar = parseAadharXml(xmlString);
console.log('Name:', aadhar.name);
console.log('Age:', aadhar.age);
console.log('Commitment:', aadhar.commitment);

// 2. Create DIDComm context for proof
const context = {
  nonce: '0x' + randomBytes(32).toString('hex'),
  contextHash: '0x' + sha256(requestData).toString('hex'),
  sessionId: '0x' + randomBytes(16).toString('hex')
};

// 3. Generate age threshold proof (age >= 18)
const proof = proveAgeThreshold(xmlString, 18, context);

// 4. Create DIDComm response
const response = createDidcommAgeResponse(xmlString, proof, context, 18);

// 5. Verify proof
const isValid = verifyAgeThreshold(
  proof.proof,
  18,
  aadhar.commitment,
  context,
  proof.metadata.outputsHash
);

API Reference

parseAadharXml(xmlContent: string): AadharData

Parses Aadhaar offline KYC XML and verifies digital signature.

Returns:

{
  referenceId: string,
  name: string,
  dob: string,
  gender: string,
  age: number,
  commitment: number,
  signatureVerified: boolean
}

proveAgeThreshold(xmlContent: string, minAge: number, context: ProofContext): ProofResult

Generates a zero-knowledge proof that age >= minAge.

Parameters:

  • xmlContent - Raw Aadhaar XML string
  • minAge - Minimum age threshold
  • context - DIDComm context (nonce, contextHash, sessionId)

Returns:

{
  proof: string,        // Base64-encoded STARK proof
  metadata: {
    circuitId: string,
    vkHash: string,
    outputsHash: string,
    proofSizeBytes: number,
    scheme: string,
    generationTimeMs: number
  }
}

proveAgeRange(xmlContent: string, minAge: number, maxAge: number, context: ProofContext): ProofResult

Generates proof that minAge <= age <= maxAge.

createDidcommAgeResponse(xmlContent: string, proof: ProofResult, context: ProofContext, minAge: number): DIDCommProofResponse

Creates a DIDComm-compatible proof response.

Returns:

{
  programId: string,
  result: string,
  public: {
    nonce: string,
    contextHash: string,
    sessionId: string,
    outputsHash: string,
    vkHash: string,
    commitment: number
  },
  zk: {
    scheme: string,
    circuitId: string,
    vkHash: string,
    proofB64: string
  }
}

verifyAgeThreshold(proofBase64: string, minAge: number, commitment: number, context: ProofContext, outputsHash: string): boolean

Verifies an age threshold proof.

Returns: true if proof is valid, throws error otherwise.

getVersion(): string

Returns the library version.

Performance

Benchmarked on Apple M-series (arm64):

| Operation | Time | Notes | |-----------|------|-------| | Parse XML | < 1ms | Includes signature verification | | Generate Proof (threshold) | ~12ms | STARK proof, 58KB | | Generate Proof (range) | ~68ms | STARK proof, 59KB | | Verify Proof | ~2ms | Very fast verification |

Security Features

  • Digital Signature Verification - UIDAI's RSA-2048 signature
  • Zero-Knowledge - No PII revealed in proofs
  • Replay Protection - Context binding prevents reuse
  • Commitment Binding - Proof tied to specific Aadhaar
  • Tamper Detection - Invalid XML rejected

Platform Support

Pre-built binaries for:

  • macOS (x64, arm64)
  • Linux (x64, arm64, musl)
  • Windows (x64, arm64)

Example Code

See example.js for complete usage examples including:

  • XML parsing
  • Proof generation
  • DIDComm responses
  • Proof verification

License

MIT

Links

Warning

⚠️ Never commit real Aadhaar data to version control!

This library is for legitimate KYC verification only. Misuse of Aadhaar data is illegal under Indian law.