Skip to content

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

Open
@matthiasgeihs

Description

@matthiasgeihs

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"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions