crypto: `impl Signer` based on `Keypair`
Since all signers implement `signature::Keypair`, we can simplify the implementations of `signature::Signer<ExtendedSignature>`. A blanket implementation is not possible, because we do not control `signature::Signer`.
This commit is contained in:
parent
f2ad54542e
commit
06fae85e67
|
|
@ -27,7 +27,7 @@ git-ref-format-core = { workspace = true, optional = true }
|
||||||
radicle-ssh = { workspace = true, optional = true }
|
radicle-ssh = { workspace = true, optional = true }
|
||||||
schemars = { workspace = true, optional = true, features = ["derive", "std"] }
|
schemars = { workspace = true, optional = true, features = ["derive", "std"] }
|
||||||
serde = { workspace = true, features = ["derive", "std"] }
|
serde = { workspace = true, features = ["derive", "std"] }
|
||||||
signature = { workspace = true }
|
signature = { workspace = true, features = ["std"] }
|
||||||
sqlite = { workspace = true, features = ["bundled"], optional = true }
|
sqlite = { workspace = true, features = ["bundled"], optional = true }
|
||||||
ssh-key = { version = "0.6.3", default-features = false, features = ["std", "encryption", "getrandom"], optional = true }
|
ssh-key = { version = "0.6.3", default-features = false, features = ["std", "encryption", "getrandom"], optional = true }
|
||||||
thiserror = { workspace = true, default-features = true }
|
thiserror = { workspace = true, default-features = true }
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,10 @@ impl signature::Signer<Signature> for AgentSigner {
|
||||||
|
|
||||||
impl signature::Signer<ExtendedSignature> for AgentSigner {
|
impl signature::Signer<ExtendedSignature> for AgentSigner {
|
||||||
fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
|
fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
|
||||||
|
use signature::Keypair as _;
|
||||||
Ok(ExtendedSignature {
|
Ok(ExtendedSignature {
|
||||||
key: self.public,
|
key: self.verifying_key(),
|
||||||
sig: Signer::try_sign(self, msg).map_err(signature::Error::from_source)?,
|
sig: self.try_sign(msg)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -258,9 +258,10 @@ impl signature::Signer<Signature> for MemorySigner {
|
||||||
|
|
||||||
impl signature::Signer<ExtendedSignature> for MemorySigner {
|
impl signature::Signer<ExtendedSignature> for MemorySigner {
|
||||||
fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
|
fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
|
||||||
|
use signature::Keypair as _;
|
||||||
Ok(ExtendedSignature {
|
Ok(ExtendedSignature {
|
||||||
key: self.public,
|
key: self.verifying_key(),
|
||||||
sig: Signer::sign(self, msg),
|
sig: self.try_sign(msg)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,10 @@ pub struct MockSigner {
|
||||||
|
|
||||||
impl signature::Signer<ExtendedSignature> for MockSigner {
|
impl signature::Signer<ExtendedSignature> for MockSigner {
|
||||||
fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
|
fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
|
||||||
|
use signature::Keypair as _;
|
||||||
Ok(ExtendedSignature {
|
Ok(ExtendedSignature {
|
||||||
key: self.pk,
|
key: self.verifying_key(),
|
||||||
sig: signature::Signer::<Signature>::try_sign(self, msg)?,
|
sig: self.try_sign(msg)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue