Skip to content

Commit db28525

Browse files
committed
Fix nonce reuse in RFC 9381 VRF proving
gen_rng used a fresh hasher instead of the transcript state, making the nonce depend only on the secret key. Two proofs with different inputs shared the same nonce, enabling full secret key recovery: x = (s1 - s2) / (c1 - c2).
1 parent b7a84f1 commit db28525

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

vrf_fun/src/rfc9381.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ impl<H: Hash32, const SUITE_STRING: u8> ProverTranscript<crate::VrfDleq<U16>>
134134
witness: &Scalar,
135135
_in_rng: Option<&mut R>,
136136
) -> Self::Rng {
137-
let mut hasher = H::default();
138-
hasher = hasher.add(b"vrf-nonce-gen");
139-
hasher = hasher.add(witness.to_bytes());
140-
let seed = hasher.finalize_fixed();
137+
let seed = self
138+
.hasher
139+
.clone()
140+
.add(b"vrf-nonce-gen")
141+
.add(witness.to_bytes())
142+
.finalize_fixed();
141143
ChaCha20Rng::from_seed(seed.into())
142144
}
143145
}

0 commit comments

Comments
 (0)