Hash in field modulus, curve parameters
This commit is contained in:
parent
52c028b4da
commit
f35e190455
47
src/plonk.rs
47
src/plonk.rs
|
@ -85,6 +85,53 @@ impl<C: CurveAffine> VerifyingKey<C> {
|
||||||
.personal(C::BLAKE2B_PERSONALIZATION)
|
.personal(C::BLAKE2B_PERSONALIZATION)
|
||||||
.to_state();
|
.to_state();
|
||||||
|
|
||||||
|
// Hash in curve parameters
|
||||||
|
hasher.update(&C::Scalar::ROOT_OF_UNITY.to_bytes());
|
||||||
|
hasher.update(&C::Scalar::ROOT_OF_UNITY_INV.to_bytes());
|
||||||
|
hasher.update(
|
||||||
|
&(C::Scalar::T_MINUS1_OVER2
|
||||||
|
.iter()
|
||||||
|
.fold(Vec::new(), |mut res, word| {
|
||||||
|
res.extend_from_slice(&word.to_le_bytes());
|
||||||
|
res
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
hasher.update(&C::Scalar::DELTA.to_bytes());
|
||||||
|
hasher.update(&C::Scalar::TWO_INV.to_bytes());
|
||||||
|
hasher.update(&C::Scalar::RESCUE_ALPHA.to_le_bytes());
|
||||||
|
hasher.update(
|
||||||
|
&(C::Scalar::RESCUE_INVALPHA
|
||||||
|
.iter()
|
||||||
|
.fold(Vec::new(), |mut res, word| {
|
||||||
|
res.extend_from_slice(&word.to_le_bytes());
|
||||||
|
res
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
hasher.update(&C::Base::ZETA.to_bytes());
|
||||||
|
|
||||||
|
hasher.update(&C::Base::ROOT_OF_UNITY.to_bytes());
|
||||||
|
hasher.update(&C::Base::ROOT_OF_UNITY_INV.to_bytes());
|
||||||
|
hasher.update(
|
||||||
|
&(C::Base::T_MINUS1_OVER2
|
||||||
|
.iter()
|
||||||
|
.fold(Vec::new(), |mut res, word| {
|
||||||
|
res.extend_from_slice(&word.to_le_bytes());
|
||||||
|
res
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
hasher.update(&C::Base::DELTA.to_bytes());
|
||||||
|
hasher.update(&C::Base::TWO_INV.to_bytes());
|
||||||
|
hasher.update(&C::Base::RESCUE_ALPHA.to_le_bytes());
|
||||||
|
hasher.update(
|
||||||
|
&(C::Base::RESCUE_INVALPHA
|
||||||
|
.iter()
|
||||||
|
.fold(Vec::new(), |mut res, word| {
|
||||||
|
res.extend_from_slice(&word.to_le_bytes());
|
||||||
|
res
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
hasher.update(&C::Base::ZETA.to_bytes());
|
||||||
|
|
||||||
// Hash in constants in the domain which influence the proof
|
// Hash in constants in the domain which influence the proof
|
||||||
self.domain.hash_into(&mut hasher);
|
self.domain.hash_into(&mut hasher);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ impl<C: ColumnType> Column<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn hash_into(&self, hasher: &mut Blake2bState) {
|
pub(crate) fn hash_into(&self, hasher: &mut Blake2bState) {
|
||||||
|
hasher.update(&format!("{:?}", self).as_bytes().len().to_le_bytes());
|
||||||
hasher.update(&format!("{:?}", self).as_bytes());
|
hasher.update(&format!("{:?}", self).as_bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,6 +326,7 @@ impl<F: Field> Expression<F> {
|
||||||
|
|
||||||
/// Hash an Expression into a Blake2bState
|
/// Hash an Expression into a Blake2bState
|
||||||
pub fn hash_into(&self, hasher: &mut Blake2bState) {
|
pub fn hash_into(&self, hasher: &mut Blake2bState) {
|
||||||
|
hasher.update(&format!("{:?}", self).as_bytes().len().to_le_bytes());
|
||||||
hasher.update(&format!("{:?}", self).as_bytes());
|
hasher.update(&format!("{:?}", self).as_bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,6 +381,11 @@ impl<G: Group> EvaluationDomain<G> {
|
||||||
|
|
||||||
/// Hashes the constants in the domain which influence the proof into a Blake2bState
|
/// Hashes the constants in the domain which influence the proof into a Blake2bState
|
||||||
pub fn hash_into(&self, hasher: &mut Blake2bState) {
|
pub fn hash_into(&self, hasher: &mut Blake2bState) {
|
||||||
|
// Hash in field modulus
|
||||||
|
let modulus = G::Scalar::char_le_bits();
|
||||||
|
hasher.update(&modulus.len().to_le_bytes());
|
||||||
|
hasher.update(format!("{:?}", modulus).as_bytes());
|
||||||
|
|
||||||
hasher.update(b"k");
|
hasher.update(b"k");
|
||||||
hasher.update(&self.k.to_le_bytes());
|
hasher.update(&self.k.to_le_bytes());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue