-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
173 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ version = "0.1.0" | |
edition = "2021" | ||
authors = [ | ||
"Remco Bloemen <[email protected]>", | ||
"Philipp Sippl <[email protected]>"] | ||
"Philipp Sippl <[email protected]>", | ||
] | ||
homepage = "https://github.com/worldcoin/semaphore-rs" | ||
repository = "https://github.com/worldcoin/semaphore-rs" | ||
description = "Rust support library for Semaphore" | ||
|
@@ -20,9 +21,18 @@ members = ["crates/*"] | |
default = [] | ||
bench = ["criterion", "proptest"] | ||
dylib = ["wasmer/dylib", "wasmer-engine-dylib", "wasmer-compiler-cranelift"] | ||
depth_16 = ["semaphore-depth-config/depth_16", "semaphore-depth-macros/depth_16"] | ||
depth_20 = ["semaphore-depth-config/depth_20", "semaphore-depth-macros/depth_20"] | ||
depth_30 = ["semaphore-depth-config/depth_30", "semaphore-depth-macros/depth_30"] | ||
depth_16 = [ | ||
"semaphore-depth-config/depth_16", | ||
"semaphore-depth-macros/depth_16", | ||
] | ||
depth_20 = [ | ||
"semaphore-depth-config/depth_20", | ||
"semaphore-depth-macros/depth_20", | ||
] | ||
depth_30 = [ | ||
"semaphore-depth-config/depth_30", | ||
"semaphore-depth-macros/depth_30", | ||
] | ||
|
||
[[bench]] | ||
name = "criterion" | ||
|
@@ -32,12 +42,23 @@ required-features = ["bench", "proptest"] | |
|
||
[dependencies] | ||
ark-bn254 = { version = "0.3.0" } | ||
ark-circom = { git = "https://github.com/gakonst/ark-circom", rev = "a93c8b0", features = ["circom-2"] } | ||
ark-ec = { version = "0.3.0", default-features = false, features = ["parallel"] } | ||
ark-ff = { version = "0.3.0", default-features = false, features = ["parallel", "asm"] } | ||
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", features = ["parallel"] } | ||
ark-circom = { git = "https://github.com/gakonst/ark-circom", rev = "a93c8b0", features = [ | ||
"circom-2", | ||
] } | ||
ark-ec = { version = "0.3.0", default-features = false, features = [ | ||
"parallel", | ||
] } | ||
ark-ff = { version = "0.3.0", default-features = false, features = [ | ||
"parallel", | ||
"asm", | ||
] } | ||
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", features = [ | ||
"parallel", | ||
] } | ||
ark-relations = { version = "0.3.0", default-features = false } | ||
ark-std = { version = "0.3.0", default-features = false, features = ["parallel"] } | ||
ark-std = { version = "0.3.0", default-features = false, features = [ | ||
"parallel", | ||
] } | ||
color-eyre = "0.6" | ||
criterion = { version = "0.3", optional = true, features = ["async_tokio"] } | ||
hex = "0.4.0" | ||
|
@@ -47,7 +68,12 @@ once_cell = "1.8" | |
proptest = { version = "1.0", optional = true } | ||
rand = "0.8.4" | ||
rayon = "1.5.1" | ||
ruint = { git = "https://github.com/recmo/uint.git", rev = "1b14a406ec64e7e084c7e8116e349bc1a598e339", features = ["serde", "num-bigint", "ark-ff", "bytemuck"] } | ||
ruint = { version = "=1.11.0", features = [ | ||
"serde", | ||
"num-bigint", | ||
"ark-ff", | ||
"bytemuck", | ||
] } | ||
semaphore-depth-config = { path = "crates/semaphore-depth-config" } | ||
serde = "1.0" | ||
sha2 = "0.10.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::{ | ||
identity::Identity, | ||
poseidon_tree::LazyPoseidonTree, | ||
protocol::{Proof, ProofError}, | ||
Field, | ||
}; | ||
|
||
pub fn generate_proof( | ||
depth: usize, | ||
identity: &Identity, | ||
ext_nullifier_hash: Field, | ||
signal_hash: Field, | ||
) -> Result<Proof, ProofError> { | ||
Check warning on line 13 in src/protocol/authentication.rs GitHub Actions / clippydocs for function returning `Result` missing `# Errors` section
|
||
let merkle_proof = LazyPoseidonTree::new(depth, Field::from(0)) | ||
.update(0, &identity.commitment()) | ||
.proof(0); | ||
return super::generate_proof(identity, &merkle_proof, ext_nullifier_hash, signal_hash); | ||
Check warning on line 17 in src/protocol/authentication.rs GitHub Actions / clippyunneeded `return` statement
|
||
} | ||
|
||
pub fn verify_proof( | ||
depth: usize, | ||
id_commitment: Field, | ||
nullifier_hash: Field, | ||
signal_hash: Field, | ||
ext_nullifier_hash: Field, | ||
proof: &Proof, | ||
) -> Result<bool, ProofError> { | ||
Check warning on line 27 in src/protocol/authentication.rs GitHub Actions / clippydocs for function returning `Result` missing `# Errors` section
|
||
let root = LazyPoseidonTree::new(depth, Field::from(0)) | ||
.update(0, &id_commitment) | ||
.root(); | ||
return super::verify_proof( | ||
root, | ||
nullifier_hash, | ||
signal_hash, | ||
ext_nullifier_hash, | ||
proof, | ||
depth, | ||
); | ||
Check warning on line 38 in src/protocol/authentication.rs GitHub Actions / clippyunneeded `return` statement
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters