Improve Hash impl for Ciphertext.

This formulation makes it harder to forget updating the `Hash`
implementation if the `Ciphertext` type changes.
This commit is contained in:
Andreas Fackler 2018-06-19 12:27:59 +02:00 committed by Vladimir Komendantskiy
parent db1de60237
commit 34d642f709
1 changed files with 4 additions and 3 deletions

7
mod.rs
View File

@ -175,9 +175,10 @@ impl<E: Engine> PartialEq for Ciphertext<E> {
impl<E: Engine> Hash for Ciphertext<E> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.into_affine().into_compressed().as_ref().hash(state);
self.1.hash(state);
self.2.into_affine().into_compressed().as_ref().hash(state);
let Ciphertext(ref u, ref v, ref w) = *self;
u.into_affine().into_compressed().as_ref().hash(state);
v.hash(state);
w.into_affine().into_compressed().as_ref().hash(state);
}
}