From ee29fb4b848558eca2826c0887b48e30ea617045 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Wed, 1 Jun 2022 18:38:10 +0200 Subject: [PATCH] Revive base field type on Curve trait Curves operate on certain base fields. Sometimes in can be useful to have a direct reference to which field this is. With the `Base` associate type you can not get that information. More concretely this will be used by some GPU code, which needs access to the information which base field a curve operates on. BREAKING CHANGE: crates implementing `Curve` need to define the `Base`. --- src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 1ef6bc9..749bff6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ pub use ff; use core::fmt; use core::iter::Sum; use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign}; -use ff::PrimeField; +use ff::{Field, PrimeField}; use rand_core::RngCore; use subtle::{Choice, CtOption}; @@ -96,6 +96,9 @@ pub trait Group: pub trait Curve: Group + GroupOps<::AffineRepr> + GroupOpsOwned<::AffineRepr> { + /// The base field of the elliptic curve. + type Base: Field; + /// The affine representation for this elliptic curve. type AffineRepr;