Skip to main content

dcrypt_algorithms/ec/
mod.rs

1// File: crates/algorithms/src/ec/mod.rs
2//! Elliptic Curve Primitives
3//!
4//! This module provides low-level elliptic-curve operations on several curves.
5//! Individual implementations use timing-aware techniques, but the module has
6//! no blanket compiler- or target-level constant-time guarantee and is not by
7//! itself a complete protocol such as RFC 9180 HPKE.
8//! This module now also includes support for Koblitz (secp256k1) and Binary (sect283k1) curves.
9
10pub mod b283k;
11pub mod bls12_381;
12pub mod k256; // For secp256k1
13pub mod p192;
14pub mod p224;
15pub mod p256;
16pub mod p384;
17pub mod p521; // For sect283k1
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    pairing as bls12_381_pairing, Bls12_381Scalar, G1Projective as Bls12_381G1,
23    G2Projective as Bls12_381G2, Gt as Bls12_381Gt,
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 {}