Skip to content

Commit

Permalink
miniscript: add Rust miniscript and bitcoin deps
Browse files Browse the repository at this point in the history
rust-miniscript implements miniscrpit for the `wsh()` (Pay to witness
script hash) context as well as for the `tr()` context (Pay to
taproot). We use this dep as it works out of the box. The downside is
that this library uses a lot of generics and binary-size-inefficent
code. We could address much of that with PRs upstream, or in the worst
case roll our own miniscript implementation that is space-efficient in
the future.

The rust-bitcoin dep is needed explicitly as rust-miniscript requires
the `bitcoin::PublicKey` type to serialize pubkeys inside of
miniscript expressions. Maybe we can make upstream changes that allow
us to use our own types for that, as we already have all the code
needed to serialize pubkeys. rust-bitcoin is a dependency to
rust-miniscript as rust-bitcoin contains the necessary script
generation functions.

secp256k1 and secp256k1-sys are also transitive dependencies, as
`bitcoin::PublicKey` is a re-export of `secp256k1::PublicKey`. Also
here, we might be able to make upstream changes to remove the reliance
on these deps.

bech32 is updated to 0.9 as that is used by rust-bitcoin, so we don't
vendor two versions of the same lib.
  • Loading branch information
benma committed Jun 20, 2023
1 parent 0884576 commit 98bee99
Show file tree
Hide file tree
Showing 646 changed files with 228,124 additions and 601 deletions.
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ else()
# For binary reproducibility, strip path prefixes that can be different depending on environment (e.g. /home/<user>, etc.).
set(RUSTFLAGS "--remap-path-prefix=${CMAKE_CURRENT_SOURCE_DIR}/rust=src --remap-path-prefix=$ENV{HOME}=")
endif()
# Use libsecp256k1 that we link ourselves (included via external/libwally-core).
# See https://github.com/rust-bitcoin/rust-secp256k1/tree/7c8270a8506e31731e540fab7ee1abde1f48314e/secp256k1-sys#linking-to-external-symbols
set(RUSTFLAGS "${RUSTFLAGS} --cfg=rust_secp_no_symbol_renaming")

if(CMAKE_CROSSCOMPILING)
set(RUST_TARGET_ARCH thumbv7em-none-eabi)
Expand Down
140 changes: 136 additions & 4 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/rust/bitbox02-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ num-bigint = { version = "0.4.3", default-features = false, optional = true }
num-traits = { version = "0.2", default-features = false, optional = true }
bip32-ed25519 = { git = "https://github.com/digitalbitbox/rust-bip32-ed25519", tag = "v0.1.0", optional = true }
bs58 = { version = "0.4.0", default-features = false, features = ["alloc", "check"] }
bech32 = { version = "0.8.1", default-features = false, optional = true }
bech32 = { version = "0.9", default-features = false, optional = true }
blake2 = { version = "0.10.5", default-features = false, optional = true }
minicbor = { version = "0.18.0", default-features = false, features = ["alloc"], optional = true }
crc = { version = "2.1.0", optional = true }
Expand All @@ -48,6 +48,9 @@ lazy_static = { version = "1.4.0", optional = true }
async-recursion = "1.0.0"
hmac = "0.11.0"

miniscript = { version = "10.0.0", default-features = false, features = ["no-std"] }
bitcoin = { version = "0.30.0", default-features = false, features = ["no-std"] }

# For stack allocated strings
[dependencies.arrayvec]
version = "0.5.1"
Expand Down
1 change: 1 addition & 0 deletions src/rust/vendor/ahash/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"files":{"Cargo.toml":"31399b9babab52fabfe71f52ffe38fef0d3d894fdd5829f84a4e69b031f463c9","FAQ.md":"9eb41898523ee209a0a937f9bcb78afe45ad55ca0556f8a4d4063558098f6d1e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"ff8f68cb076caf8cefe7a6430d4ac086ce6af2ca8ce2c4e5a2004d4552ef52a2","README.md":"72185284f100e149998fe5301f70489e617cc4415b51cc77e967c63c6e970a67","build.rs":"123b322034273b5aa1b4934d84c277fef279afd533ecfb44831a3715e9887fcd","rustfmt.toml":"e090969e99df9360705680cc0097cfaddae10c22dc2e01470592cf3b9787fd36","src/aes_hash.rs":"04483498a0d86e3ab099e22f734ea6fcac384b92f349bd310456856bf6a9a5e2","src/convert.rs":"f0e78840046493d0679a9ec077c8164cf57cf30d5e852b11bfadfdd996d29bd1","src/fallback_hash.rs":"ec00691bd555c69f7446afe893b6631cb84207cb7b512260dec8ef488e1905f3","src/hash_map.rs":"ed0c79c41c2218ad9591a585670a2b9b983807c9725880b780138a44c126cbfd","src/hash_quality_test.rs":"6c1fea90a38dc7b2ac5b2fa6e44a565e0c3385c72df6e87231401f920912d053","src/hash_set.rs":"dc3d33e290aad62457ab1f5e64d3e33eb79e28c9468bfc8686339f0bbd8b19aa","src/lib.rs":"9fec7d1d412e414231c9b929081b1daa7c3b788a9f91eedd79a55efdf5d0d291","src/operations.rs":"10772e65b8b7106f195428c5eb8dbf6cbd49dd5a2165ac750e54af5995210f88","src/random_state.rs":"b7981967ec5ecbff04d166b5e05c59c386062b4de3b36816f3c98ef284372f63","src/specialize.rs":"38d3b56ef4f264d564f48dbcb8ac137928babf90635090c9771c1a62140d1f30","tests/bench.rs":"0851dffebaffd7a437f6f9946ed5e03a957e9a6eb0da7911451af58778c411ec","tests/map_tests.rs":"e0f155f964dd965740b072ee1da110a8c6ef34491c95219f7c89064112c7840f","tests/nopanic.rs":"3363675c4c1a197b86604a0aebbe958fb5ec7c01a414fbfd70e9eb8a29707400"},"package":"fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"}
116 changes: 116 additions & 0 deletions src/rust/vendor/ahash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)

[package]
edition = "2018"
name = "ahash"
version = "0.7.6"
authors = ["Tom Kaitchuck <[email protected]>"]
build = "./build.rs"
exclude = ["/smhasher", "/benchmark_tools"]
description = "A non-cryptographic hash function using AES-NI for high performance"
documentation = "https://docs.rs/ahash"
readme = "README.md"
keywords = ["hash", "hasher", "hashmap", "aes", "no-std"]
categories = ["algorithms", "data-structures", "no-std"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/tkaitchuck/ahash"
[package.metadata.docs.rs]
features = ["std"]
rustc-args = ["-C", "target-feature=+aes"]
rustdoc-args = ["-C", "target-feature=+aes"]
[profile.bench]
opt-level = 3
lto = "fat"
codegen-units = 1
debug = false
debug-assertions = false

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
debug = false
debug-assertions = false

[profile.test]
opt-level = 2
lto = "fat"

[lib]
name = "ahash"
path = "src/lib.rs"
test = true
doctest = true
bench = true
doc = true

[[bench]]
name = "ahash"
path = "tests/bench.rs"
harness = false

[[bench]]
name = "map"
path = "tests/map_tests.rs"
harness = false
[dev-dependencies.criterion]
version = "0.3.2"

[dev-dependencies.fnv]
version = "1.0.5"

[dev-dependencies.fxhash]
version = "0.2.1"

[dev-dependencies.hex]
version = "0.4.2"

[dev-dependencies.no-panic]
version = "0.1.10"

[dev-dependencies.rand]
version = "0.7.3"

[dev-dependencies.seahash]
version = "4.0"

[dev-dependencies.serde_json]
version = "1.0.59"
[build-dependencies.version_check]
version = "0.9"

[features]
compile-time-rng = ["const-random"]
default = ["std"]
std = []
[target."cfg(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\"))".dependencies.const-random]
version = "0.1.12"
optional = true

[target."cfg(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\"))".dependencies.getrandom]
version = "0.2.3"

[target."cfg(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\"))".dependencies.serde]
version = "1.0.117"
optional = true
[target."cfg(not(all(target_arch = \"arm\", target_os = \"none\")))".dependencies.once_cell]
version = "1.8"
features = ["alloc"]
default-features = false
[target."cfg(not(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\")))".dependencies.const-random]
version = "0.1.12"
optional = true

[target."cfg(not(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\")))".dependencies.serde]
version = "1.0.117"
optional = true
Loading

0 comments on commit 98bee99

Please sign in to comment.