Skip to content

Add cleartext support for and_v(v:$sub1,$sub2) and and_v(v:$sub,LOCK) patterns.#270

Merged
bigspider merged 4 commits into
masterfrom
cleartext-subpolicies
Jun 2, 2026
Merged

Add cleartext support for and_v(v:$sub1,$sub2) and and_v(v:$sub,LOCK) patterns.#270
bigspider merged 4 commits into
masterfrom
cleartext-subpolicies

Conversation

@bigspider

@bigspider bigspider commented May 29, 2026

Copy link
Copy Markdown
Contributor

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).

@bigspider
bigspider force-pushed the cleartext-subpolicies branch 2 times, most recently from b3695da to 3c41ef3 Compare May 29, 2026 22:00
@bigspider
bigspider requested a review from Copilot June 1, 2026 06:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Subpolicy as a new cleartext binding/value kind, including decode support and generated classification/matching logic to prevent combinator nesting.
  • Add an AndV tapleaf spec plus new TOML test vectors covering and_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.

Comment thread client-sdk/src/vanadium_client.rs Outdated
Comment thread apps/bitcoin/bip388/build.rs
Comment thread app-sdk/src/ecalls_native.rs Outdated
Comment thread app-sdk/src/ecalls_native.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

@bigspider
bigspider force-pushed the cleartext-subpolicies branch from e37e188 to 9e671d1 Compare June 1, 2026 08:03
@bigspider
bigspider marked this pull request as ready for review June 1, 2026 09:03
@bigspider
bigspider requested a review from a team as a code owner June 1, 2026 09:03
@bigspider
bigspider requested review from cedelavergne-ledger and removed request for a team June 1, 2026 09:03
@bigspider
bigspider force-pushed the cleartext-subpolicies branch from 8b1bd01 to 62db8ab Compare June 1, 2026 11:40
@bigspider bigspider changed the title Add cleartext support for and_v(v:$sub1,$sub2) patterns Add cleartext support for and_v(v:$sub1,$sub2) and and_v(v:$sub1,LOCK) patterns. Jun 1, 2026
@bigspider bigspider changed the title Add cleartext support for and_v(v:$sub1,$sub2) and and_v(v:$sub1,LOCK) patterns. Add cleartext support for and_v(v:$sub1,$sub2) and and_v(v:$sub,LOCK) patterns. Jun 1, 2026
@cedelavergne-ledger
cedelavergne-ledger removed their request for review June 1, 2026 14:47
bigspider added 2 commits June 1, 2026 16:51
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).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread apps/bitcoin/bip388/build.rs
Comment thread apps/bitcoin/bip388/src/cleartext/specs/test_vectors.toml Outdated
Comment thread apps/bitcoin/bip388/src/cleartext/specs/test_vectors.toml Outdated
@bigspider
bigspider force-pushed the cleartext-subpolicies branch 2 times, most recently from fba7395 to 41dbb37 Compare June 2, 2026 07:09
@bigspider
bigspider merged commit 94f0d0b into master Jun 2, 2026
77 checks passed
@bigspider
bigspider deleted the cleartext-subpolicies branch June 2, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants