Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[k256] Build error: struct Secp256k1 doesn't implement AssociatedOid #1098

Open
matthiasgeihs opened this issue Nov 1, 2024 · 1 comment

Comments

@matthiasgeihs
Copy link

I work on a project using k256 = 0.13.4 with features = ["arithmetic", "hash2curve", "schnorr", "serde"] and default-features = false. The project fails to build with the following error:

% cargo build --release
   Compiling k256 v0.13.4
error[E0599]: the method `serialize` exists for struct `PublicKey<Secp256k1>`, but its trait bounds were not satisfied
   --> /Users/matthias/.cargo/registry/src/index.crates.io-6f17d22bba15001f/k256-0.13.4/src/schnorr/verifying.rs:171:20
    |
171 |         self.inner.serialize(serializer)
    |                    ^^^^^^^^^ method cannot be called on `PublicKey<Secp256k1>` due to unsatisfied trait bounds
    |
   ::: /Users/matthias/.cargo/registry/src/index.crates.io-6f17d22bba15001f/k256-0.13.4/src/lib.rs:89:1
    |
89  | pub struct Secp256k1;
    | -------------------- doesn't satisfy `Secp256k1: AssociatedOid`
    |
   ::: /Users/matthias/.cargo/registry/src/index.crates.io-6f17d22bba15001f/elliptic-curve-0.13.8/src/public_key.rs:90:1
    |
90  | pub struct PublicKey<C>
    | ----------------------- doesn't satisfy `elliptic_curve::PublicKey<Secp256k1>: Serialize`
    |
    = note: the following trait bounds were not satisfied:
            `Secp256k1: AssociatedOid`
            which is required by `elliptic_curve::PublicKey<Secp256k1>: Serialize`
note: the trait `AssociatedOid` must be implemented
   --> /Users/matthias/.cargo/registry/src/index.crates.io-6f17d22bba15001f/const-oid-0.9.6/src/lib.rs:44:1
    |
44  | pub trait AssociatedOid {
    | ^^^^^^^^^^^^^^^^^^^^^^^

The problem seems to be that feature "pkcs8" is required when "schnorr" and "serde" are enabled. This cost me a bit of time to realize. Is there a better way to setup the project so that this error does not occur? Or at least a more helpful error message would be nice. Maybe feature "serde" should require "pkcs8"?

@tarcieri
Copy link
Member

tarcieri commented Nov 1, 2024

Yeah, elsewhere we transitively activate pkcs8 when the serde feature is enabled (e.g. in the elliptic-curve and ecdsa crates). k256 should probably be updated to do the same (it wasn't really possible, or rather would be quite convoluted without weak/namespaced features, which k256 predates)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants