embassy-crypto

Crates

git

Versions

default

Flavors

Skip to main content

Point

Struct Point 

Source
pub struct Point(/* private fields */);
Expand description

A point on the curve, the point at infinity included.

Held in the arithmetic driver’s own representation (projective coordinates, typically), so a chain of operations converts to affine coordinates once, when asked to through Self::to_affine. Comparing two points converts both. Arithmetic is served by the curve’s arithmetic driver.

Implementations§

Source§

impl Point

Source

pub fn generator() -> Self

The base point G.

Source

pub fn identity() -> Self

The point at infinity.

Source

pub fn from_xy(x: &[u8; 32], y: &[u8; 32]) -> Result<Self, Error>

Build a point from its coordinates, checking that it is on the curve.

Source

pub fn from_sec1(bytes: &[u8; 65]) -> Result<Self, Error>

Parse an uncompressed SEC1 encoding (0x04 || x || y), checking that the point is on the curve.

Source

pub fn from_affine(p: &P256Point) -> Result<Self, Error>

Import an affine point, checking that it is on the curve.

Source

pub fn to_affine(&self) -> Option<P256Point>

The affine coordinates, or None for the point at infinity.

Source

pub fn to_sec1(&self) -> Option<[u8; 65]>

The uncompressed SEC1 encoding (0x04 || x || y), or None for the point at infinity.

Source

pub fn is_identity(&self) -> bool

Whether this is the point at infinity.

Source

pub fn from_driver(p: P256ArithImplPoint) -> Self

Wrap a point in the driver representation.

Source

pub fn as_driver(&self) -> &P256ArithImplPoint

The driver representation.

Source

pub fn neg(&self) -> Self

-self.

Source

pub fn add(&self, other: &Self) -> Self

self + other.

Source

pub fn mul(&self, k: &Scalar) -> Self

k * self.

Source

pub fn mul_base(k: &Scalar) -> Self

k * G.

Source

pub fn lincomb(a: &Scalar, p: &Self, b: &Scalar, q: &Self) -> Self

a * p + b * q.

Constant-time in the scalars: safe for secret scalars, as in a PAKE or a Schnorr-style signature. Cheaper than the equivalent muls and add when the driver shares the doublings.

Source

pub fn lincomb_vartime(a: &Scalar, p: &Self, b: &Scalar, q: &Self) -> Self

a * p + b * q.

May be variable-time: only for public inputs, as in signature verification. Faster than Self::lincomb.

Trait Implementations§

Source§

impl Clone for Point

Source§

fn clone(&self) -> Point

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Point

Source§

impl Debug for Point

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Point

Source§

impl Format for Point

Available on crate feature defmt only.
Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
Source§

impl PartialEq for Point

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl TryFrom<Point> for P256Point

Source§

fn try_from(p: Point) -> Result<Self, Error>

Fails for the point at infinity.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

impl TryFrom<Point> for PublicKey

Source§

fn try_from(p: Point) -> Result<Self, Error>

Fails for the point at infinity.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

impl TryFrom<Point> for VerifyingKey

Source§

fn try_from(p: Point) -> Result<Self, Error>

Fails for the point at infinity.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

impl TryFrom<PublicKey> for Point

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(p: PublicKey) -> Result<Self, Error>

Performs the conversion.
Source§

impl TryFrom<VerifyingKey> for Point

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(p: VerifyingKey) -> Result<Self, Error>

Performs the conversion.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Point

§

impl !Unpin for Point

§

impl !UnwindSafe for Point

§

impl Freeze for Point

§

impl Send for Point

§

impl Sync for Point

§

impl UnsafeUnpin for Point

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.