From bc633a23f5b6f9122b31edb76e231d2cffb2a6fb Mon Sep 17 00:00:00 2001 From: Conrado Gouvea Date: Wed, 28 Feb 2024 13:44:23 -0300 Subject: [PATCH] randomized: add Debug to structs --- 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 71c3733..c5ce2c4 100644 --- a/frost-rerandomized/Cargo.toml +++ b/frost-rerandomized/Cargo.toml @@ -23,6 +23,7 @@ rustdoc-args = ["--cfg", "docsrs"] derive-getters = "0.3.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 f4ff81b..97e8759 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() + } +}