-
Notifications
You must be signed in to change notification settings - Fork 22
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
14 changed files
with
1,089 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ members = [ | |
"node/migration", | ||
"wano", | ||
"verkletree", | ||
"poseidon", | ||
] | ||
exclude = [] | ||
resolver = "2" | ||
|
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,22 @@ | ||
[package] | ||
name = "poseidon" | ||
version = "0.1.1" | ||
description = "Poseidon Hash" | ||
authors.workspace = true | ||
repository.workspace = true | ||
edition.workspace = true | ||
license = "Apache-2.0" | ||
readme = "README.md" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
name = "poseidon" | ||
path = "src/lib.rs" | ||
|
||
[dependencies] | ||
halo2_proofs = { workspace = true } | ||
halo2curves = { workspace = true } | ||
rand = { workspace = true } | ||
rand_core = { workspace = true } | ||
ff = { workspace = true } |
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,9 @@ | ||
# Poseidon Hash | ||
|
||
Poseidon hash implementation in Rust. | ||
|
||
## License | ||
|
||
This project licensed under the [Apache License, Version 2.0](LICENSE). | ||
|
||
_build with ❤️ and 🦀_ |
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,27 @@ | ||
use poseidon::{ | ||
circuit::PoseidonCircuit, | ||
poseidon_hash::{Hash, OrchardNullifier, ConstantLength} | ||
}; | ||
use halo2_proofs::{ | ||
dev::MockProver, | ||
arithmetic::Field, | ||
}; | ||
use std::marker::PhantomData; | ||
use halo2curves::pasta::Fp; | ||
use rand::rngs::OsRng; | ||
fn main(){ | ||
let rng = OsRng; | ||
|
||
let message = [Fp::random(rng), Fp::random(rng)]; | ||
let output = Hash::<Fp, OrchardNullifier, ConstantLength<2>, 3, 2>::init().hash(message); | ||
|
||
let k = 6; | ||
let circuit = PoseidonCircuit::<OrchardNullifier, Fp, ConstantLength<2>, 3, 2, 2> { | ||
message, | ||
output, | ||
_marker: PhantomData, | ||
_marker2: PhantomData, | ||
}; | ||
let prover = MockProver::run(k, &circuit, vec![]).expect("cannot prove"); | ||
assert_eq!(prover.verify(), Ok(())) | ||
} |
Oops, something went wrong.