ec_generic
This crate is a minimal and easy-to-use elliptic curve library. This library allows to perform the following operations over an elliptic curve finite cyclic group:
- Point Addition:
R = P + Q - Point Doubling:
R = P + P = 2 * P - Scalar Multiplication:
R = d * P
A generic elliptic curve is defined as y^2 = x^3 + ax + b mod p, and in this
particular library the constrains are:
pshould be a prime number bigger than 34 a^3 + 27 b^2 != 0
The library could be use in any cryptographic algorithm that requires elliptic curve groups, for example:
- Digital Signature Algorithm (DSA)
- Zero-Knowledge Proofs (ZKP)
Usage
This crate is on crates.io and can be
used by adding regex to your dependencies in your project's Cargo.toml.
[]
= "0.1.14"
Example: y^2 = x^3 + 2x + 2 mod 17
use ;
use BigUint;
let ec = EllipticCurve ;
// (6,3) + (5,1) = (10,6)
let p1 = Coor;
let p2 = Coor;
let pr = Ok;
let res = ec.add;
assert_eq!;
let res = ec.add;
assert_eq!;
Example: secp256k1: y^2 = x^3 + 7 mod p (large)
use ;
use BigUint;
let p = parse_bytes
.expect;
let n = parse_bytes
.expect;
let gx = parse_bytes
.expect;
let gy = parse_bytes
.expect;
let ec = EllipticCurve ;
let g = Coor;
// n * G = I (Identity)
let res = ec.scalar_mul;
assert_eq!;