pub struct Secp256k1 { /* private fields */ }Expand description
Secp256k1 - a short Weierstrass elliptic curve of the form y^2 = x^3 + 7 over
the prime field of modulus 2^256 - 2^32 - 977.
Implementations§
Source§impl Secp256k1
impl Secp256k1
Sourcepub fn new(b: &CircuitBuilder) -> Self
pub fn new(b: &CircuitBuilder) -> Self
Creates new curve struct with constants related to curve and its coordinate and scalar fields.
Sourcepub const fn f_p(&self) -> &PseudoMersennePrimeField
pub const fn f_p(&self) -> &PseudoMersennePrimeField
Coordinate field.
Sourcepub const fn f_scalar(&self) -> &PseudoMersennePrimeField
pub const fn f_scalar(&self) -> &PseudoMersennePrimeField
Scalar field.
Sourcepub fn assert_on_curve(&self, b: &CircuitBuilder, p: &Secp256k1Affine)
pub fn assert_on_curve(&self, b: &CircuitBuilder, p: &Secp256k1Affine)
Assert that given affine point actually resides on curve.
Considers point-at-infinity not on curve.
Sourcepub fn recover(
&self,
b: &CircuitBuilder,
r: &BigUint,
recid_odd: Wire,
) -> Secp256k1Affine
pub fn recover( &self, b: &CircuitBuilder, r: &BigUint, recid_odd: Wire, ) -> Secp256k1Affine
Recover the full affine point (r, y) by its x coordinate and y parity.
Returns point-at-infinity in case recovery isn’t possible.
Note: we don’t handle the case where r does not fit into the scalar field, thus recid is boolean, and not a 0-3 bitmask signifying both parity and scalar field overflow.
Sourcepub fn negate_if(
&self,
b: &CircuitBuilder,
cond: Wire,
p: &Secp256k1Affine,
) -> Secp256k1Affine
pub fn negate_if( &self, b: &CircuitBuilder, cond: Wire, p: &Secp256k1Affine, ) -> Secp256k1Affine
Negate the curve point p if MSB-bool cond is true.
Sourcepub fn endomorphism(
&self,
b: &CircuitBuilder,
p: &Secp256k1Affine,
) -> Secp256k1Affine
pub fn endomorphism( &self, b: &CircuitBuilder, p: &Secp256k1Affine, ) -> Secp256k1Affine
Compute the endomorphism λ (x, y) = (βx, y).
Sourcepub fn add(
&self,
b: &CircuitBuilder,
p1: &Secp256k1Affine,
p2: &Secp256k1Affine,
) -> Secp256k1Affine
pub fn add( &self, b: &CircuitBuilder, p1: &Secp256k1Affine, p2: &Secp256k1Affine, ) -> Secp256k1Affine
Add two curve points.
Requires both p1 and p2 to be either valid curve points or points at infinities.
This implementation is complete - it handles the cases of either p1 or p2 being
point-at-infinities, as well as being equal (which falls back to doubling).
Sourcepub fn add_incomplete(
&self,
b: &CircuitBuilder,
p1: &Secp256k1Affine,
p2: &Secp256k1Affine,
) -> Secp256k1Affine
pub fn add_incomplete( &self, b: &CircuitBuilder, p1: &Secp256k1Affine, p2: &Secp256k1Affine, ) -> Secp256k1Affine
Add two curve points, incomplete.
Requires both p1 and p2 to be either valid curve points or points at infinities.
Unlike Secp256k1::add this implementation does not handle doubling, asserting false in
that case.
Sourcepub fn double(&self, b: &CircuitBuilder, p: &Secp256k1Affine) -> Secp256k1Affine
pub fn double(&self, b: &CircuitBuilder, p: &Secp256k1Affine) -> Secp256k1Affine
Double a curve point.
Requires both p to be either a valid curve point or point at infinity.
Auto Trait Implementations§
impl Freeze for Secp256k1
impl RefUnwindSafe for Secp256k1
impl Send for Secp256k1
impl Sync for Secp256k1
impl Unpin for Secp256k1
impl UnsafeUnpin for Secp256k1
impl UnwindSafe for Secp256k1
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more