From 758d422595f3d9c0ad50b23c03ad2187f1857166 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Wed, 20 Aug 2025 08:14:00 -0400 Subject: [PATCH] Have ::zeroize yield a well-defined value --- Cargo.lock | 2 +- crypto/ed448/Cargo.toml | 2 +- crypto/ed448/src/point.rs | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 475b5ab0..15afb24d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4827,7 +4827,7 @@ dependencies = [ [[package]] name = "minimal-ed448" -version = "0.4.1" +version = "0.4.2" dependencies = [ "ciphersuite", "crypto-bigint", diff --git a/crypto/ed448/Cargo.toml b/crypto/ed448/Cargo.toml index a68ef9ff..bb9748a1 100644 --- a/crypto/ed448/Cargo.toml +++ b/crypto/ed448/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minimal-ed448" -version = "0.4.1" +version = "0.4.2" description = "Unaudited, inefficient implementation of Ed448 in Rust" license = "MIT" repository = "https://github.com/serai-dex/serai/tree/develop/crypto/ed448" diff --git a/crypto/ed448/src/point.rs b/crypto/ed448/src/point.rs index cd49023f..d9b47b5e 100644 --- a/crypto/ed448/src/point.rs +++ b/crypto/ed448/src/point.rs @@ -50,13 +50,25 @@ fn recover_x(y: FieldElement) -> CtOption { } /// Ed448 point. -#[derive(Clone, Copy, Debug, Zeroize)] +#[derive(Clone, Copy, Debug)] pub struct Point { x: FieldElement, y: 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; + } +} + const G: Point = Point { x: G_X, y: G_Y, z: FieldElement::ONE }; impl ConstantTimeEq for Point {