Skip to content

Commit

Permalink
Renable assertion
Browse files Browse the repository at this point in the history
Redo all correctness and malleablity properties for Covenant fragments.
Minsicript fragments were designed only to consider inputs from stack
for satisfaction/dissatisfaction.
Traditional fragments can only be dissatified from stack inputs, but
covenant fragments can be dissatisfied by changing the transaction
components. We do not consider these malleabilities in the extensions
and only deal with script witness malleability.

I also needed to remove the test that used now incorrectly typed
miniscript.
  • Loading branch information
sanket1729 committed Oct 23, 2022
1 parent 5430285 commit 61c2f3a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/descriptor/csfs_cov/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ mod tests {
string_rtt("elcovwsh(A,or_i(pk(B),pk(C)))");
string_rtt("elcovwsh(A,multi(2,B,C,D))");
string_rtt("elcovwsh(A,and_v(v:pk(B),pk(C)))");
string_rtt("elcovwsh(A,thresh(2,ver_eq(1),s:pk(C),s:pk(B)))");
string_rtt("elcovwsh(A,thresh(2,l:ver_eq(1),s:pk(C),s:pk(B)))");
string_rtt("elcovwsh(A,outputs_pref(01020304))");
}

Expand Down
5 changes: 5 additions & 0 deletions src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2109,4 +2109,9 @@ pk(03f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8))";
"eltr(020000000000000000000000000000000000000000000000000000000000000002)",
);
}

#[test]
fn test_regression_29() {
let _ = Descriptor::<String>::from_str("eltr(,thresh(1,spk_eq(,00)))");
}
}
8 changes: 4 additions & 4 deletions src/extensions/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,16 +811,16 @@ impl Extension for Arith {
fn corr_prop(&self) -> Correctness {
Correctness {
base: Base::B,
input: Input::Zero, // No input from stack
dissatisfiable: true,
input: Input::Zero, // No input from stack
dissatisfiable: false, // No dissatisfactions from stack
unit: true,
}
}

fn mall_prop(&self) -> Malleability {
Malleability {
dissat: Dissat::Unknown, // many dissatisfactions possible
safe: false, // Unsafe as a top fragment
dissat: Dissat::None, // No dissatisfactions from stack inputs
safe: false, // Unsafe as a top fragment
non_malleable: true, // There can exist multiple satisfactions for expressions. inp_v(0) = out_v(0), but
// we only deal with script satisfactions here.
}
Expand Down
8 changes: 4 additions & 4 deletions src/extensions/introspect_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,16 +418,16 @@ impl<T: ExtParam> Extension for CovOps<T> {
fn corr_prop(&self) -> Correctness {
Correctness {
base: Base::B,
input: Input::Zero, // No input from stack
dissatisfiable: true,
input: Input::Zero, // No input from stack
dissatisfiable: false, // No dissatisfactions possible from stack inputs
unit: true,
}
}

fn mall_prop(&self) -> Malleability {
Malleability {
dissat: Dissat::Unknown, // many dissatisfactions possible
safe: false, // Unsafe as a top fragment
dissat: Dissat::None, // No dissatisfactions from stack inputs
safe: false, // Unsafe as a top fragment
non_malleable: true, // Script satisfaction is non-malleable, whole fragment tx could be malleable
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/tx_ver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ impl Extension for LegacyVerEq {
Correctness {
base: Base::B,
input: Input::Zero,
dissatisfiable: true,
dissatisfiable: false, // No dissat from stack inputs
unit: true,
}
}

fn mall_prop(&self) -> Malleability {
Malleability {
dissat: Dissat::Unknown, // multi-dissat
dissat: Dissat::None, // No dissatisfactions from stack inputs
safe: false,
non_malleable: true,
}
Expand Down
3 changes: 1 addition & 2 deletions src/miniscript/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,7 @@ impl Property for Type {
debug_assert!(!self.corr.dissatisfiable || self.mall.dissat != Dissat::None);
debug_assert!(self.mall.dissat == Dissat::None || self.corr.base != Base::V);
debug_assert!(self.mall.safe || self.corr.base != Base::K);
// Not true for covenant scripts. Covenant scripts have zero inputs, but are still malleable
// debug_assert!(self.mall.non_malleable || self.corr.input != Input::Zero);
debug_assert!(self.mall.non_malleable || self.corr.input != Input::Zero);
}

fn from_true() -> Self {
Expand Down
7 changes: 0 additions & 7 deletions src/psbt/mod.rs

Large diffs are not rendered by default.

0 comments on commit 61c2f3a

Please sign in to comment.