paritytech / libsecp256k1

Pure Rust Implementation of secp256k1.
Apache License 2.0
172 stars 84 forks source link

fix: no-std compatibility tweak (#1) #146

Open Slesarew opened 1 year ago

Slesarew commented 1 year ago

Problem

Current sp-core crate (version 7.0.0) with feature full_crypto depends on libsecp256k1 crate with version = "0.7", default-features = false, features = ["static-context"]. full_crypto is a feature intended for no_std support and libsecp256k1 with default-features = false is supposed to work with no_std. However, libsecp256k1 with default-features = false currently does not compile at least on targets thumbv7m-none-eabi and thumbv7em-none-eabi causing sp-core in full_crypto to not compile as well.

Possible fix

[build-dependencies] contain libsecp256k1-gen-ecmult and libsecp256k1-gen-genmult, both depending on libsecp256k1-core with default features (i.e. in std mode). If the Cargo.toml files for both libsecp256k1-gen-ecmult and libsecp256k1-gen-genmult are changed to have libsecp256k1-core with default-features = false, things keep building as before in std and begin to build in no-std as well. Also, a few dependencies (serde and base64) get used only in std, but were not marked as optional = true, although this does not affect buildability.

We will maintain a thus fixed version of the crate for Kampela development and switch to this upstream if the issue gets resolved.