| Crates.io | curveforge-macro |
| lib.rs | curveforge-macro |
| version | 0.3.0 |
| created_at | 2025-09-15 14:29:13.246199+00 |
| updated_at | 2025-09-15 14:29:13.246199+00 |
| description | Optimised, secure, and generalised algorithms for elliptic curve arithmetic |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1840130 |
| size | 209,513 |
curveforge_macro is a procedural macro crate that provides a set of powerful macros for generating elliptic curve and finite field implementations.
These macros conform to the trait-based abstractions defined in the curveforge_traits crate, enabling modular, secure, and efficient cryptographic structures.
finite_field!
Define a prime finite field for cryptographic applications. Assumes the modulus is greater than 2.
elliptic_curve_model!
Specify the algebraic form of an elliptic curve (e.g., Weierstrass, Montgomery).
elliptic_curve!
Combine a finite field and model to create a complete elliptic curve implementation.
curveforge_traits to provide a unified algebraic interface.Here is a basic usage example. Grammars for the model and curve can be found in model.pest and curve.pest.
use curveforge::prelude::*;
// Define a finite field over any prime number (larger than 2). Order can be given in hex.
finite_field!(MyFiniteField, 7);
// Define a type of elliptic curve.
elliptic_curve_model! {
// Attribute section
[attributes]
name = MyCurveModel // Required
coordinates = (x, y) // Required
constants = (a, b) // Have to be provided by the specific curve that uses this model
// Functions section (define behaviour matching traits in [curveforge_traits::curve_model])
[functions]
add: (P: Self, Q: Self) -> Self
// Series of statements
x <- P.x + Q.x
y <- P.y + Q.y
// Return expression
Self::new(x, y)
}
elliptic_curve! {
// Attribute section
[attributes]
name = MyCurve // Required
model = MyCurveModel // Required, matching a model in scope
// Required prime base field and prime order subgroup sizes
field_size = 7
group_size = 7
// Generator and identity points on the curve
generator = (1, 1)
identity = (0, 0)
// Constants section
[constants]
// Define constants required by the model
a = 1
b = 2
}