Skip to content

Commit

Permalink
Merge pull request privacy-scaling-explorations#127 from input-output…
Browse files Browse the repository at this point in the history
…-hk/dev-feature/ensure-non-id

Add EccInstructions API to turn `Point` to `NonIdentityPoint`
  • Loading branch information
b13decker committed Feb 27, 2024
2 parents 313797d + 44b8550 commit 16bec5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions halo2_gadgets/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ pub trait EccInstructions<C: CurveAffine>:
b: &Self::Point,
) -> Result<(), Error>;

/// Converts [`EccInstructions::Point`] to [`EccInstructions::NonIdentityPoint`] by
/// convincing the verifier that `point` is not identity.
fn ensure_non_id(
&self,
layouter: &mut impl Layouter<C::Base>,
point: &Self::Point,
) -> Result<Self::NonIdentityPoint, Error>;

/// Witnesses the given point as a private input to the circuit.
/// This allows the point to be the identity, mapped to (0, 0) in
/// affine coordinates.
Expand Down
11 changes: 11 additions & 0 deletions halo2_gadgets/src/ecc/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,17 @@ where
)
}

fn ensure_non_id(
&self,
layouter: &mut impl Layouter<pallas::Base>,
point: &Self::Point,
) -> Result<Self::NonIdentityPoint, Error> {
let non_id_point = self.witness_point_non_id(layouter, point.point())?;
self.constrain_equal(layouter, point, &non_id_point.clone().into())?;

Ok(non_id_point)
}

fn witness_point(
&self,
layouter: &mut impl Layouter<pallas::Base>,
Expand Down

0 comments on commit 16bec5a

Please sign in to comment.