Skip to content

Commit

Permalink
Unify identity treatment across both backends
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Feb 12, 2024
1 parent 4589ef4 commit 47948fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ark_curve/element/projective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ impl Element {
pub const GENERATOR: Self = Self {
inner: EdwardsProjective::new_unchecked(B_X, B_Y, B_T, B_Z),
};

pub const IDENTITY: Self = Self {
inner: EdwardsProjective::new_unchecked(Fq::ZERO, Fq::ONE, Fq::ZERO, Fq::ONE),
};
}

impl Hash for Element {
Expand Down
7 changes: 7 additions & 0 deletions src/min_curve/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ impl Element {
Element { x, y, z, t }
}
}
///
/// Convenience method to make identity checks more readable.
pub fn is_identity(&self) -> bool {
// Section 4.5 of Decaf paper states for cofactor 4 curves we can
// just check X = 0 to check equality with identity
self.x == Fq::ZERO
}

pub fn double(self) -> Self {
// https://eprint.iacr.org/2008/522 Section 3.3
Expand Down

0 comments on commit 47948fa

Please sign in to comment.