dcrypt_algorithms/ec/
mod.rs

1// File: crates/algorithms/src/ec/mod.rs
2//! Elliptic Curve Primitives
3//!
4//! This module provides constant-time implementations of elliptic curve operations
5//! on NIST curves P-224, P-256, P-384, and P-521. These implementations are designed
6//! to be resistant to timing attacks and provide a foundation for higher-level
7//! protocols like ECDH-KEM.
8//! This module now also includes support for Koblitz (secp256k1) and Binary (sect283k1) curves.
9
10pub mod b283k;
11pub mod k256; // For secp256k1
12pub mod p192;
13pub mod p224;
14pub mod p256;
15pub mod p384;
16pub mod p521; // For sect283k1
17pub mod bls12_381;
18
19// Re-export types with consistent naming scheme.
20// This corrects the original error which tried to export non-existent types like 'PointG1'.
21pub use bls12_381::{
22    G1Projective as Bls12_381G1, G2Projective as Bls12_381G2, Gt as Bls12_381Gt,
23    Bls12_381Scalar, pairing as bls12_381_pairing,
24};
25
26pub use b283k::{Point as B283kPoint, Scalar as B283kScalar};
27pub use k256::{Point as K256Point, Scalar as K256Scalar};
28pub use p192::{Point as P192Point, Scalar as P192Scalar};
29pub use p224::{Point as P224Point, Scalar as P224Scalar};
30pub use p256::{Point as P256Point, Scalar as P256Scalar};
31pub use p384::{Point as P384Point, Scalar as P384Scalar};
32pub use p521::{Point as P521Point, Scalar as P521Scalar};
33
34/// Common trait for coordinate systems used in elliptic curve operations
35pub trait CoordinateSystem {}
36
37/// Affine coordinates (x,y)
38pub struct Affine;
39impl CoordinateSystem for Affine {}
40
41/// Jacobian projective coordinates (X:Y:Z) where x = X/Z² and y = Y/Z³
42pub struct Jacobian;
43impl CoordinateSystem for Jacobian {}