refactor: make the recipient-binding encode infallible and state the scope-transplant rule - #1843
Conversation
… dead mint refusal The recipient-binding preimage is four byte strings the encoder builds itself, so neither check_depth nor Map::reject_if_wiped can fire. Route it through encode_fixed_depth, drop the Result from encode_recipient_binding and sign_recipient_binding, and delete the .ok()? in mint_grant_row that the false fallibility fed. mint_grant_row keeps its Option for the diffie_hellman contributory backstop, so remint_grants keeps its Rejected mapping for that leg. The wire format and the KAT vectors do not change.
publish_interior_head carries envelope-level and epochTag-level unknown fields from a record authored under one scope's AAD into a record authored under another scope's AAD. blueprint/core.md now states, inside the carried unknown fields law, that every new structure at either level is either scope-transplant-safe or refused by name at that authoring path, the way author_child_envelope already refuses the grant section. The scope-changing call site in reseal_interior_node carries a one-line cross-reference to the rule.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (11)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe change makes recipient-binding encoding and signing infallible by using fixed-depth encoding. Callers remove obsolete error handling. The blueprint documents scope-transplant requirements for preserved fields, and the affected authoring path references the rule. ChangesRecipient-binding API
Scope-transplant rule
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The change preserves recipient-binding behavior and caller contracts, with no established production-impacting regression. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Wave 19, lane C2. Two
comp:coreissues that share the recipient-binding and carried-unknown surface.What changes
#1551 — the recipient-binding encode becomes infallible.
The preimage is a map of four byte strings the function builds itself. It nests two levels against
MAX_DEPTH128 and the map is local, so neithercheck_depthnorMap::reject_if_wipedcan fire. The encode now goes throughencode_fixed_depth, which is the codec's own name for a tree whose nesting the construction site fixes.encode_recipient_bindingreturnsVec<u8>.sign_recipient_bindingreturnsEcdsaSignature.verify_recipient_bindingstays fallible for the signature check and loses only the?on its encode leg.mint_grant_rowloses the.ok()?that the false fallibility fed.mint_grant_rowkeeps itsOption. Thediffie_hellmanleg is a real contributory backstop, soremint_grantskeeps itsRejectedmapping for that leg. This is the open call in step 4 of the issue; the decision is recorded on the issue.Six caller sites drop an
.expector an.unwrap. The wire format does not change and the KAT vectors do not change:crates/core/kat/manifest.jsonis untouched and the recipient-binding accept vectors re-encode byte-for-byte.#1711 — the scope-transplant rule is stated.
blueprint/core.mdnow states, inside the carried unknown fields law that it qualifies, that every new envelope-level orepochTag-level structure is either scope-transplant-safe or refused by name at the authoring path that moves it, the wayauthor_child_envelopealready refuses the grant section. One sentence covers both levels.reseal_interior_nodecarries a one-line cross-reference immediately before itspublish_interior_headcall. That is the single call site where the scope changes while carried unknown fields travel; the sweep keeps the node inside its own scope and carries no cross-reference.Verification
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test -p cipherbox-core,cargo test -p cipherbox-engine,cargo check -p cipherbox-wasm --target wasm32-unknown-unknown,pnpm lint:md,pnpm lint:tracker-refs. All green. No TypeScript is touched.Review gates
Simplify, security and crypto and privacy passes ran inline over
git diff main...HEAD. The crypto and privacy pass confirms the preimage bytes, the RFC 6979 ECDSA signing path and the zeroize ownership are all unchanged, and that the one removed refusal was unreachable rather than fail-closed.Body checks / follow-ups filed
v2-buildadded.Closes #1551.
Closes #1711.
Summary by CodeRabbit
Documentation
Reliability
Tests
Note
Make
encode_recipient_bindingandsign_recipient_bindinginfallible and add scope-transplant ruleencode_recipient_bindingin write_body.rs from a fallible codec return to raw bytes using a fixed-depth encoder;sign_recipient_bindingnow returns the signature directly.reseal_interior_nodeidentifying it as the authoring path where carried unknown fields cross a scope boundary.encode_recipient_bindingandsign_recipient_bindingno longer returnResult; all callers that previously handled encoding errors must be updated.Macroscope summarized 91511de.