mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 22:10:31 +08:00
node: Implement signed refs
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
+22
-6
@@ -2,7 +2,7 @@ use ed25519_consensus as ed25519;
|
||||
|
||||
use crate::crypto::{PublicKey, SecretKey, Signer};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MockSigner {
|
||||
pk: PublicKey,
|
||||
sk: SecretKey,
|
||||
@@ -15,12 +15,14 @@ impl MockSigner {
|
||||
for byte in &mut bytes {
|
||||
*byte = rng.u8(..);
|
||||
}
|
||||
let sk = SecretKey::from(bytes);
|
||||
Self::from(SecretKey::from(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
pk: sk.verification_key().into(),
|
||||
sk,
|
||||
}
|
||||
impl From<SecretKey> for MockSigner {
|
||||
fn from(sk: SecretKey) -> Self {
|
||||
let pk = sk.verification_key().into();
|
||||
Self { sk, pk }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +38,20 @@ impl Default for MockSigner {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for MockSigner {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.pk == other.pk
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for MockSigner {}
|
||||
|
||||
impl std::hash::Hash for MockSigner {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.pk.hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl Signer for MockSigner {
|
||||
fn public_key(&self) -> &PublicKey {
|
||||
&self.pk
|
||||
|
||||
Reference in New Issue
Block a user