node: Implement signature verification

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-09-13 10:16:05 +02:00
parent 993d88101c
commit 35b0af9a68
4 changed files with 43 additions and 5 deletions
+13 -4
View File
@@ -1,8 +1,11 @@
use ed25519_consensus as ed25519;
use crate::crypto::{PublicKey, SecretKey, Signer};
#[derive(Debug)]
pub struct MockSigner {
key: PublicKey,
pk: PublicKey,
sk: SecretKey,
}
impl MockSigner {
@@ -15,7 +18,8 @@ impl MockSigner {
let sk = SecretKey::from(bytes);
Self {
key: sk.verification_key().into(),
pk: sk.verification_key().into(),
sk,
}
}
}
@@ -26,13 +30,18 @@ impl Default for MockSigner {
let sk = SecretKey::from(bytes);
Self {
key: sk.verification_key().into(),
pk: sk.verification_key().into(),
sk,
}
}
}
impl Signer for MockSigner {
fn public_key(&self) -> &PublicKey {
&self.key
&self.pk
}
fn sign(&self, msg: &[u8]) -> ed25519::Signature {
self.sk.sign(msg)
}
}