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

Length of P modulus (bytes)

Length of the scalar (bytes)

P modulus parameter Length: MOD_LENGTH + 4

A parameter of a curve Length: MOD_LENGTH + 4

B parameter of a curve Length: MOD_LENGTH + 4

X coordinate of a base point (point of origin on a curve) Length: MOD_LENGTH + 4

Y coordinate of a base point (point of origin on a curve) Length: MOD_LENGTH + 4

Z coordinate of a base point (point of origin on a curve) It is equal to 1 Length: MOD_LENGTH + 4

Order point of the curve Length: SCALAR_LENGTH + 4

Modulo reduction constant precalculated with RedMod service in a SetupConstant mode

Note: That CNS value is for services over prime field: GF(p) For polynomials GF(2^n) it has to be generated separately Length: SCALAR_LENGTH + 12

Provided Methods

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

Implementors