Skip to content

Commit

Permalink
Add extract() to SinsemillaInstructions
Browse files Browse the repository at this point in the history
  • Loading branch information
therealyingtong committed Jun 3, 2021
1 parent 5e6b811 commit 5074388
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/circuit/gadget/sinsemilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ pub trait SinsemillaInstructions<C: CurveAffine> {
/// A cell in the circuit
type CellValue;

/// A point output of [ hash_to_point`].
/// The x-coordinate of a point output of [`hash_to_point`].
type X;
/// A point output of [`hash_to_point`].
type Point: Clone + Debug;
/// The fixed points used in `CommitDomains`.
type FixedPoints: Clone + Debug;
Expand Down Expand Up @@ -61,6 +63,9 @@ pub trait SinsemillaInstructions<C: CurveAffine> {
Q: C,
message: Vec<Self::MessagePiece>,
) -> Result<Self::Point, Error>;

/// Extracts the x-coordinate of the output of a Sinsemilla hash.
fn extract(point: &Self::Point) -> &Self::X;
}

/// A message to be hashed.
Expand Down
5 changes: 5 additions & 0 deletions src/circuit/gadget/sinsemilla/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ impl<C: CurveAffine> SinsemillaInstructions<C> for SinsemillaChip<C> {
type MessagePiece = MessagePiece<C::Base>;
type CellValue = CellValue<C::Base>;

type X = CellValue<C::Base>;
type Point = EccPoint<C>;
type FixedPoints = OrchardFixedBasesFull<C>;

Expand Down Expand Up @@ -345,6 +346,10 @@ impl<C: CurveAffine> SinsemillaInstructions<C> for SinsemillaChip<C> {
|mut region| hash_to_point::hash_message::<C>(&mut region, config.clone(), Q, &message),
)
}

fn extract(point: &Self::Point) -> &Self::X {
&point.x
}
}

#[derive(Clone, Debug)]
Expand Down

0 comments on commit 5074388

Please sign in to comment.