๐ฅ Contributing ย ย |ย ย ๐ค Code of conduct ย ย |ย ย ๐ Issues ย ย |ย ย ๐ฃ๏ธ Chat & Support
| Semaphore is a generic privacy layer. Leveraging zero-knowledge technology, users can prove their membership in groups and send messages (extending from votes to endorsements) off-chain or across EVM-compatible blockchains, all without revealing their personal identity. | 
|---|
All tasks related to the Semaphore Rust implementation are public. You can track their progress, statuses, and additional details in the Semaphore Rust view.
Add this to your Cargo.toml:
[dependencies]
semaphore-protocol = "0.1"- Generate a semaphore identity from a string
use semaphore::identity::Identity; let identity = Identity::new("secret".as_bytes()); 
- Get the identity commitment
identity.commitment() 
- Get the identity private key
identity.private_key() 
- 
Generate a group member from an identity use semaphore::utils::to_element; let member = to_element(*identity.commitment()) 
- 
Generate a semaphore group from members use semaphore::group::{Element, Group}; const MEMBER1: Element = [1; 32]; const MEMBER2: Element = [2; 32]; let group = Group::new(&[ MEMBER1, MEMBER2, to_element(*identity.commitment()) ]).unwrap(); 
- 
Get the group root let root = group.root(); 
- 
Generate a semaphore proof use semaphore::proof::GroupOrMerkleProof; use semaphore::proof::Proof; let message = "message"; let scope = "scope"; let tree_depth = 20; let proof = Proof::generate_proof( identity, GroupOrMerkleProof::Group(group), message.to_string(), scope.to_string(), tree_depth as u16, ) .unwrap(); 
- 
Verify a semaphore proof let valid = Proof::verify_proof(proof); 
- 
Please enable the feature in the Cargo.tomlsemaphore-rs = { version = "0.1", features = ["serde"] } 
- 
Serialize a semaphore proof let proof_json = proof.export().unwrap(); 
- 
Deserialize a semaphore proof use semaphore::proof::SemaphoreProof; let proof_imported = SemaphoreProof::import(&proof_json).unwrap(); 
Clone this repository:
git clone https://github.com/semaphore-protocol/semaphore-rsRun Rustfmt to automatically format the code
cargo fmt --allRun rust-clippy to catch common mistakes and improve your Rust code.
cargo clippycargo testUpdate witness_graph with circom-witnesscalc
./script build_witness_graph.sh