mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Correct secq256k1/embedwards25519 Zeroize implementations
This commit is contained in:
@@ -30,7 +30,7 @@ fn recover_y(x: FieldElement) -> CtOption<FieldElement> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Point.
|
/// Point.
|
||||||
#[derive(Clone, Copy, Debug, Zeroize)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Point {
|
pub struct Point {
|
||||||
x: FieldElement, // / Z
|
x: FieldElement, // / Z
|
||||||
@@ -38,6 +38,18 @@ pub struct Point {
|
|||||||
z: FieldElement,
|
z: FieldElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Zeroize for Point {
|
||||||
|
fn zeroize(&mut self) {
|
||||||
|
self.x.zeroize();
|
||||||
|
self.y.zeroize();
|
||||||
|
self.z.zeroize();
|
||||||
|
let identity = Self::identity();
|
||||||
|
self.x = identity.x;
|
||||||
|
self.y = identity.y;
|
||||||
|
self.z = identity.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ConstantTimeEq for Point {
|
impl ConstantTimeEq for Point {
|
||||||
fn ct_eq(&self, other: &Self) -> Choice {
|
fn ct_eq(&self, other: &Self) -> Choice {
|
||||||
let x1 = self.x * other.z;
|
let x1 = self.x * other.z;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fn recover_y(x: FieldElement) -> CtOption<FieldElement> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Point.
|
/// Point.
|
||||||
#[derive(Clone, Copy, Debug, Zeroize)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Point {
|
pub struct Point {
|
||||||
x: FieldElement, // / Z
|
x: FieldElement, // / Z
|
||||||
@@ -32,6 +32,18 @@ pub struct Point {
|
|||||||
z: FieldElement,
|
z: FieldElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Zeroize for Point {
|
||||||
|
fn zeroize(&mut self) {
|
||||||
|
self.x.zeroize();
|
||||||
|
self.y.zeroize();
|
||||||
|
self.z.zeroize();
|
||||||
|
let identity = Self::identity();
|
||||||
|
self.x = identity.x;
|
||||||
|
self.y = identity.y;
|
||||||
|
self.z = identity.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ConstantTimeEq for Point {
|
impl ConstantTimeEq for Point {
|
||||||
fn ct_eq(&self, other: &Self) -> Choice {
|
fn ct_eq(&self, other: &Self) -> Choice {
|
||||||
let x1 = self.x * other.z;
|
let x1 = self.x * other.z;
|
||||||
|
|||||||
Reference in New Issue
Block a user