| Crates.io | semaphore-protocol |
| lib.rs | semaphore-protocol |
| version | 0.1.0 |
| created_at | 2025-10-06 08:54:30.917668+00 |
| updated_at | 2025-10-07 02:07:41.59493+00 |
| description | Semaphore Rust Implementation |
| homepage | |
| repository | https://github.com/semaphore-protocol/semaphore-rs |
| max_upload_size | |
| id | 1869951 |
| size | 10,272,910 |
| 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"
use semaphore::identity::Identity;
let identity = Identity::new("secret".as_bytes());
identity.commitment()
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.toml
semaphore-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-rs
Run Rustfmt to automatically format the code
cargo fmt --all
Run rust-clippy to catch common mistakes and improve your Rust code.
cargo clippy
cargo test
witness_graph with circom-witnesscalc./script build_witness_graph.sh