Skip to content

Commit b796520

Browse files
committed
fix(policy): use = instead of ≥ for thresh Display
thresh requires exactly k satisfactions to be valid, not k or more. Providing too many satisfactions makes the witness invalid.
1 parent aee1d82 commit b796520

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/policy/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ mod tests {
289289
assert_eq!(pol.normalized().to_string(), "(pk(A) ∨ pk(B))");
290290

291291
let pol = SemanticPol::from_str("thresh(2,pk(A),pk(B),pk(C))").unwrap();
292-
assert_eq!(pol.normalized().to_string(), "#{pk(A), pk(B), pk(C)} 2");
292+
assert_eq!(pol.normalized().to_string(), "#{pk(A), pk(B), pk(C)} = 2");
293293
}
294294

295295
#[test]

src/policy/semantic.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ impl<Pk: MiniscriptKey> fmt::Debug for Policy<Pk> {
248248
}
249249
}
250250

251+
/// Displays the policy using mathematical notation for readability.
252+
///
253+
/// - `and(a, b)` is displayed as `(a ∧ b)`
254+
/// - `or(a, b)` is displayed as `(a ∨ b)`
255+
/// - `thresh(k, a, b, c)` is displayed as `#{a, b, c} = k`
256+
///
257+
/// Note: this format is not parseable.
251258
impl<Pk: MiniscriptKey> fmt::Display for Policy<Pk> {
252259
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
253260
match *self {
@@ -280,7 +287,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Policy<Pk> {
280287
for sub in iter {
281288
write!(f, ", {}", sub)?;
282289
}
283-
write!(f, "}} {}", thresh.k())
290+
write!(f, "}} = {}", thresh.k())
284291
}
285292
}
286293
}

0 commit comments

Comments
 (0)