b38ae97eaf
Currently we rely on the inner bytes with types that are passed across the FFI boundry when implementing comparison functions (e.g. `Ord`, `PartialEq`), this is incorrect because the bytes are opaque, meaning the byte layout is not guaranteed across versions of `libsecp26k1`. Implement stable comparison functionality by doing: - Implement `core::cmp` traits by first coercing the data into a stable form e.g., by serializing it. - Add fast comparison methods to `secp256k1-sys` types that wrap types from libsecp, add similar methods to types in `secp256k1` that wrap `secp256k1-sys` types (just call through to inner type). - In `secp256k1-sys` feature gate the new `core::cmp` impls on `not(fuzzing)`, when fuzzing just derive the impls instead. Any additional methods added to `secp256k1-sys` types are private, justified by the fact the -sys is meant to be just a thin wrapper around libsecp256k1, we don't want to commit to supporting additional API functions. Please note, the solution presented in this patch is already present for `secp256k1::PublicKey`, this PR removes that code in favour of deriving traits that then call down to the same logic in `secp256k1-sys`. |
||
---|---|---|
.. | ||
depend | ||
src | ||
wasm | ||
CHANGELOG.md | ||
Cargo.toml | ||
LICENSE | ||
README.md | ||
build.rs | ||
vendor-libsecp.sh |
README.md
secp256k1-sys
This crate provides Rust definitions for the FFI structures and methods.
Vendoring
The default build process is to build using the vendored libsecp256k1 sources in
the depend folder. These sources are prefixed with a special
rust-secp256k1-sys-specific prefix rustsecp256k1_v1_2_3_
.
This prefix ensures that no symbol collision can happen:
- when a Rust project has two different versions of rust-secp256k1 in its depepdency tree, or
- when rust-secp256k1 is used for building a static library in a context where existing libsecp256k1 symbols are already linked.
To update the vendored sources, use the vendor-libsecp.sh
script:
$ ./vendor-libsecp.sh depend <version-code> <rev>
- Where
<version-code>
is the secp256k1-sys version number underscored:0_1_2
. - Where
<rev>
is the git revision of libsecp256k1 to checkout.
Linking to external symbols
If you want to compile this library without using the bundled symbols (which may
be required for integration into other build systems), you can do so by adding
--cfg=rust_secp_no_symbol_renaming'
to your RUSTFLAGS
variable.