pub struct Ecc<'d> { /* private fields */ }
Implementations§
Source§impl<'d> Ecc<'d>
impl<'d> Ecc<'d>
pub fn new(ecc: impl Peripheral<P = ECC> + 'd) -> Ecc<'d>
pub fn free(self) -> PeripheralRef<'d, ECC>
pub fn reset(&mut self)
Sourcepub fn affine_point_multiplication(
&mut self,
curve: &EllipticCurve,
k: &[u8],
x: &mut [u8],
y: &mut [u8],
) -> Result<(), Error>
pub fn affine_point_multiplication( &mut self, curve: &EllipticCurve, k: &[u8], x: &mut [u8], y: &mut [u8], ) -> Result<(), Error>
Sourcepub fn affine_point_verification(
&mut self,
curve: &EllipticCurve,
x: &[u8],
y: &[u8],
) -> Result<(), Error>
pub fn affine_point_verification( &mut self, curve: &EllipticCurve, x: &[u8], y: &[u8], ) -> Result<(), Error>
§Base Point Verification
Base Point Verification can be used to verify if a point (Px, Py) is on a selected elliptic curve.
§Error
This function will return an error if any bitlength value is different from the bitlength of the prime fields of the curve.
This function will return an error if the point is not on the selected elliptic curve.
Sourcepub fn affine_point_verification_multiplication(
&mut self,
curve: &EllipticCurve,
k: &[u8],
px: &mut [u8],
py: &mut [u8],
qx: &mut [u8],
qy: &mut [u8],
qz: &mut [u8],
) -> Result<(), Error>
pub fn affine_point_verification_multiplication( &mut self, curve: &EllipticCurve, k: &[u8], px: &mut [u8], py: &mut [u8], qx: &mut [u8], qy: &mut [u8], qz: &mut [u8], ) -> Result<(), Error>
§Base Point Verification + Base Point Multiplication
In this working mode, ECC first verifies if Point (P_x, P_y) is on the selected elliptic curve or not. If yes, then perform the multiplication: (Q_x, Q_y) = (J_x, J_y, J_z) = k * (P_x, P_y)
The affine point representation output is stored in px
and py
.
The Jacobian point representation output is stored in qx
, qy
, and
qz
.
§Error
This function will return an error if any bitlength value is different from the bitlength of the prime fields of the curve.
This function will return an error if the point is not on the selected elliptic curve.
Sourcepub fn jacobian_point_multiplication(
&mut self,
curve: &EllipticCurve,
k: &mut [u8],
x: &mut [u8],
y: &mut [u8],
) -> Result<(), Error>
pub fn jacobian_point_multiplication( &mut self, curve: &EllipticCurve, k: &mut [u8], x: &mut [u8], y: &mut [u8], ) -> Result<(), Error>
Sourcepub fn jacobian_point_verification(
&mut self,
curve: &EllipticCurve,
x: &[u8],
y: &[u8],
z: &[u8],
) -> Result<(), Error>
pub fn jacobian_point_verification( &mut self, curve: &EllipticCurve, x: &[u8], y: &[u8], z: &[u8], ) -> Result<(), Error>
§Jacobian Point Verification
Jacobian Point Verification can be used to verify if a point (Q_x, Q_y, Q_z) is on a selected elliptic curve.
§Error
This function will return an error if any bitlength value is different from the bitlength of the prime fields of the curve.
This function will return an error if the point is not on the selected elliptic curve.
Sourcepub fn affine_point_verification_jacobian_multiplication(
&mut self,
curve: &EllipticCurve,
k: &mut [u8],
x: &mut [u8],
y: &mut [u8],
) -> Result<(), Error>
pub fn affine_point_verification_jacobian_multiplication( &mut self, curve: &EllipticCurve, k: &mut [u8], x: &mut [u8], y: &mut [u8], ) -> Result<(), Error>
§Base Point Verification + Jacobian Point Multiplication
In this working mode, ECC first verifies if Point (Px, Py) is on the selected elliptic curve or not. If yes, then perform the multiplication: (Q_x, Q_y, Q_z) = k * (P_x, P_y, 1)
Output is stored in x
, y
, and k
.
§Error
This function will return an error if any bitlength value is different from the bitlength of the prime fields of the curve.
This function will return an error if the point is not on the selected elliptic curve.
Sourcepub fn affine_point_addition(
&mut self,
curve: &EllipticCurve,
px: &mut [u8],
py: &mut [u8],
qx: &mut [u8],
qy: &mut [u8],
qz: &mut [u8],
) -> Result<(), Error>
pub fn affine_point_addition( &mut self, curve: &EllipticCurve, px: &mut [u8], py: &mut [u8], qx: &mut [u8], qy: &mut [u8], qz: &mut [u8], ) -> Result<(), Error>
§Point Addition
In this working mode, ECC first verifies if Point (Px, Py) is on the selected elliptic curve or not. If yes, then perform the addition: (R_x, R_y) = (J_x, J_y, J_z) = (P_x, P_y, 1) + (Q_x, Q_y, Q_z)
This functions requires data in Little Endian.
The affine point representation output is stored in px
and py
.
The Jacobian point representation output is stored in qx
, qy
, and
qz
.
§Error
This function will return an error if any bitlength value is different from the bitlength of the prime fields of the curve.
This function will return an error if the point is not on the selected elliptic curve.
Sourcepub fn mod_operations(
&mut self,
curve: &EllipticCurve,
a: &mut [u8],
b: &mut [u8],
work_mode: WorkMode,
) -> Result<(), Error>
pub fn mod_operations( &mut self, curve: &EllipticCurve, a: &mut [u8], b: &mut [u8], work_mode: WorkMode, ) -> Result<(), Error>
§Mod Operations (+-*/)
In this working mode, ECC first verifies if Point (A, B) is on the selected elliptic curve or not. If yes, then perform single mod operation: R = A (+-*/) B mod N
This functions requires data in Little Endian.
Output is stored in a
(+-) and in b
(*/).
§Error
This function will return an error if any bitlength value is different from the bitlength of the prime fields of the curve.
This function will return an error if the point is not on the selected elliptic curve.