A TypeScript/JavaScript library providing Noir-based zero-knowledge proof functionality for the Hyli ecosystem. This library enables secure secret verification through cryptographic proofs without revealing sensitive information.
- 🔐 Zero-Knowledge Secret Verification: Generate proofs that demonstrate knowledge of a password without revealing it
- 🛡️ Identity-Based Authentication: Combine user identity with password hashing for secure authentication
- 📦 Blob Transaction Support: Create and manage blob transactions containing encrypted secrets
- ⚡ Noir Circuit Integration: Built on Noir's zero-knowledge proof system with UltraHonk backend
- 🔧 TypeScript Support: Full TypeScript definitions and type safety
npm install hyli-noirThis library requires the following peer dependencies:
npm install @aztec/bb.js@0.82.2 @noir-lang/noir_js@1.0.0-beta.18 @noir-lang/noir_wasm@1.0.0-beta.18import { check_secret } from 'hyli-noir';
// Hash a password
const hashedPassword = await check_secret.hash_password('my-secret-password');
// Generate identity hash
const identityHash = await check_secret.identity_hash('user@example.com', 'my-secret-password');
// Build a blob transaction
const blob = await check_secret.build_blob('user@example.com', 'my-secret-password');
// Generate a proof transaction
const proofTx = await check_secret.build_proof_transaction(
'user@example.com',
'my-secret-password',
'0x1234567890abcdef...', // transaction hash
0, // blob index
1 // total blob count
);Hashes a password using SHA-256.
Parameters:
password- The password string to hash
Returns: Promise resolving to a 32-byte Uint8Array containing the SHA-256 hash
Creates a combined hash of identity and password for authentication.
Parameters:
identity- The user's identity stringpassword- The user's password string
Returns: Promise resolving to a hex-encoded string of the combined hash
Creates a blob transaction containing a secret derived from identity and password.
Parameters:
identity- The user's identity stringpassword- The user's password string
Returns: Promise resolving to a Blob object containing the encrypted secret
build_proof_transaction(identity, password, tx_hash, blob_index, tx_blob_count, circuit?): Promise<ProofTransaction>
Generates a zero-knowledge proof transaction demonstrating knowledge of the password.
Parameters:
identity- The user's identity stringpassword- The user's password stringtx_hash- The blob transaction hash stringblob_index- The index of the blob in the transactiontx_blob_count- Total number of blobs in the transactioncircuit- Optional compiled Noir circuit (defaults to check_secret circuit)
Returns: Promise resolving to a ProofTransaction containing the generated proof
Registers the Noir contract with the node if not already registered.
Parameters:
node- The NodeApiHttpClient instancecircuit- Optional compiled Noir circuit (defaults to check_secret circuit)
Throws an error if the condition is false.
Computes SHA-256 hash of the input data.
Converts a string to Uint8Array using UTF-8 encoding.
Converts Uint8Array to hex string representation.
The library implements a zero-knowledge proof system for secret verification:
- Password Hashing: The user's password is hashed using SHA-256 to create a fixed-size secret
- Identity Combination: The identity is concatenated with the hashed password using a colon separator
- Final Hash: The combined value is hashed again to create the stored secret
- Proof Generation: A zero-knowledge proof is generated that demonstrates knowledge of the password without revealing it
- Verification: The proof can be verified against the stored hash without exposing the original password
- Passwords are never stored in plain text
- The zero-knowledge proof system ensures password privacy
- All cryptographic operations use industry-standard algorithms (SHA-256)
- The system is designed to prevent replay attacks and unauthorized access
In ./check-jwt/ folder if ./Prover.toml is present and well constructed
nargo executeIt builds and executes the circuit.
In ./check-secret/, to build without executing do
nargo buildbun run buildbun run pubMIT
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions:
- GitHub Issues: https://github.com/hyli-org/hyli-noir/issues
- Repository: https://github.com/hyli-org/hyli-noir