Add cleartext support for and_v(v:$sub1,$sub2) and and_v(v:$sub,LOCK) patterns.#270
Merged
Conversation
bigspider
force-pushed
the
cleartext-subpolicies
branch
2 times, most recently
from
May 29, 2026 22:00
b3695da to
3c41ef3
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the BIP388 “cleartext” system to support displaying and round-tripping Taproot leaf policies of the form and_v(v:$sub1, $sub2) by introducing a “subpolicy” binding kind that can classify and embed recognized tapleaf sub-expressions without requiring full DNF expansion.
Changes:
- Add
Subpolicyas a new cleartext binding/value kind, including decode support and generated classification/matching logic to prevent combinator nesting. - Add an
AndVtapleaf spec plus new TOML test vectors coveringand_v(...)cleartext rendering/scoring. - Move multiple crates to workspace-level Rust edition configuration (2024) and adjust code for newer Rust/SDK struct initializers and unsafe attribute/operation requirements.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/src/main.rs | Switch exported entrypoint attribute to #[unsafe(no_mangle)]. |
| vm/src/handlers/lib/ecall/ux_handler.rs | Use struct update syntax with Default::default() for NBGL layout struct init. |
| vm/src/app_ui/menu.rs | Use struct update syntax with Default::default() for NBGL bars list struct init. |
| riscv-arch-tests/Cargo.toml | Inherit Rust edition from workspace. |
| macros/Cargo.toml | Inherit Rust edition from workspace. |
| ecalls/Cargo.toml | Inherit Rust edition from workspace. |
| common/Cargo.toml | Inherit Rust edition from workspace. |
| client-sdk/src/vanadium_client.rs | Refactor pending-response handling (currently introduces a compile error). |
| client-sdk/Cargo.toml | Inherit Rust edition from workspace. |
| Cargo.toml | Define workspace package edition (2024). |
| cargo-vnd/Cargo.toml | Inherit Rust edition from workspace. |
| apps/bitcoin/bip388/src/cleartext/specs/test_vectors.toml | Add vectors for Taproot AndV leaf cleartext and scoring. |
| apps/bitcoin/bip388/src/cleartext/specs/cleartext.toml | Add AndV tapleaf spec: and_v(v:$sub1, $sub2). |
| apps/bitcoin/bip388/src/cleartext/mod.rs | Add Subpolicy cleartext part/value and display ordering for AndV. |
| apps/bitcoin/bip388/src/cleartext/decode.rs | Add decode support for parsing subpolicy cleartext into TapleafClass. |
| apps/bitcoin/bip388/build.rs | Extend codegen with Subpolicy bindings, classification steps, scoring, and descriptor construction. |
| app-sdk/src/lib.rs | Switch exported symbols to #[unsafe(no_mangle)] and reformat compile_error. |
| app-sdk/src/ecalls_native.rs | Add explicit unsafe {} blocks for raw-pointer ops (Rust 2024 compatibility). |
| app-sdk/Cargo.toml | Inherit Rust edition from workspace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bigspider
force-pushed
the
cleartext-subpolicies
branch
from
June 1, 2026 07:20
3c41ef3 to
e37e188
Compare
bigspider
force-pushed
the
cleartext-subpolicies
branch
from
June 1, 2026 08:03
e37e188 to
9e671d1
Compare
bigspider
marked this pull request as ready for review
June 1, 2026 09:03
bigspider
requested review from
cedelavergne-ledger
and removed request for
a team
June 1, 2026 09:03
bigspider
force-pushed
the
cleartext-subpolicies
branch
from
June 1, 2026 11:40
8b1bd01 to
62db8ab
Compare
and_v(v:$sub1,$sub2) and and_v(v:$sub1,LOCK) patterns.
and_v(v:$sub1,$sub2) and and_v(v:$sub1,LOCK) patterns.and_v(v:$sub1,$sub2) and and_v(v:$sub,LOCK) patterns.
cedelavergne-ledger
removed their request for review
June 1, 2026 14:47
While 'or' in taptrees can easily be split into different leaves, the same is not easily possible for policies that are composed with a conjunction (except with DNF reductions that incur in an exponential cost in the number of leaves, which is not practical). This adds minimal support for matching pattern with disjunctive policies, even just at a single level of nesting.
This avoids a proliferation of patterns: if a certain policy is supported as a pattern, prior to this change, 4 additional patterns with the various time-/height-locks would have to be added as well. Instead, we make the locks generic, so that the combinations are rather handled by composition (that is, recursion).
bigspider
force-pushed
the
cleartext-subpolicies
branch
from
June 1, 2026 14:51
b6a8f3f to
88729ea
Compare
bigspider
force-pushed
the
cleartext-subpolicies
branch
2 times, most recently
from
June 2, 2026 07:09
fba7395 to
41dbb37
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While 'or' in taptrees can easily be split into different leaves, the same is not easily possible for policies that are composed with a conjunction (except with DNF reductions that incur in an exponential cost in the number of leaves, which is not practical).
This adds minimal support for matching pattern with disjunctive policies, even just at a single level of nesting.
The same idea also allows simplifying the specifications for the various combinations with relative/absolute time-/height-locks, which use a pattern like
and_v(v:$sub,LOCK).