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
impl ProjectivePoint
Sourcepub fn is_identity(&self) -> Choice
pub fn is_identity(&self) -> Choice
Whether this is the point at infinity (Z = 0). Constant-time.
Sourcepub fn add(&self, other: &Self) -> Self
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.
Sourcepub fn double(&self) -> Self
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.
Sourcepub fn to_affine(&self) -> Option<(Fp, Fp)>
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.6’s
ConstMontyForm::invert (safegcd / Bernstein-Yang), which is
documented as constant-time but direct measurement on the
project’s dudect harness shows |tau| ≈ 0.70 between different
inputs. Callers that pass secret-derived Z (notably mul_g(k)
inside the SM2 sign retry loop, where k is the secret nonce)
inherit a measurable timing side-channel until v0.2 replaces the
invert site with a Fermat-style pow_bounded_exp.
See SECURITY.md for the full posture.
Trait Implementations§
Source§impl Clone for ProjectivePoint
impl Clone for ProjectivePoint
Source§fn clone(&self) -> ProjectivePoint
fn clone(&self) -> ProjectivePoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConditionallySelectable for ProjectivePoint
impl ConditionallySelectable for ProjectivePoint
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
self and other if choice == 1; otherwise,
reassign both unto themselves. Read more