From 9e19bc9d49d3fe3a5056c988bfaefa12dcdbf608 Mon Sep 17 00:00:00 2001 From: Conrado Gouvea Date: Thu, 6 Jun 2024 10:42:09 -0300 Subject: [PATCH] randomized: add Debug to structs (#622) --- frost-rerandomized/Cargo.toml | 1 + frost-rerandomized/src/lib.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/frost-rerandomized/Cargo.toml b/frost-rerandomized/Cargo.toml index 21bf223d..fbccc56b 100644 --- a/frost-rerandomized/Cargo.toml +++ b/frost-rerandomized/Cargo.toml @@ -23,6 +23,7 @@ rustdoc-args = ["--cfg", "docsrs"] derive-getters = "0.4.0" document-features = "0.2.7" frost-core = { path = "../frost-core", version = "1.0.0", features = ["internals"] } +hex = "0.4.3" rand_core = "0.6" [dev-dependencies] diff --git a/frost-rerandomized/src/lib.rs b/frost-rerandomized/src/lib.rs index f4ff81b9..97e87590 100644 --- a/frost-rerandomized/src/lib.rs +++ b/frost-rerandomized/src/lib.rs @@ -249,6 +249,19 @@ where } } +impl core::fmt::Debug for Randomizer +where + C: Ciphersuite, +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_tuple("Randomizer") + .field(&hex::encode( + <::Field>::serialize(&self.0).as_ref(), + )) + .finish() + } +} + /// Randomized parameters for a signing instance of randomized FROST. #[derive(Clone, PartialEq, Eq, Getters)] pub struct RandomizedParams { @@ -303,3 +316,19 @@ where } } } + +impl core::fmt::Debug for RandomizedParams +where + C: Ciphersuite, +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("RandomizedParams") + .field("randomizer", &self.randomizer) + .field( + "randomizer_element", + &hex::encode(::serialize(&self.randomizer_element).as_ref()), + ) + .field("randomized_verifying_key", &self.randomized_verifying_key) + .finish() + } +}