crypto: `impl signature::KeypairRef` for Signers
The various signers defined in `radicle-crypto` all allow borrowing the corresponding public key a.k.a. "verifying key". This is captured by implementing `signature::KeypairRef`, so implement it in addition to `signature::Signer`.
This commit is contained in:
parent
768ecf56ba
commit
f2ad54542e
|
|
@ -72,6 +72,16 @@ impl signature::Signer<ExtendedSignature> for AgentSigner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRef<PublicKey> for AgentSigner {
|
||||||
|
fn as_ref(&self) -> &PublicKey {
|
||||||
|
&self.public
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl signature::KeypairRef for AgentSigner {
|
||||||
|
type VerifyingKey = PublicKey;
|
||||||
|
}
|
||||||
|
|
||||||
impl AgentSigner {
|
impl AgentSigner {
|
||||||
pub fn new(agent: Agent, public: PublicKey) -> Self {
|
pub fn new(agent: Agent, public: PublicKey) -> Self {
|
||||||
let agent = RefCell::new(agent);
|
let agent = RefCell::new(agent);
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,16 @@ impl signature::Signer<ExtendedSignature> for MemorySigner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRef<PublicKey> for MemorySigner {
|
||||||
|
fn as_ref(&self) -> &PublicKey {
|
||||||
|
&self.public
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl signature::KeypairRef for MemorySigner {
|
||||||
|
type VerifyingKey = PublicKey;
|
||||||
|
}
|
||||||
|
|
||||||
impl Signer for MemorySigner {
|
impl Signer for MemorySigner {
|
||||||
fn public_key(&self) -> &PublicKey {
|
fn public_key(&self) -> &PublicKey {
|
||||||
&self.public
|
&self.public
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,16 @@ impl signature::Signer<Signature> for MockSigner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRef<PublicKey> for MockSigner {
|
||||||
|
fn as_ref(&self) -> &PublicKey {
|
||||||
|
&self.pk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl signature::KeypairRef for MockSigner {
|
||||||
|
type VerifyingKey = PublicKey;
|
||||||
|
}
|
||||||
|
|
||||||
impl MockSigner {
|
impl MockSigner {
|
||||||
pub fn new(rng: &mut fastrand::Rng) -> Self {
|
pub fn new(rng: &mut fastrand::Rng) -> Self {
|
||||||
let mut seed: [u8; 32] = [0; 32];
|
let mut seed: [u8; 32] = [0; 32];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue