pub struct EllipticCurve {
pub a: BigUint,
pub b: BigUint,
pub p: BigUint,
}Expand description
This represents an elliptic curve of the form y^2 = x^3 + ax + b mod p
Fields§
§a: BigUint§b: BigUint§p: BigUintImplementations§
Source§impl EllipticCurve
impl EllipticCurve
Sourcepub fn add(&self, a: &Point, b: &Point) -> Result<Point, EllipticCurveError>
pub fn add(&self, a: &Point, b: &Point) -> Result<Point, EllipticCurveError>
Perform a point addition: C = A + B where A and B are points which
belong to the curve. Geometrically speaking, the point C is the
x-reflection of the intersection of the lines that passes through A
and B and intersects the curve.
Sourcepub fn double(&self, a: &Point) -> Result<Point, EllipticCurveError>
pub fn double(&self, a: &Point) -> Result<Point, EllipticCurveError>
Perform a point doubling: B = A + A = 2 * A where A is a point in
the curve. Geometrically speaking, the point B is the intersection of
the tangent line over A that intersects the curve.
Sourcepub fn scalar_mul(
&self,
a: &Point,
d: &BigUint,
) -> Result<Point, EllipticCurveError>
pub fn scalar_mul( &self, a: &Point, d: &BigUint, ) -> Result<Point, EllipticCurveError>
Perform a scalar multiplication of a point: B = d * A where A is a
point in the curve and d > 0 is a positive scalar of any value.
It uses the addition/doubling algorithm
T = A
for i in [(bits of d)-1), 0]
T = 2 * T
if bit i of d == 1
T = T + ASourcepub fn is_on_curve(&self, a: &Point) -> bool
pub fn is_on_curve(&self, a: &Point) -> bool
Checks if a point A = (x,y) belongs to the elliptic curve:
if y^2 = x^3 + a * x + b mod p then returns true, if not, returns
false.
Trait Implementations§
Source§impl Clone for EllipticCurve
impl Clone for EllipticCurve
Source§fn clone(&self) -> EllipticCurve
fn clone(&self) -> EllipticCurve
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more