diff --git a/src/circuit/gadget.rs b/src/circuit/gadget.rs index 9e152918f..6760313fc 100644 --- a/src/circuit/gadget.rs +++ b/src/circuit/gadget.rs @@ -1 +1,2 @@ pub(crate) mod ecc; +pub(crate) mod sinsemilla; diff --git a/src/circuit/gadget/sinsemilla.rs b/src/circuit/gadget/sinsemilla.rs new file mode 100644 index 000000000..88edf4716 --- /dev/null +++ b/src/circuit/gadget/sinsemilla.rs @@ -0,0 +1,37 @@ +//! Gadget and chips for the Sinsemilla hash function. +use halo2::{ + arithmetic::CurveAffine, + circuit::{Chip, Layouter}, + plonk::Error, +}; + +/// The set of circuit instructions required to use the [`Sinsemilla`](https://zcash.github.io/halo2/design/gadgets/sinsemilla.html) gadget. +pub trait SinsemillaInstructions: Chip { + type Message: IntoIterator; + + fn extract(point: &C::Curve) -> C::Base; + + #[allow(non_snake_case)] + fn Q(domain_prefix: &str) -> C::CurveExt; + + fn hash_to_point( + layouter: &mut impl Layouter, + domain_prefix: &str, + message: Self::Message, + ) -> Result; + + fn hash( + layouter: &mut impl Layouter, + domain_prefix: &str, + message: Self::Message, + ) -> Result; + + fn commit(domain_prefix: &str, msg: Self::Message, r: &C::Scalar) + -> Result; + + fn short_commit( + domain_prefix: &str, + msg: Self::Message, + r: &C::Scalar, + ) -> Result; +}