Skip to main content

ProjectivePoint

Struct ProjectivePoint 

Source
pub struct ProjectivePoint { /* private fields */ }
Expand description

A point on the SM2 curve in projective coordinates (X:Y:Z).

The point at infinity is represented as (0:1:0).

Implementations§

Source§

impl ProjectivePoint

Source

pub const fn identity() -> Self

The point at infinity (0 : 1 : 0).

Source

pub const fn generator() -> Self

The curve generator G.

Source

pub fn is_identity(&self) -> Choice

Whether this is the point at infinity (Z = 0). Constant-time.

Source

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

Add two points using RCB Algorithm 4 (a=-3 specialized, complete).

Transcribed from eprint 2015/1060 Algorithm 4.

Source

pub fn double(&self) -> Self

Double a point using RCB Algorithm 6 (a=-3 specialized). Cost: 3S + 5M + a few additions.

Transcribed from eprint 2015/1060 Algorithm 6.

Source

pub fn neg(&self) -> Self

Negate a point: (X:Y:Z) -> (X:-Y:Z).

Source

pub fn to_affine(&self) -> Option<(Fp, Fp)>

Convert to affine (x, y) coordinates. Returns None for the identity point (where Z = 0).

§Constant-time caveat

The Z-inverse goes through crypto-bigint = 0.7.3’s ConstMontyForm::invert (safegcd / Bernstein-Yang). v0.1.0 shipped on crypto-bigint = 0.6 where direct measurement on the dudect harness showed |tau| ≈ 0.70 between different inputs — a nonce-dependent timing side-channel for callers passing secret-derived Z. Main (post-publish, on 0.7.3) measures |tau| ≈ 0.006 directly via the W0 ct_fp_invert target at 100K samples — two orders of magnitude under the 0.20 gate. The v0.2 Fermat-invert workstream is dropped; pow_bounded_exp remains a fallback if a future crypto-bigint release regresses. See SECURITY.md for the full posture.

Trait Implementations§

Source§

impl Clone for ProjectivePoint

Source§

fn clone(&self) -> ProjectivePoint

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 ConditionallySelectable for ProjectivePoint

Source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
Source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Source§

impl ConstantTimeEq for ProjectivePoint

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl Debug for ProjectivePoint

Source§

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

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

impl From<ProjectivePoint> for Sm2PublicKey

Source§

fn from(p: ProjectivePoint) -> Self

Converts to this type from the input type.
Source§

impl Copy for ProjectivePoint

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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.