Skip to content

Commit

Permalink
Add Sinsemilla gadget
Browse files Browse the repository at this point in the history
  • Loading branch information
therealyingtong committed Feb 27, 2021
1 parent a03ee87 commit 77d1a13
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/circuit/gadget.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub(crate) mod ecc;
pub(crate) mod sinsemilla;
37 changes: 37 additions & 0 deletions src/circuit/gadget/sinsemilla.rs
Original file line number Diff line number Diff line change
@@ -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<C: CurveAffine>: Chip<Field = C::Base> {
type Message: IntoIterator<Item = bool>;

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<Self>,
domain_prefix: &str,
message: Self::Message,
) -> Result<C, Error>;

fn hash(
layouter: &mut impl Layouter<Self>,
domain_prefix: &str,
message: Self::Message,
) -> Result<C::Base, Error>;

fn commit(domain_prefix: &str, msg: Self::Message, r: &C::Scalar)
-> Result<C::CurveExt, Error>;

fn short_commit(
domain_prefix: &str,
msg: Self::Message,
r: &C::Scalar,
) -> Result<C::Base, Error>;
}

0 comments on commit 77d1a13

Please sign in to comment.