Skip to content

Commit c8facc2

Browse files
Generalize implementation for HintSerialize and HintDeserialize (#184)
* Generalize implementation for HintSerialize and HintDeserialize The trait is implemented for generic type instead of default type * Fix missing trait imports * Fix * Clippy --------- Co-authored-by: Giacomo Fenzi <giacomofenzi@outlook.com>
1 parent 9d7a97b commit c8facc2

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/crypto/merkle_tree/parameters.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use ark_crypto_primitives::{
77
};
88
use ark_ff::Field;
99
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
10-
use rand::RngCore;
10+
use rand::{CryptoRng, RngCore};
1111
use serde::{Deserialize, Serialize};
1212
use spongefish::{
13-
ByteDomainSeparator, BytesToUnitDeserialize, BytesToUnitSerialize, DomainSeparator, ProofError,
14-
ProofResult, ProverState, VerifierState,
13+
ByteDomainSeparator, BytesToUnitDeserialize, BytesToUnitSerialize, DomainSeparator,
14+
DuplexSpongeInterface, ProofError, ProofResult, ProverState, Unit, VerifierState,
1515
};
1616

1717
use super::{digest::GenericDigest, IdentityDigestConverter};
@@ -84,7 +84,12 @@ where
8484
}
8585
}
8686

87-
impl HintSerialize for ProverState {
87+
impl<H, U, R> HintSerialize for ProverState<H, U, R>
88+
where
89+
U: Unit,
90+
H: DuplexSpongeInterface<U>,
91+
R: RngCore + CryptoRng,
92+
{
8893
fn hint<T: CanonicalSerialize>(&mut self, hint: &T) -> ProofResult<()> {
8994
let mut bytes = Vec::new();
9095
hint.serialize_compressed(&mut bytes)?;
@@ -107,7 +112,11 @@ where
107112
}
108113
}
109114

110-
impl HintDeserialize for VerifierState<'_> {
115+
impl<H, U> HintDeserialize for VerifierState<'_, H, U>
116+
where
117+
U: Unit,
118+
H: DuplexSpongeInterface<U>,
119+
{
111120
fn hint<T: CanonicalDeserialize>(&mut self) -> ProofResult<T> {
112121
let mut bytes = self.hint_bytes()?;
113122
Ok(T::deserialize_compressed(&mut bytes)?)

src/ntt/cooley_tukey.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<F: Field> NttEngine<F> {
178178
}
179179

180180
/// Returns a cached table of roots of unity of the given order.
181-
fn roots_table(&self, order: usize) -> RwLockReadGuard<Vec<F>> {
181+
fn roots_table(&self, order: usize) -> RwLockReadGuard<'_, Vec<F>> {
182182
// Precompute more roots of unity if requested.
183183
let roots = self.roots.read().unwrap();
184184
if roots.is_empty() || roots.len() % order != 0 {

0 commit comments

Comments
 (0)