From 33c162f3b482ed917da9511783dec8ac478acef3 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Tue, 16 Nov 2021 16:01:09 +0000 Subject: [PATCH] Make traits public to allow PCC to use formatting traits --- common/nymcoconut/src/lib.rs | 2 +- common/nymcoconut/src/proofs/mod.rs | 2 +- common/nymcoconut/src/scheme/verification.rs | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/nymcoconut/src/lib.rs b/common/nymcoconut/src/lib.rs index ace0883d10..810aed2d2b 100644 --- a/common/nymcoconut/src/lib.rs +++ b/common/nymcoconut/src/lib.rs @@ -48,7 +48,7 @@ pub mod proofs; pub mod scheme; #[cfg(test)] mod tests; -mod traits; +pub mod traits; mod utils; pub type Attribute = Scalar; diff --git a/common/nymcoconut/src/proofs/mod.rs b/common/nymcoconut/src/proofs/mod.rs index c758835628..1c9a0a8081 100644 --- a/common/nymcoconut/src/proofs/mod.rs +++ b/common/nymcoconut/src/proofs/mod.rs @@ -29,7 +29,7 @@ use crate::error::{CoconutError, Result}; use crate::scheme::setup::Parameters; use crate::scheme::VerificationKey; use crate::utils::{hash_g1, try_deserialize_scalar, try_deserialize_scalar_vec}; -use crate::{elgamal, Attribute, Bytable, ElGamalKeyPair}; +use crate::{elgamal, Attribute, ElGamalKeyPair}; // as per the reference python implementation type ChallengeDigest = Sha256; diff --git a/common/nymcoconut/src/scheme/verification.rs b/common/nymcoconut/src/scheme/verification.rs index 16961763e5..cfe3d3a5a2 100644 --- a/common/nymcoconut/src/scheme/verification.rs +++ b/common/nymcoconut/src/scheme/verification.rs @@ -73,6 +73,14 @@ impl ThetaCovid { bytes } + pub fn to_bytes_tuple(&self) -> ([u8; 96], [u8; 96], Vec) { + let blinded_message_bytes = self.blinded_message.to_affine().to_compressed(); + let credential_bytes = self.credential.to_bytes(); + let proof_bytes = self.pi_v.to_bytes(); + + (blinded_message_bytes, credential_bytes, proof_bytes) + } + pub fn from_bytes(bytes: &[u8]) -> Result { if bytes.len() < 192 { return Err(