Skip to content

Commit 5dbfc26

Browse files
committed
Merge #530: Update multi_a to not include n wrapper
0ad1fdf Release 7.0.1 (sanket1729) 85fe631 Fix Ci (sanket1729) f1a9238 Update multi_a to not include n wrapper (sanket1729) Pull request description: ACKs for top commit: apoelstra: ACK 0ad1fdf Tree-SHA512: 38cbd6c597a011cb02c2a349818dc7fe8bfe63c8fc3111352f848ac418dfd8983786b1ed7efff8134ae273de014b98836e1f6cb0d92337e19b3444746612b1f3
2 parents 65a8ea8 + 0ad1fdf commit 5dbfc26

File tree

7 files changed

+49
-5
lines changed

7 files changed

+49
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 7.0.1 - March 8, 2023
2+
3+
- Fixed a typing rule in `multi_a` for taproot miniscript descriptors. Current typing rules
4+
incorrectly tagged `multi_a` with the `n` property. Certain miniscripts of the form `j:multi_a` could
5+
could not spent without the first key. We could not find any evidence of these scripts being used
6+
in the wild. While this is technically a breaking change, any downstream users whose code would
7+
break by this change are already vulnerable.
8+
19
# 7.0.0 - April 20, 2022
210

311
- Fixed miniscript type system bug. This is a security vulnerability and users are strongly encouraged to upgrade.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "miniscript"
3-
version = "7.0.0"
3+
version = "7.0.1"
44
authors = ["Andrew Poelstra <[email protected]>, Sanket Kanjalkar <[email protected]>"]
55
repository = "https://github.com/apoelstra/miniscript"
66
description = "Miniscript: a subset of Bitcoin Script designed for analysis"

contrib/test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ then
88
alias cargo="cargo +$TOOLCHAIN"
99
fi
1010

11+
12+
# Pin dependencies as required if we are using MSRV toolchain.
13+
if cargo --version | grep "1\.41"; then
14+
# 1.0.108 uses `matches!` macro so does not work with Rust 1.41.1, bad `syn` no biscuit.
15+
cargo update -p syn --precise 1.0.107
16+
fi
17+
1118
# Lint if told to
1219
if [ "$DO_LINT" = true ]
1320
then

src/miniscript/types/correctness.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ impl Property for Correctness {
173173
}
174174
}
175175

176+
fn from_multi_a(_: usize, _: usize) -> Self {
177+
Correctness {
178+
base: Base::B,
179+
input: Input::Any,
180+
dissatisfiable: true,
181+
unit: true,
182+
}
183+
}
184+
176185
fn from_hash() -> Self {
177186
Correctness {
178187
base: Base::B,

src/miniscript/types/malleability.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ impl Property for Malleability {
122122
}
123123
}
124124

125+
fn from_multi_a(_: usize, _: usize) -> Self {
126+
Malleability {
127+
dissat: Dissat::Unique,
128+
safe: true,
129+
non_malleable: true,
130+
}
131+
}
132+
125133
fn from_hash() -> Self {
126134
Malleability {
127135
dissat: Dissat::Unknown,

src/miniscript/types/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,7 @@ pub trait Property: Sized {
270270
fn from_multi(k: usize, n: usize) -> Self;
271271

272272
/// Type property of a `MultiA` fragment
273-
fn from_multi_a(k: usize, n: usize) -> Self {
274-
// default impl same as multi
275-
Self::from_multi(k, n)
276-
}
273+
fn from_multi_a(k: usize, n: usize) -> Self;
277274

278275
/// Type property of a hash fragment
279276
fn from_hash() -> Self;
@@ -584,6 +581,13 @@ impl Property for Type {
584581
}
585582
}
586583

584+
fn from_multi_a(k: usize, n: usize) -> Self {
585+
Type {
586+
corr: Property::from_multi_a(k, n),
587+
mall: Property::from_multi_a(k, n),
588+
}
589+
}
590+
587591
fn from_hash() -> Self {
588592
Type {
589593
corr: Property::from_hash(),

src/policy/compiler.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ impl Property for CompilerExtData {
191191
}
192192
}
193193

194+
fn from_multi_a(k: usize, n: usize) -> Self {
195+
CompilerExtData {
196+
branch_prob: None,
197+
sat_cost: 66.0 * k as f64 + (n - k) as f64,
198+
dissat_cost: Some(n as f64), /* <w_n> ... <w_1> := 0x00 ... 0x00 (n times) */
199+
}
200+
}
201+
194202
fn from_hash() -> Self {
195203
CompilerExtData {
196204
branch_prob: None,

0 commit comments

Comments
 (0)