Skip to content

mpereiraesaa/elliptic-curve-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elliptic Curve Cryptography Library

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.

Features

  • 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-bigint crate for handling large integers.

Getting Started

Prerequisites

  • Rust programming language
  • Cargo package manager

Installation

Clone the repository to your local machine:

git clone https://github.com/yourusername/elliptic_curve_crypto.git
cd elliptic_curve_crypto

Usage

You can run the tests to see the library in action:

cargo test

Example

Here'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);
}

Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by the secp256k1 curve used in Bitcoin.
  • Thanks to the Rust community for the num-bigint crate.

Feel free to reach out if you have any questions or suggestions!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages