This repository contains a custom implementation of elliptic curve arithmetic in C. It supports basic operations on elliptic curves such as verifying points, point addition, point negation, and scalar multiplication.
The library provides functionalities to work with elliptic curves over finite fields defined by equations of the form:
The implementation uses GMP for arbitrary-precision arithmetic to ensure compatibility with large numbers.
- GCC or any C compiler
- GMP library
sudo apt update
sudo apt install libgmp-devbrew install gmpInstall GMP for Windows and ensure the headers and libraries are correctly linked during compilation.
Use the following command to compile the example program:
gcc example.c EC.c -o example_program -lgmpAn example usage of the library is provided in the example.c file. The program demonstrates:
- Initializing curve parameters.
- Checking if a point is on the curve.
- Point negation.
- Point addition (doubling).
- Scalar multiplication.
Run the compiled example:
./example_programExpected output:
Point P(3, 6) is on the curve.
Negation of P: (3, 91)
Point Doubling: P + P = (80, 10)
Scalar Multiplication: 3P = (80, 87)
- Point Verification: Check if a given point lies on the elliptic curve.
- Point Negation: Compute the negation of a point.
- Point Addition: Add two points on the curve.
- Scalar Multiplication: Multiply a point by a scalar.
- Ensure all GMP dependencies are installed before compiling.
- This library uses affine coordinates for simplicity.
- Example values are predefined for demonstration purposes but can be replaced with custom inputs.