Skip to content

test(core): property-test the canonical encoding (OSTIF T-12) - #84

Merged
tonibergholm merged 1 commit into
mainfrom
test/proptest-canonical-encoding
Jul 18, 2026
Merged

tonibergholm merged 1 commit into
mainfrom
test/proptest-canonical-encoding

Conversation

@tonibergholm

Copy link
Copy Markdown
Member

Executes T-12 (start of G-001's testing track) from the OSTIF audit (#76).

Adds proptest as a dev-dependency of scl-core only, with three properties on the canonical encoding:

  1. Id-stable round trip — decode(encode(o)) succeeds, re-encodes byte-identically, and preserves id(), for generated objects of all eight kinds (Blob, Tree, Snapshot incl. protection registers, Secret, Signature, Transcript, Sealed, Manifest). Encode canonicalizes sort order, so encode-stability is the property, not strict equality.
  2. Decode totality on arbitrary bytes — never panics on attacker-shaped input (this is the entry point wire/pack data reaches).
  3. Decode totality on truncations — the cut-off-transfer case.

Verified locally: 48/48 scl-core tests pass, clippy clean. Next slice: T-13 nightly cargo-fuzz target on the wire decode path.

Adds proptest (dev-dependency of scl-core only) and three properties on
Object::encode/decode — the content-addressing core invariant:

- decode(encode(o)) succeeds, re-encodes to identical bytes, and keeps
  the content address, across generated objects of all eight kinds
  (encode canonicalizes sort order, so encode-stability is the
  load-bearing property, not strict struct equality).
- decode is total on arbitrary bytes (0..2048) — the path
  attacker-supplied wire/pack data reaches. Ok or Err, never a panic.
- decode is total on truncations of valid encodings (cut-off transfers).

First slice of the audit's fuzzing track; the nightly cargo-fuzz target
on the wire decode path (T-13) builds on the same entry points.
@tonibergholm
tonibergholm merged commit 877e295 into main Jul 18, 2026
8 checks passed
@tonibergholm
tonibergholm deleted the test/proptest-canonical-encoding branch July 18, 2026 09:28
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.

1 participant