Skip to content

Commit a79e0c3

Browse files
authored
Merge pull request #438 from EspressoSystems/ax/vess-nit
Avoid spongefish not fully consumed errors
2 parents aea1ac3 + 0775ab9 commit a79e0c3

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

timeboost-crypto/src/vess.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -498,20 +498,13 @@ impl<C: CurveGroup> ShoupVess<C> {
498498
.io_pattern(&vss_pp, aad, &mode)
499499
.to_verifier_state(&ct.transcript);
500500

501-
// verifier logic until Step 4b
502-
let (expected_comm, h, subset_seed, mut shifted_polys, mut mre_cts) =
501+
// verifier logic
502+
let (expected_comm, h, subset_seed, mut shifted_polys, mut mre_cts, mut seeds) =
503503
self.verify_core(&vss_pp, &mut verifier_state, &mode)?;
504504
if &expected_comm != comm {
505505
return Err(VessError::WrongCommitment);
506506
}
507507

508-
// parse out prover's response for k notin S
509-
let mut seeds = VecDeque::new();
510-
for _ in self.subset_size..self.num_repetition {
511-
let seed: [u8; 32] = verifier_state.next_bytes()?;
512-
seeds.push_back(seed);
513-
}
514-
515508
// recompute the hash of all the dealings,
516509
let mut hasher = sha2::Sha256::new();
517510
hasher.update(aad);
@@ -570,13 +563,13 @@ impl<C: CurveGroup> ShoupVess<C> {
570563
}
571564
}
572565

573-
// Verifier's core logic until step 4.b (exclusive), shared between `verify()` and `decrypt()`.
566+
// Verifier's core logic, shared between `verify()` and `decrypt()`.
574567
fn verify_core(
575568
&self,
576569
vss_pp: &FeldmanVssPublicParam,
577570
verifier_state: &mut VerifierState,
578571
mode: &Mode<C>,
579-
) -> Result<ProverMessageUntilStep4b<C>, VessError> {
572+
) -> Result<ProverMessage<C>, VessError> {
580573
let t = vss_pp.t.get();
581574
let n = vss_pp.n.get();
582575

@@ -624,7 +617,15 @@ impl<C: CurveGroup> ShoupVess<C> {
624617
}
625618
mre_cts.push_back(MultiRecvCiphertext { epk, cts });
626619
}
627-
Ok((comm.into(), h, subset_seed, shifted_polys, mre_cts))
620+
621+
// parse out prover's response for k notin S (now internalized)
622+
let mut seeds = VecDeque::new();
623+
for _ in self.subset_size..self.num_repetition {
624+
let seed: [u8; 32] = verifier_state.next_bytes()?;
625+
seeds.push_back(seed);
626+
}
627+
628+
Ok((comm.into(), h, subset_seed, shifted_polys, mre_cts, seeds))
628629
}
629630

630631
// core logic to decrypt
@@ -643,8 +644,8 @@ impl<C: CurveGroup> ShoupVess<C> {
643644
.io_pattern(&vss_pp, aad, &mode)
644645
.to_verifier_state(&ct.transcript);
645646

646-
// verifier logic until Step 4b
647-
let (comm, _h, subset_seed, shifted_polys, mre_cts) =
647+
// verifier logic
648+
let (comm, _h, subset_seed, shifted_polys, mre_cts, _seeds) =
648649
self.verify_core(&vss_pp, &mut verifier_state, &mode)?;
649650
let subset_indices = self.map_subset_seed(subset_seed);
650651
debug_assert_eq!(subset_indices.len(), shifted_polys.len());
@@ -675,17 +676,19 @@ impl<C: CurveGroup> ShoupVess<C> {
675676
}
676677
}
677678

678-
/// (C, h, s, { rho_k.shifted_poly }_{k in S}, { rho_k.mre_ciphertext }_{k in S})
679+
/// (C, h, s, { rho_k.shifted_poly }_{k in S}, { rho_k.mre_ciphertext }_{k in S}, seeds)
679680
/// where C is Feldman commitment, h is output of H_compress of all dealings,
680681
/// s is subset seed, S is the corresponding subset
681682
/// shifted_poly is omega''_k in paper
683+
/// seeds are the random seeds for k not in S
682684
#[allow(type_alias_bounds)]
683-
type ProverMessageUntilStep4b<C: CurveGroup> = (
685+
type ProverMessage<C: CurveGroup> = (
684686
FeldmanCommitment<C>,
685687
[u8; 32],
686688
[u8; 16],
687689
VecDeque<Vec<C::ScalarField>>,
688690
VecDeque<MultiRecvCiphertext<C>>,
691+
VecDeque<[u8; 32]>,
689692
);
690693

691694
// returns x * a / b without overflow panic, assuming the result < u128::MAX

0 commit comments

Comments
 (0)