Skip to content

Add Ecdsa adaptor and schnorr signature from temp-everything branch #1

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

Draft
wants to merge 73 commits into
base: add-bip340-schnorr
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
bc81930
global-context depends on rand-std
vorot93 Nov 6, 2020
1859ddc
switch from travis to github workflows
apoelstra Nov 10, 2020
221254b
Merge pull request #246 from vorot93/patch-2
apoelstra Nov 11, 2020
ac4541a
Merge pull request #250 from rust-bitcoin/2020-11--github-actions
apoelstra Nov 23, 2020
6b41326
Fix link in README
justinmoon Nov 25, 2020
d448cd8
Merge pull request #252 from justinmoon/readme
apoelstra Nov 25, 2020
6f8a480
Implement lexigraphic ordering for PubKey
justinmoon Nov 9, 2020
9083bab
Merge pull request #248 from justinmoon/pubkey-ordering
apoelstra Nov 26, 2020
be9a78f
Merge pull request #237 from p2pderivatives/add-bip340-schnorr
apoelstra Nov 27, 2020
12b0abb
make `ffi::Type::new` functions all unsafe, expand documentation
apoelstra Nov 27, 2020
37049d7
schnorrsig: expose tweak_check_add API
apoelstra Nov 27, 2020
0ec8fab
stop explicitly casting references to rawptrs
apoelstra Nov 30, 2020
ea027ce
schnorrsig: change tweak_add_check to return a bool, take a fixed-len…
apoelstra Dec 9, 2020
11e9641
Merge pull request #253 from apoelstra/2020-11--schnorrsig-followup
apoelstra Dec 9, 2020
7b99784
Add AligneType and redo secp256k1_context_create with alloc
elichai Aug 28, 2020
fd206ab
Replace use of boxes with global allocator
elichai Aug 28, 2020
767246a
Make preallocated use AlignedType
elichai Aug 28, 2020
0638107
Adopt no-std tests to new preacllocated_* functions
elichai Aug 28, 2020
3151352
Merge pull request #233 from elichai/alloc-AlignedType2
apoelstra Dec 21, 2020
8b8e482
Run more tests in wasm
thomaseizinger Dec 21, 2020
f67081a
Allow unnecessary parentheses
tcharding Dec 22, 2020
617bff9
Conditionally include ALIGN_TO
tcharding Dec 22, 2020
3afc172
Conditionally compile fn strlen
tcharding Dec 22, 2020
02dec3e
Implement AsRef instead of custom method
tcharding Dec 22, 2020
1a818ea
Merge pull request #260 from tcharding/clippy
apoelstra Dec 22, 2020
4e87e6f
Implement is_empty method
tcharding Dec 22, 2020
ed29f12
Remove unnecessary return statements
tcharding Dec 22, 2020
34ad411
Remove unused error return value
tcharding Dec 22, 2020
ef23cb8
Return Ok directly
tcharding Dec 22, 2020
c92b946
Remove unnecessary clone
tcharding Dec 22, 2020
c38136b
Use for loop instead of map
tcharding Dec 22, 2020
a584643
Use ManuallyDrop
tcharding Dec 22, 2020
2917de5
Merge pull request #261 from tcharding/more-clippy
apoelstra Dec 22, 2020
1d166d0
Implement low r signing
Tibo-lg Dec 21, 2020
b31bf2f
Merge pull request #258 from thomaseizinger/better-wasm-tests
apoelstra Dec 22, 2020
d77483f
replace cargo `external-symbols` feature with a rustc --cfg flag
apoelstra Dec 22, 2020
85075a6
replace `fuzztarget` Cargo feature with a rustc --cfg flag
apoelstra Dec 22, 2020
29316ef
add warning about fuzzing being enabled
apoelstra Dec 22, 2020
67c9be3
Merge pull request #263 from apoelstra/2020-12--no-extsymb
apoelstra Dec 22, 2020
a2c25f2
Merge pull request #259 from p2pderivatives/implement-low-r-signing
apoelstra Dec 22, 2020
21f231b
Make test.sh test and build secp256k1-sys
elichai Dec 18, 2020
91eea11
Merge pull request #256 from rust-bitcoin/workspace
apoelstra Dec 23, 2020
40c3134
ffi: make function types nullable
apoelstra Dec 22, 2020
b811ec1
fuzz: only replace signing and verification, leave everything else alone
apoelstra Dec 22, 2020
51bc0b1
Fix link_name for secp256k1_ec_seckey_negate
junderw Dec 28, 2020
96862b6
fuzz: implement recoverable signatures, get all tests passing, run th…
apoelstra Dec 23, 2020
d1714ce
fuzz: disable sig-grinding tests, prevent spin-looping
apoelstra Dec 28, 2020
75d7177
fuzz: fix elichai's nits
apoelstra Dec 28, 2020
867b920
Merge pull request #264 from rust-bitcoin/2020-12--no-extsymb2
apoelstra Dec 28, 2020
a9049f8
Merge pull request #266 from junderw/patch-1
apoelstra Dec 29, 2020
e5d9e08
secp-sys: update scratch_impl.patch for upstream changes
apoelstra Dec 21, 2020
a93d671
update libsecp to 98dac87839838b86094f1bccc71cc20e67b146cc
apoelstra Dec 29, 2020
e687622
bump secp-sys version; drop endomorphism flag
apoelstra Dec 21, 2020
58f946f
secp-sys: remove now-unneeded endianness check from build.rs
apoelstra Dec 29, 2020
d12be79
drop unnecessary no_mangle annotations on non-exported functions
apoelstra Dec 29, 2020
c4d2fef
rust-secp 0.20.0
apoelstra Dec 21, 2020
1f04321
Add ability to randomize context without the `rand` feature.
TheBlueMatt Dec 29, 2020
c534b54
Merge pull request #267 from TheBlueMatt/master
apoelstra Dec 29, 2020
5f1622f
Merge pull request #257 from apoelstra/2020-12--no-endo
apoelstra Jan 3, 2021
65ff814
rename `rust_secp_fuzz` to `fuzzing`
apoelstra Jan 11, 2021
ca3caf9
bump version to 0.20.1
apoelstra Jan 11, 2021
a24e27e
Merge pull request #269 from apoelstra/2021-01--rename-fuzz-feature
apoelstra Jan 15, 2021
c86808f
use core instead of std for wasm sanity checks
gregdhill Jan 20, 2021
8e61874
Merge pull request #275 from gregdhill/master
apoelstra Jan 25, 2021
519857c
More standard derives for Error
dr-orlovsky Jan 30, 2021
3bff596
Merge pull request #277 from LNP-BP/fix/error-derive
apoelstra Feb 10, 2021
0a91f2b
Use CARGO_CFG_TARGET_ARCH instead TARGET in build.rs
fanatid Mar 8, 2021
4ae0e7e
Merge pull request #284 from fanatid/patch-1
apoelstra Mar 12, 2021
297f255
Update dependency folder to use ecdsa adaptor
Tibo-lg Oct 22, 2020
f92169b
Update secp256k1-sys to add adaptor module
Tibo-lg Aug 19, 2020
bda891c
Update rust-secp256k1 to add ecdsa-adaptor
Tibo-lg Aug 19, 2020
7b7a967
Add ecdsa adaptor example
Tibo-lg Oct 23, 2020
c16f8b7
Add combine_keys function to PublicKey
Tibo-lg Mar 31, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
on: [push, pull_request]

name: Continuous integration

jobs:
bench_nightly:
name: Nightly - ASan + Bench
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rust-src
- name: Running address sanitizer
env:
DO_ASAN: true
run: ./contrib/test.sh
- name: Running benchmarks
env:
DO_BENCH: true
run: ./contrib/test.sh

wasm:
name: Stable - Docs / WebAssembly Build
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Building docs
env:
DO_DOCS: true
run: ./contrib/test.sh
- name: Running WASM build
env:
DO_WASM: true
run: ./contrib/test.sh

Tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.29.0
- beta
- stable
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Pin cc if rust 1.29
if: matrix.rust == '1.29.0'
run: cargo generate-lockfile --verbose && cargo update -p cc --precise "1.0.41" --verbose
- name: Running cargo
env:
DO_FEATURE_MATRIX: true
run: ./contrib/test.sh

78 changes: 0 additions & 78 deletions .travis.yml

This file was deleted.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@

# 0.20.0 - 2020-12-21

* [remove `ffi::PublicKey::blank`](https://github.com/rust-bitcoin/rust-secp256k1/pull/232) and replace with unsafe [`ffi::PublicKey::new` and `ffi::PublicKey::from_array_unchecked`](https://github.com/rust-bitcoin/rust-secp256k1/pull/253/); similar for all other FFI types
* [support wasm32-wasi target](https://github.com/rust-bitcoin/rust-secp256k1/pull/242)
* [make the global-context feature depend on the rand-std feature](https://github.com/rust-bitcoin/rust-secp256k1/pull/246)
* [add a lexicographic ordering to `PublicKey`](https://github.com/rust-bitcoin/rust-secp256k1/pull/248) which does **not** match the ordering used by Bitcoin Core (matching this would be impossible as it requires tracking a compressedness flag, which libsecp256k1 does not have)
* [implement BIP340 Schnorr signatures](https://github.com/rust-bitcoin/rust-secp256k1/pull/237)
* [require use of new `AlignedType` in preallocated-context API to enforce alignment requirements](https://github.com/rust-bitcoin/rust-secp256k1/pull/233); previously it was possible to get UB by using misaligned memory stores
* [enforce correct alignment when using preallocated context API](https://github.com/rust-bitcoin/rust-secp256k1/pull/233)
* [stop using cargo features for dangerous build-breaking options, require setting `RUSTFLAGS` instead](https://github.com/rust-bitcoin/rust-secp256k1/pull/263)
* [implement low-R signing and function to grind even smaller signatures](https://github.com/rust-bitcoin/rust-secp256k1/pull/259)
* [remove endomorphism feature, following upstream in enabling it by default](https://github.com/rust-bitcoin/rust-secp256k1/pull/257)

# 0.19.0 - 2020-08-27

* **Update MSRV to 1.29.0**
Expand Down
24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "secp256k1"
version = "0.19.0"
version = "0.20.1-adaptor.0"
authors = [ "Dawid Ciężarkiewicz <[email protected]>",
"Andrew Poelstra <[email protected]>" ]
license = "CC0-1.0"
Expand All @@ -14,27 +14,19 @@ autoexamples = false # Remove when edition 2018 https://github.com/rust-lang/car

# Should make docs.rs show all functions, even those behind non-default features
[package.metadata.docs.rs]
features = [ "rand", "rand-std", "serde", "recovery", "endomorphism" ]
features = [ "rand", "rand-std", "serde", "recovery" ]

[features]
unstable = ["recovery", "rand-std"]
default = ["std"]
std = ["secp256k1-sys/std"]
rand-std = ["rand/std"]
recovery = ["secp256k1-sys/recovery"]
endomorphism = ["secp256k1-sys/endomorphism"]
lowmemory = ["secp256k1-sys/lowmemory"]
global-context = ["std", "rand"]

# Use this feature to not compile the bundled libsecp256k1 C symbols,
# but use external ones. Use this only if you know what you are doing!
external-symbols = ["secp256k1-sys/external-symbols"]

# Do not use this feature! HAZMAT. (meant for Fuzzing only. this is *BROKEN CRYPTOGRAPHY*)
fuzztarget = ["secp256k1-sys/fuzztarget"]
global-context = ["std", "rand-std"]

[dependencies]
secp256k1-sys = { version = "0.3.1", default-features = false, path = "./secp256k1-sys" }
secp256k1-sys = { version = "0.4.0-adaptor-0", default-features = false, path = "./secp256k1-sys" }
bitcoin_hashes = { version = "0.9", optional = true }
rand = { version = "0.6", default-features = false, optional = true }
serde = { version = "1.0", default-features = false, optional = true }
Expand All @@ -61,3 +53,11 @@ name = "sign_verify"
[[example]]
name = "generate_keys"
required-features = ["rand"]

[workspace]
members = ["secp256k1-sys"]
exclude = ["no_std_test"]

[[example]]
name = "ecdsa_adaptor"
required-features = ["rand", "bitcoin_hashes"]
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### rust-secp256k1

`rust-secp256k1` is a wrapper around ![libsecp256k1](https://github.com/bitcoin-core/secp256k1),
`rust-secp256k1` is a wrapper around [libsecp256k1](https://github.com/bitcoin-core/secp256k1),
a C library by Pieter Wuille for producing ECDSA signatures using the SECG curve
`secp256k1`. This library
* exposes type-safe Rust bindings for all `libsecp256k1` functions
Expand Down Expand Up @@ -35,3 +35,14 @@ before_script:
cargo generate-lockfile --verbose && cargo update -p cc --precise "1.0.41" --verbose;
fi
```

## 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=fuzzing` in your `RUSTFLAGS` variable.

Note that `cargo hfuzz` sets this config flag automatically.

85 changes: 85 additions & 0 deletions contrib/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/sh -ex

FEATURES="bitcoin_hashes global-context lowmemory rand rand-std recovery serde"

# Use toolchain if explicitly specified
if [ -n "$TOOLCHAIN" ]
then
alias cargo="cargo +$TOOLCHAIN"
fi

cargo --version
rustc --version

# Make all cargo invocations verbose
export CARGO_TERM_VERBOSE=true

# Defaults / sanity checks
cargo build --all
cargo test --all

if [ "$DO_FEATURE_MATRIX" = true ]; then
cargo build --all --no-default-features
#This doesn't work but probably should --andrew
#cargo test --all --no-default-features

# All features
cargo build --all --no-default-features --features="$FEATURES"
cargo test --all --features="$FEATURES"
# Single features
for feature in ${FEATURES}
do
cargo build --all --no-default-features --features="$feature"
cargo test --all --features="$feature"
done

# Other combos
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS=$RUSTFLAGS cargo test --all
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS=$RUSTFLAGS cargo test --all --features="$FEATURES"
cargo test --all --features="rand rand-std"
cargo test --all --features="rand serde"

if [ "$DO_BENCH" = true ]; then # proxy for us having a nightly compiler
cargo test --all --all-features
RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS='--cfg=fuzzing' cargo test --all --all-features
fi

# Examples
cargo run --example sign_verify
cargo run --example sign_verify_recovery --features=recovery
cargo run --example generate_keys --features=rand
fi

# Docs
if [ "$DO_DOCS" = true ]; then
cargo doc --all --features="$FEATURES"
fi

# Webassembly stuff
if [ "$DO_WASM" = true ]; then
clang --version &&
CARGO_TARGET_DIR=wasm cargo install --force wasm-pack &&
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml &&
CC=clang-9 wasm-pack build &&
CC=clang-9 wasm-pack test --node;
fi

# Address Sanitizer
if [ "$DO_ASAN" = true ]; then
cargo clean
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
cargo clean &&
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully"
fi

# Bench
if [ "$DO_BENCH" = true ]; then
cargo bench --all --features="unstable"
fi

Loading