pub trait Curve {
const MOD_LENGTH: u16;
const SCALAR_LENGTH: u16;
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<(), CurveVerficationFailure> { ... }
}
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
)
Associated Constants
const MOD_LENGTH: u16
const MOD_LENGTH: u16
Length of P modulus (bytes)
const SCALAR_LENGTH: u16
const SCALAR_LENGTH: u16
Length of the scalar (bytes)
const MODULO_P: &'static [u8]
const MODULO_P: &'static [u8]
P modulus parameter Length: MOD_LENGTH + 4
const A_CURVE: &'static [u8]
const A_CURVE: &'static [u8]
A parameter of a curve Length: MOD_LENGTH + 4
const B_CURVE: &'static [u8]
const B_CURVE: &'static [u8]
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
const ORDER_POINT: &'static [u8]
const ORDER_POINT: &'static [u8]
Order point of the curve Length: SCALAR_LENGTH + 4
const CNS: &'static [u8]
const CNS: &'static [u8]
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
fn verify_curve() -> Result<(), CurveVerficationFailure>
fn verify_curve() -> Result<(), CurveVerficationFailure>
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