0xMiden / 0xMiden/miden-vm

Validate deferred witnesses in Verifier::verify()

Open
#3,765 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
772
Forks
352
Avg merge
1d 12h
Merged PRs (30d)
93

Description

## What should be done?

Move deferred witness validation from `miden-protocol`'s `TransactionVerifier` into `miden-verifier`'s `Verifier::verify()` path.

Today, [`Verifier::verify()` dispatches by proof format](https://github.com/0xMiden/miden-vm/blob/4080283da0a9618af7de15efa5d9e4cb9cb804bd/verifier/src/lib.rs#L90-L114). Its [format 1 deferred branch](https://github.com/0xMiden/miden-vm/blob/4080283da0a9618af7de15efa5d9e4cb9cb804bd/verifier/src/lib.rs#L117-L155) returns the precompile root authenticated by the VM proof without checking the carried `DeferredStateWire`.

[`TransactionVerifier::verify()` performs that check after VM verification](https://github.com/0xMiden/miden-base/blob/d7eef37eb4d89cd9d6d0de21be9d67af1cfe8d20/crates/miden-protocol/src/transaction/verifier.rs#L65-L81). Its [`validate_deferred_witness()` helper](https://github.com/0xMiden/miden-base/blob/d7eef37eb4d89cd9d6d0de21be9d67af1cfe8d20/crates/miden-protocol/src/transaction/verifier.rs#L95-L111) rebuilds the state with `miden_precompiles::registry()` and compares its root with the root returned by the VM verifier.

## How should it be done?

For format 1, whose protocol integration was added in [0xMiden/protocol#3782](https://github.com/0xMiden/protocol/pull/3782), move this check into `verify_v1()`'s deferred branch. Rebuild the carried wire with the standard precompile registry. Return a `VerificationError` when the wire is invalid or its root differs from the root authenticated by the VM proof. Keep returning that root in `VerificationOutcome` when the check succeeds.

Then remove `validate_deferred_witness()` and the matching protocol error variants from `miden-base`. `TransactionVerifier` should rely on `Verifier::verify()` for this check.

## When is this task done?

`Verifier::verify()` rejects malformed deferred wire and root mismatches. Verifier tests cover both failures and a matching witness. `TransactionVerifier` no longer repeats the check.

## Additional context

This follows [the discussion on deferred witness ownership](https://github.com/0xMiden/miden-vm/pull/3753#discussion_r3917809044).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.