Skip to content

ORE v2 (2/n): core refactor — width abstraction, seed/tag separation, template RO keys#79

Draft
coderdan wants to merge 1 commit into
feat/ore-v2-test-vectorsfrom
feat/ore-v2-core-refactor
Draft

ORE v2 (2/n): core refactor — width abstraction, seed/tag separation, template RO keys#79
coderdan wants to merge 1 commit into
feat/ore-v2-test-vectorsfrom
feat/ore-v2-core-refactor

Conversation

@coderdan

Copy link
Copy Markdown
Contributor

Stacked on #78. Plan §1 (docs/plans/2026-06-12-ore-v2-architecture.md).

What

  • BlockWidth trait (scheme/width.rs): sealed trait carrying BITS/DOMAIN and the domain-sized associated types (RightBlock, Prp, RoKeyBuf) that stable Rust can't express const-generically. Bit8 is the only width today; Bit6 arrives with its scheme (PR 5).
  • 6-bit decomposition (scheme/decompose.rs): MSB-first bit-packing with quickcheck properties for order preservation, domain bounds, and injectivity — landed ahead of the scheme that consumes it so the packing is independently pinned.
  • Seed/tag buffer separation: PRP seeds (PRF₂ outputs — key-equivalent material) now live in a dedicated zeroize-on-drop SeedBuf and never touch the serialisable Left. Previously the only thing separating seeds from published tags was statement ordering inside encrypt.
  • Template RO keys: the per-block RO key inputs are maintained incrementally (3 byte-writes per entry per block) instead of rebuilt from a zeroed lazy_static block each iteration; a work buffer takes the in-place PRF/hash passes. Both zeroized after use. lazy_static dependency dropped.
  • encode_right_block: the naive per-bit indicator loop extracted behind a width-generic function — deliberately not optimized here (risk staging); the permutation-direct bulk form is PR 3.

Byte identity

All 12 compatibility vector tests from #78 pass unchanged — the AES input bytes are identical to before; only buffer management moved.

Note for review

OreCipher's public shape is unchanged in this PR; the associated-type change flagged in the plan lands with the Bit6 scheme instead, keeping this diff purely internal.

Introduces the ORE v2 core abstractions (plan §1) with byte-identical
output, verified by the PR 1 compatibility vectors:

- BlockWidth trait (Bit8 today; Bit6 arrives with its scheme) carrying the
  domain-sized types stable Rust can't express const-generically.
- 6-bit MSB-first block decomposition with order-preservation property
  tests, ahead of the scheme that consumes it.
- PRP seeds (PRF2 outputs, key-equivalent material) now live in a dedicated
  zeroize-on-drop SeedBuf, never in the serialisable Left; tag inputs are
  built directly into Left.f.
- RO keys maintained as an incrementally-updated template plus a work
  buffer for the in-place PRF/hash passes (3 byte-writes per entry per
  block instead of a full rebuild), both zeroized after use.
- Indicator encoding extracted behind encode_right_block (naive form
  retained; bulk form lands in the next PR).

Drops the now-unused lazy_static dependency.

Part of the ORE v2 program (docs/plans/2026-06-12-ore-v2-architecture.md, PR 2).
let mut seeds = [AesBlock::default(); N];
for (n, block) in seeds.iter_mut().enumerate() {
block[0..n].clone_from_slice(&x[0..n]);
// TODO (tracked in v2 plan, fixed for new schemes by the §5(b)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should link to the relevant PR

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