Skip to content

Commit

Permalink
extract the package
Browse files Browse the repository at this point in the history
  • Loading branch information
NOOMA-42 committed Aug 20, 2024
1 parent cc50c2f commit 26c382f
Show file tree
Hide file tree
Showing 14 changed files with 1,089 additions and 21 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"node/migration",
"wano",
"verkletree",
"poseidon",
]
exclude = []
resolver = "2"
Expand Down
22 changes: 22 additions & 0 deletions poseidon/Cargo.toml
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 }
9 changes: 9 additions & 0 deletions poseidon/README.md
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 🦀_
27 changes: 27 additions & 0 deletions poseidon/examples/poseidon_hash.rs
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(()))
}
Loading

0 comments on commit 26c382f

Please sign in to comment.