From 50c49127fb679195995e075a83422c3feaac755c Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Sun, 10 Jan 2021 17:03:08 -0800 Subject: [PATCH] Add reveal to commitment and bivarcommitment --- src/poly.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/poly.rs b/src/poly.rs index 38614ed..a8f5588 100644 --- a/src/poly.rs +++ b/src/poly.rs @@ -513,6 +513,11 @@ impl Commitment { let len = self.coeff.len() - zeros; self.coeff.truncate(len) } + + /// Generates a non-redacted debug string + pub fn reveal(&self) -> String { + format!("Commitment {{ coeff: {:?} }}", self.coeff) + } } /// A symmetric bivariate polynomial in the prime field. @@ -729,6 +734,16 @@ impl BivarCommitment { fn powers(&self, x: T) -> Vec { powers(x, self.degree) } + + /// Generates a non-redacted debug string. This method differs from the + /// `Debug` implementation in that it *does* leak the the struct's + /// internal state. + pub fn reveal(&self) -> String { + format!( + "BivarCommitment {{ degree: {}, coeff: {:?} }}", + self.degree, self.coeff + ) + } } /// Returns the `0`-th to `degree`-th power of `x`.