pub trait Curve {
const MOD_LENGTH: u2;
const SCALAR_LENGTH: u2;
const MODULO_P: &'static [u8];
const A_CURVE: &'static [u8];
const B_CURVE: &'static [u8];
const BASE_POINT_A_X: &'static [u8];
const BASE_POINT_A_Y: &'static [u8];
const BASE_POINT_A_Z: &'static [u8];
const ORDER_POINT: &'static [u8];
const CNS: &'static [u8];
fn verify_curve() -> Result<(), CurveVerificationFailure> { ... }
}
Expand description
A trait that generalizes over a curve concept.
General equation of a curve is:
y^2 = x^3 + a*x + b
Provides all the parametrizations through associated constants.
Associated constant slices must incorporate zero padding required by PUKCC.
Const generics are limited. It is impossible to have const arrays with a
length as a separate const parameter. Therefore slices are used instead and
length verification is moved to runtime (Curve::verify_curve
)
Required Associated Constants
sourceconst MOD_LENGTH: u2
const MOD_LENGTH: u2
Length of P modulus (bytes)
sourceconst SCALAR_LENGTH: u2
const SCALAR_LENGTH: u2
Length of the scalar (bytes)
sourceconst BASE_POINT_A_X: &'static [u8]
const BASE_POINT_A_X: &'static [u8]
X coordinate of a base point (point of origin on a curve) Length: MOD_LENGTH + 4
sourceconst BASE_POINT_A_Y: &'static [u8]
const BASE_POINT_A_Y: &'static [u8]
Y coordinate of a base point (point of origin on a curve) Length: MOD_LENGTH + 4
sourceconst BASE_POINT_A_Z: &'static [u8]
const BASE_POINT_A_Z: &'static [u8]
Z coordinate of a base point (point of origin on a curve) It is equal to 1 Length: MOD_LENGTH + 4
sourceconst ORDER_POINT: &'static [u8]
const ORDER_POINT: &'static [u8]
Order point of the curve Length: SCALAR_LENGTH + 4
Provided Methods
sourcefn verify_curve() -> Result<(), CurveVerificationFailure>
fn verify_curve() -> Result<(), CurveVerificationFailure>
Function that can be used during runtime to verify if a curve is correctly defined.
That is:
- lengths of slices are following the requirements
- slices are 4 aligned