• Stars
    star
    337
  • Rank 125,272 (Top 3 %)
  • Language
    C
  • License
    Creative Commons ...
  • Created over 10 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rust language bindings for Bitcoin secp256k1 library.

Rust Secp256k1

Crate Info CC0 1.0 Universal Licensed CI Status API Docs Rustc Version 1.48.0+

rust-secp256k1 is a wrapper around libsecp256k1, a C library implementing various cryptographic functions using the SECG curve secp256k1.

This library:

  • exposes type-safe Rust bindings for all libsecp256k1 functions
  • implements key generation
  • implements deterministic nonce generation via RFC6979
  • implements many unit tests, adding to those already present in libsecp256k1
  • makes no allocations (except in unit tests) for efficiency and use in freestanding implementations

Contributing

Contributions to this library are welcome. A few guidelines:

  • Any breaking changes must have an accompanied entry in CHANGELOG.md
  • No new dependencies, please.
  • No crypto should be implemented in Rust, with the possible exception of hash functions. Cryptographic contributions should be directed upstream to libsecp256k1.
  • This library should always compile with any combination of features on Rust 1.48.0.

Githooks

To assist devs in catching errors before running CI we provide some githooks. If you do not already have locally configured githooks you can use the ones in this repository by running, in the root directory of the repository:

git config --local core.hooksPath githooks/

Alternatively add symlinks in your .git/hooks directory to any of the githooks we provide.

Benchmarks

We use a custom Rust compiler configuration conditional to guard the bench mark code. To run the bench marks use: RUSTFLAGS='--cfg=bench' cargo +nightly bench --features=recovery.

A note on non_secure_erase

This crate's secret types (SecretKey, KeyPair, SharedSecret, Scalar, and DisplaySecret) have a method called non_secure_erase that attempts to overwrite the contained secret. This method is provided to assist other libraries in building secure secret erasure. However, this library makes no guarantees about the security of using non_secure_erase. In particular, the compiler doesn't have any concept of secrets and in most cases can arbitrarily move or copy values anywhere it pleases. For more information, consult the zeroize documentation.

Fuzzing

If you want to fuzz this library, or any library which depends on it, you will probably want to disable the actual cryptography, since fuzzers are unable to forge signatures and therefore won't test many interesting codepaths. To instead use a trivially-broken but fuzzer-accessible signature scheme, compile with --cfg=secp256k1_fuzz in your RUSTFLAGS variable.

Note that cargo hfuzz does not set this config flag automatically. In 0.27.0 and earlier versions, we used the --cfg=fuzzing which honggfuzz does set, but we changed this because there was no way to override it.

More Repositories

1

rust-bitcoin

Rust Bitcoin library
Rust
2,063
star
2

rust-miniscript

Support for Miniscript and Output Descriptors for rust-bitcoin
Rust
342
star
3

rust-bitcoincore-rpc

Rust RPC client library for the Bitcoin Core JSON-RPC API.
Rust
293
star
4

rust-wallet

*archived* Library for a Bitcoin Wallet
Rust
180
star
5

murmel

Bitcoin SPV client in Rust.
Rust
102
star
6

rust-bech32

Bech32 format encoding and decoding
Rust
94
star
7

rust-bip39

A Rust library for working with Bitcoin BIP-39 mnemonics
Rust
88
star
8

bitcoin_hashes

Simple library which implements a few hashes and does nothing else
Rust
66
star
9

hammersbald

Hammersbald is a fast embedded blockchain database
Rust
52
star
10

rust-bitcoinconsensus

Bitcoin's libbitcoinconsenus.a with Rust binding. Built from Bitcoin sources with cargo.
C++
46
star
11

bitcoind

Utility to launch a regtest bitcoind process in a rust test
Rust
34
star
12

rust-bip47

BIP47 implementation in Rust
Rust
26
star
13

rust-lightning-invoice

lightning BOLT 11 invoice implementation
Rust
20
star
14

rust-bech32-bitcoin

Encoding and decoding Segregated Witness addresses in Bech32 format
Rust
16
star
15

bip324

encrypted messages over the Bitcoin P2P Protocol
Rust
15
star
16

bip322

Implements BIP322 generic message signing and verification
Rust
14
star
17

constants

Constants used across Bitcoin libraries
Rust
8
star
18

hex-conservative

Hex crate with a conservative MSRV and dependency policy
Rust
7
star
19

rust-bitcoin-chain

In-Memory Bitcoin blockchain
Rust
5
star
20

www.rust-bitcoin.org

Web site source code
Shell
5
star
21

rust-bitcoin.github.io

SCSS
5
star
22

rust-bitcoind-json-rpc

Support for Bitcoin Core's JSON-RPC API
Rust
5
star
23

rust-bitcoin-maintainer-tools

Scripts, test vectors, and other things used by or across multiple repositories in the rust-bitcoin ecosystem.
Rust
5
star
24

workshop

Conference workshop material
HTML
2
star
25

rust-psbt-v0

Partially Signed Bitcoin Transaction Format - BIP-174
Rust
1
star