diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..d309aeb --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly-2023-06-01 \ No newline at end of file diff --git a/src/matrix.rs b/src/matrix.rs index 9207835..e3593ae 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -3,7 +3,6 @@ //! with the intention of construction of parameters and are not used in the //! actual permutation process. - use halo2_proofs::arithmetic::FieldExt; #[derive(PartialEq, Debug, Clone)] diff --git a/src/poseidon.rs b/src/poseidon.rs index 163c1fe..99aed04 100644 --- a/src/poseidon.rs +++ b/src/poseidon.rs @@ -1,12 +1,13 @@ use crate::{Spec, State}; use halo2_proofs::arithmetic::FieldExt; +use std::sync::Arc; /// Poseidon hasher that maintains state and inputs and yields single element /// output when desired #[derive(Debug, Clone)] pub struct Poseidon { state: State, - spec: Spec, + spec: Arc>, absorbing: Vec, } @@ -14,7 +15,7 @@ impl Poseidon { /// Constructs a clear state poseidon instance pub fn new(r_f: usize, r_p: usize) -> Self { Self { - spec: Spec::new(r_f, r_p), + spec: Arc::new(Spec::new(r_f, r_p)), state: State::default(), absorbing: Vec::new(), } @@ -26,6 +27,16 @@ impl Poseidon { self.absorbing = Vec::new(); } + /// return share spec + pub fn get_spec(&self) -> Arc> { + self.spec.clone() + } + + /// get the internal state spec + pub fn get_state(&self) -> [F; T] { + self.state.0.clone() + } + /// Update n = RATE elements /// This assumes the current absorbing list is empty pub fn update_exact(&mut self, elements: &[F; RATE]) -> F { diff --git a/src/spec.rs b/src/spec.rs index 01a91e8..e78a9d7 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -397,8 +397,8 @@ impl Spec { #[cfg(test)] pub(super) mod tests { - -use halo2_proofs::arithmetic::FieldExt; + + use halo2_proofs::arithmetic::FieldExt; use super::MDSMatrix; use crate::grain::Grain;