Skip to content

cypriansakwa/private_key_recovery_gate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 Private Key Recovery Gate

This project implements a simple zero-knowledge circuit that enforces a private key recovery condition using Noir and Barretenberg. A user can only generate a valid proof if they know a secret_share that satisfies a strict mathematical constraint.

🗂️ Project Structure

  • /circuits — Contains the Noir circuit and logic.
  • /contract — Foundry project with Solidity verifier and test contract.
  • /js — JavaScript code for generating and saving proofs using bb.js.

Tested with:

  • Noir v1.0.0-beta.6
  • bb CLI v0.84.0

✅ Example Inputs

  • secret_share = 7
  • public_offset = 3
### Installation / Setup
```ssh
# Foundry
git submodule update

# Build circuits, generate verifier contract
(cd circuits && ./build.sh)

# Install JS dependencies
(cd js && yarn)

Proof generation in JS

# Use bb.js to generate proof and save to a file
(cd js && yarn generate-proof)

# Run foundry test to read generated proof and verify
(cd contract && forge test --optimize --optimizer-runs 5000 --gas-report -vvv)

Proof generation with bb cli

cd circuits

# Generate witness
nargo execute

# Generate proof
bb prove -b ./target/private_key_recovery_gate.json -w target/private_key_recovery_gate.gz -o ./target --oracle_hash keccak

# Run foundry test to read generated proof and verify
cd ..
(cd contract && forge test --optimize --optimizer-runs 5000 --gas-report -vvv)

🔁 Dual Workflow Support (CLI and JS)

The project supports two approaches for generating proofs:

  • JavaScript-based workflow using bb.js
  • CLI-based workflow using nargo and bb directly

🛠 Building the Solidity Verifier

Use the build.sh script to compile the circuit and generate the Solidity verifier:

./build.sh

This will:

  • Compile the Noir circuit
  • Generate the verification key (vk)
  • Export the Solidity verifier to contract/Verifier.sol

🧭 Ecosystem Attribution

This project is indexed in the Electric Capital Crypto Ecosystems Map.

Source: Electric Capital Crypto Ecosystems
Link: https://github.com/electric-capital/crypto-ecosystems
Logo: Electric Capital Logo

💡 If you’re working in open source crypto, submit your repository here to be counted.

Thank you for contributing and for reading the contribution guide! ❤️

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published