Skip to main content

EcPoint

Trait EcPoint 

Source
pub trait EcPoint<'a, const LEN: usize, const SCALAR_LEN: usize> {
    type Scalar<'s>: EcScalar<'s, SCALAR_LEN>
       where Self: 'a + 's;

    // Required methods
    fn is_valid_pubkey(&self) -> Result<bool, Error>;
    fn neg(&self) -> Result<Self, Error>
       where Self: Sized;
    fn mul(&self, scalar: &Self::Scalar<'a>) -> Result<Self, Error>
       where Self: Sized;
    fn add_mul(
        &self,
        s1: &Self::Scalar<'a>,
        p2: &Self,
        s2: &Self::Scalar<'a>,
    ) -> Result<Self, Error>
       where Self: Sized;
    fn write_canon(&self, point: &mut CryptoSensitive<LEN>) -> Result<(), Error>;
}
Expand description

Trait representing an Elliptic Curve (EC) point.

Required Associated Types§

Source

type Scalar<'s>: EcScalar<'s, SCALAR_LEN> where Self: 'a + 's

Scalar type associated with this EC point.

Required Methods§

Source

fn is_valid_pubkey(&self) -> Result<bool, Error>

Return true if this point is a valid public key on the curve, i.e. it is on the curve, its coordinates are in range, and it is not the identity (point at infinity) — equivalently, per RFC 9383 §4, that the cofactor multiple h*P is not the identity element.

SPAKE2+ requires this validation on the peer’s public share (X on the verifier side, Y on the prover side); an unchecked identity/invalid point lets a peer force the shared secret and break the protocol’s guarantees.

Source

fn neg(&self) -> Result<Self, Error>
where Self: Sized,

Negate this EC point.

Source

fn mul(&self, scalar: &Self::Scalar<'a>) -> Result<Self, Error>
where Self: Sized,

Multiply this EC point by the given scalar.

Source

fn add_mul( &self, s1: &Self::Scalar<'a>, p2: &Self, s2: &Self::Scalar<'a>, ) -> Result<Self, Error>
where Self: Sized,

Perform an addition-multiplication operation, i.e. compute P1 * s1 + P2 * s2, where P1 is self.

§Arguments
  • s1: Scalar to multiply self with.
  • p2: Second EC point to multiply with s2.
  • s2: Scalar to multiply p2 with.
§Returns
  • The result of the addition-multiplication.
Source

fn write_canon(&self, point: &mut CryptoSensitive<LEN>) -> Result<(), Error>

Write the canonical representation of this EC point into the given buffer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, const LEN: usize, const SCALAR_LEN: usize> EcPoint<'a, LEN, SCALAR_LEN> for DummyCrypto