Add signature verification to gossip (#1937)

This commit is contained in:
Sagar Dhawan
2018-12-01 12:00:30 -08:00
committed by GitHub
parent 8ef73eee51
commit 34c3a0cc1f
12 changed files with 432 additions and 99 deletions

View File

@ -30,6 +30,22 @@ impl Signature {
}
}
pub trait Signable {
fn sign(&mut self, keypair: &Keypair) {
let data = self.signable_data();
self.set_signature(Signature::new(&keypair.sign(&data).as_ref()));
}
fn verify(&self) -> bool {
self.get_signature()
.verify(&self.pubkey().as_ref(), &self.signable_data())
}
fn pubkey(&self) -> Pubkey;
fn signable_data(&self) -> Vec<u8>;
fn get_signature(&self) -> Signature;
fn set_signature(&mut self, signature: Signature);
}
impl AsRef<[u8]> for Signature {
fn as_ref(&self) -> &[u8] {
&self.0[..]