summa-tx / coins

Rust implementations of BIP32/39 and Ledger device comms
Other
92 stars 31 forks source link

chore: upgrade asymmetric crytpo dependencies #97

Closed agostbiro closed 2 years ago

agostbiro commented 2 years ago

Tries to upgrade asymmetric crypto dependencies of coins-bip32 as described in #96.

The build currently errors with:

error[E0277]: the trait bound `k256::ecdsa::SigningKey: DigestSigner<D, _>` is not satisfied
  --> bip32/src/macros.rs:18:28
   |
18 |                 self.$attr.try_sign_digest(digest)
   |                            ^^^^^^^^^^^^^^^ the trait `DigestSigner<D, _>` is not implemented for `k256::ecdsa::SigningKey`
   |
  ::: bip32/src/xkeys.rs:87:1
   |
87 | inherit_signer!(XPriv.key);
   | -------------------------- in this macro invocation
   |
   = help: the following implementations were found:
             <k256::ecdsa::SigningKey as DigestSigner<D, ecdsa::Signature<Secp256k1>>>
             <k256::ecdsa::SigningKey as DigestSigner<D, k256::ecdsa::recoverable::Signature>>
   = note: this error originates in the macro `inherit_signer` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `k256::ecdsa::SigningKey: DigestSigner<D, _>` is not satisfied
  --> bip32/src/macros.rs:38:28
   |
38 |                 self.$attr.try_sign_digest(digest)
   |                            ^^^^^^^^^^^^^^^ the trait `DigestSigner<D, _>` is not implemented for `k256::ecdsa::SigningKey`
   |
  ::: bip32/src/xkeys.rs:87:1
   |
87 | inherit_signer!(XPriv.key);
   | -------------------------- in this macro invocation
   |
   = help: the following implementations were found:
             <k256::ecdsa::SigningKey as DigestSigner<D, ecdsa::Signature<Secp256k1>>>
             <k256::ecdsa::SigningKey as DigestSigner<D, k256::ecdsa::recoverable::Signature>>
   = note: this error originates in the macro `inherit_signer` (in Nightly builds, run with -Z macro-backtrace for more info)

I've tried the following to no avail:

            fn verify_digest(
                &self,
                digest: D,
                signature: &k256::ecdsa::recoverable::Signature,
            ) -> Result<(), k256::ecdsa::Error> {
                use k256::ecdsa::signature::DigestSigner;
                self.$attr.verify_digest(digest, signature)
            }

and

            fn verify_digest(
                &self,
                digest: D,
                signature: &k256::ecdsa::recoverable::Signature,
            ) -> Result<(), k256::ecdsa::Error> {
                k256::ecdsa::signature::DigestSigner::verify_digest(&self.$attr, digest, signature)
            }
prestwich commented 2 years ago

The main issue here is that the newer version of k256 has changed the trait bounds on the impl of DigestSigner for SigningKey

https://docs.rs/k256/0.11.2/k256/ecdsa/struct.SigningKey.html#impl-DigestSigner%3CD%2C%20Signature%3CSecp256k1%3E%3E

agostbiro commented 2 years ago

Right thanks I overlooked that. I've gotten it to build now. I'll open a new PR because of conflicts + cleaner history.