More Vest DSL Features #40
Merged
Merged
Conversation
y1ca1
added a commit
that referenced
this pull request
Mar 26, 2026
* Bump vstd version * Make dependent `Pair` aware of refinements * Syntax for length expression (incl. arith and size) and field accesses * Adapt elab and tyck for new syntaxes * Negative tests for tyck * Reduce warnings * More generic disjointness proofs and support for `AndThen<Tail, B>` * Codegen for length expr; nested dependent fmts; preconds for refinements * Positive tests for length expr and nested field accesses * [claude] (Incomplete) IKEv2 binary format specification in vest dsl * Fix `ensures` for continuation * Cleanup `vest.pest` * Further simplify `vest.pest` * Elaborate nested anonymous struct/choose fmts * New and regression tests * TLS regression (cherry picked from commit 8fde004)
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.
More Vest DSL Features
This PR introduces three major extensions to the Vest DSL that enhance its expressiveness for specifying complex binary formats. These features were motivated by the need to precisely specify IKEv2 (RFC 5996), where payload lengths are context sensitive and fields depend on previously-parsed nested structures.
New Features
1. Length Expressions:
|fmt|A new syntax to reference the wire length of any format with a fixed (compile-time known) size.
Syntax:
|T|evaluates to the wire length of formatTas a compile-time constant.Examples:
2. Arithmetic in Length Expressions
Length positions now support full arithmetic expressions with
+,-,*,/, and parentheses.Examples:
IKEv2 use case: The
payload_lengthfield includes the 4-byte generic header, so body length =@payload_length - |generic_payload_header|:Note: Vest simply translates the arithmetic expression to Verus expressions and Verus guarantees the arithmetic safety. Though, to make Verus happy, it's still user's responsibility to properly bound the integers (e.g., using refinements) before doing any arithmetics.
3. Nested Field Access:
@hdr.fieldWhen a dependent field is itself a struct, you can access its sub-fields using dot notation.
Examples:
IKEv2 use case: The IKE message header contains the total length:
4. Nested Anonymous Struct/Choose Formats
Anonymous struct and choose formats can now be deeply nested while correctly capturing dependent fields from outer scopes.
Examples:
test/src/ikev2.vestis an LLM-authored Vest specification for IKEv2. It's primarily used to motivate the new DSL features and is currently incomplete and hasn't been tested for compliance.