This library is an implementation of elliptic curve cryptography (ECC) focusing on the secp256k1 curve. It is designed for educational purposes and experimentation with ECC concepts.
- Implementation of the secp256k1 elliptic curve.
- Basic operations on elliptic curves, including point addition, point doubling, and scalar multiplication.
- Support for points at infinity (identity element).
- Utilizes the
num-bigintcrate for handling large integers.
- Rust programming language
- Cargo package manager
Clone the repository to your local machine:
git clone https://github.com/yourusername/elliptic_curve_crypto.git
cd elliptic_curve_cryptoYou can run the tests to see the library in action:
cargo testHere's a simple example of how to use the library to perform scalar multiplication on the secp256k1 curve:
use elliptic_curve_crypto::EllipticCurve;
use elliptic_curve_crypto::Point;
use num_bigint::BigUint;
fn main() {
let p = BigUint::parse_bytes(b"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16).unwrap();
let a = BigUint::from(0u32);
let b = BigUint::from(7u32);
let ec = EllipticCurve { a, b, p };
let gx = BigUint::parse_bytes(b"79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", 16).unwrap();
let gy = BigUint::parse_bytes(b"483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8", 16).unwrap();
let g = Point::Coord(gx, gy);
let n = BigUint::parse_bytes(b"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", 16).unwrap();
let result = ec.scalar_mul(&g, &n);
println!("Result of scalar multiplication: {:?}", result);
}Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the secp256k1 curve used in Bitcoin.
- Thanks to the Rust community for the
num-bigintcrate.
Feel free to reach out if you have any questions or suggestions!