mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 20:59:23 +00:00
Add crate for working with short Weierstrass elliptic curves
This commit is contained in:
30
crypto/short-weierstrass/src/lib.rs
Normal file
30
crypto/short-weierstrass/src/lib.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
#![doc = include_str!("../README.md")]
|
||||
#![no_std]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use core::fmt::Debug;
|
||||
|
||||
use zeroize::Zeroize;
|
||||
use group::ff::PrimeField;
|
||||
|
||||
mod affine;
|
||||
pub use affine::Affine;
|
||||
mod projective;
|
||||
pub use projective::Projective;
|
||||
|
||||
/// An elliptic curve represented in short Weierstrass form, with equation `y^2 = x^3 + A x + B`.
|
||||
pub trait ShortWeierstrass: 'static + Sized + Debug {
|
||||
/// The field the elliptic curve is defined over.
|
||||
type FieldElement: Zeroize + PrimeField;
|
||||
/// The constant `A` from the curve equation.
|
||||
const A: Self::FieldElement;
|
||||
/// The constant `B` from the curve equation.
|
||||
const B: Self::FieldElement;
|
||||
/// A generator of this elliptic curve.
|
||||
const GENERATOR: Affine<Self>;
|
||||
/// The scalar type.
|
||||
///
|
||||
/// This may be omitted by specifying `()`.
|
||||
type Scalar;
|
||||
}
|
||||
Reference in New Issue
Block a user