Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
crypto: `impl Signer` based on `Keypair`
Lorenz Leutgeb committed 1 month ago
commit 06fae85e6709056a85ea143461e457e7aa0fd233
parent f2ad545
4 files changed +10 -7
modified crates/radicle-crypto/Cargo.toml
@@ -27,7 +27,7 @@ git-ref-format-core = { workspace = true, optional = true }
radicle-ssh = { workspace = true, optional = true }
schemars = { workspace = true, optional = 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 }
ssh-key = { version = "0.6.3", default-features = false, features = ["std", "encryption", "getrandom"], optional = true }
thiserror = { workspace = true, default-features = true }
modified crates/radicle-crypto/src/ssh/agent.rs
@@ -65,9 +65,10 @@ impl signature::Signer<Signature> for AgentSigner {

impl signature::Signer<ExtendedSignature> for AgentSigner {
    fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
+
        use signature::Keypair as _;
        Ok(ExtendedSignature {
-
            key: self.public,
-
            sig: Signer::try_sign(self, msg).map_err(signature::Error::from_source)?,
+
            key: self.verifying_key(),
+
            sig: self.try_sign(msg)?,
        })
    }
}
modified crates/radicle-crypto/src/ssh/keystore.rs
@@ -258,9 +258,10 @@ impl signature::Signer<Signature> for MemorySigner {

impl signature::Signer<ExtendedSignature> for MemorySigner {
    fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
+
        use signature::Keypair as _;
        Ok(ExtendedSignature {
-
            key: self.public,
-
            sig: Signer::sign(self, msg),
+
            key: self.verifying_key(),
+
            sig: self.try_sign(msg)?,
        })
    }
}
modified crates/radicle-crypto/src/test/signer.rs
@@ -10,9 +10,10 @@ pub struct MockSigner {

impl signature::Signer<ExtendedSignature> for MockSigner {
    fn try_sign(&self, msg: &[u8]) -> Result<ExtendedSignature, signature::Error> {
+
        use signature::Keypair as _;
        Ok(ExtendedSignature {
-
            key: self.pk,
-
            sig: signature::Signer::<Signature>::try_sign(self, msg)?,
+
            key: self.verifying_key(),
+
            sig: self.try_sign(msg)?,
        })
    }
}