Repository navigation
RC2-CBC: delete the update functions, which nothing calls - #4877
Merged
Merged
Conversation
Neither Rust (src/cipher/rc2/cbc.rs takes whole blocks, through init and the chained functions) nor verified code calls vg_rc2_cbc_encrypt_update or vg_rc2_cbc_decrypt_update. Their code, proofs and registrations go on all six targets, with the internal CBC functions only they called, the shared update lemmas and scratch contracts, and their residue-allowlist lines. AArch64 keeps its byte copy, which ECDSA's verification uses. The internal-function test's fixture was the streaming functions; it now takes all of RC2's AArch64 artifacts, and an internal function naming another from AES-XTS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFjAR7Byf513R4zuFy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFjAR7Byf513R4zuFy
alex
pushed a commit
that referenced
this pull request
Nov 10, 2026
#4877 deleted vg_rc2_cbc_encrypt_update and vg_rc2_cbc_decrypt_update, which nothing called. Their signature, pre- and postconditions, contracts, safety items and Apis go, with Spec.Rc2.update and Spec.Rc2.blocks, which only they used. The module doc describes initialization, which the chained functions continue from, and init's summary points at the chained functions; the generated crates' documentation of vg_rc2_cbc_init changes with it. The spec test checks what the remaining contracts state, against the same published vectors: CBC from the IV init keeps, split at every block boundary and continued from Cbc.next, and init's limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFjAR7Byf513R4zuFy
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.
Part of #4548. The Rust API and verified code never call
vg_rc2_cbc_encrypt_updateorvg_rc2_cbc_decrypt_update:src/cipher/rc2/cbc.rstakes whole blocks only, throughvg_rc2_cbc_initand the_chainedfunctions.So this PR deletes the two functions, on all six targets, instead of making them internal.
What changes
Code (
Impl/Rc2/<Target>/Stream.lean).initis unchanged.copy,copyBody), which ECDSA's verification uses (Impl/Ecdsa/AArch64/VerifyHash.lean).Proofs (
Proof/Rc2/<Target>/Stream/).UpdateandPrepUpdateandCopyLongUpdateLongCopystays for ECDSA.init's proof now has the two small helpers it used fromPrep.inituses move from the deleted update section toCommon.lean.inituses stay (test_ok,beq_zero,contains_prefix, thewide_pre/rc2_stream_narrowtactics, without their update lemmas).Proof/Rc2/Scratch.leanlosescbcUpdateScratch*and the update*_locallemmas, andProof/Rc2/Stream.leanlosesupdate_eq,update_post_shortandupdate_post_long, with the lemmas only they used.initonly.Registrations (
Artifacts/Rc2/<Target>.lean). ThecbcEncryptUpdateApiandcbcDecryptUpdateApientries go.Generated crates.
vg_rc2_cbc_encryptandvg_rc2_cbc_decryptthat only they called.Test (
VerifiedGarbageTest/Internal.lean). Its fixture was the streaming functions, which called the internal CBC functions, which called the block functions. Now:initcallsvg_rc2_expand_key, andrc2_cbccalls the block functions from a module other thanrc2.CI data.
ci/residue_allowlist.txtlosesx86_64 vg_rc2_cbc_{en,de}crypt_update.ci/lean_speed_allowed.pylowers two counts, since the patterns went with the deleted code.No
Spec/orTCB/change. The follow-up Spec PR deletes:Spec.Rc2.cbcUpdateSig,cbcUpdatePre,cbcUpdatePost,cbcUpdateContract,cbcEncrypt/DecryptUpdateContract,cbcUpdateSafetyand the two Apis;Spec.Rc2.update;init's summary text that points at the update functions.init's contract keeps the context,contextAtincluded.Checks
lake build(all modules),Emit.lean, andEmit.lean --checkStatic checksjob's scriptscheck_lean_public_imports.pyon each edited modulecargo fmt --check,cargo clippy --all-targets -D warningscargo testwith Wycheproof, and the RC2 tests withVG_CPU_FEATURES=nonemain, whose only change since was Spec: delete FFDH generate_key_cached's Api and contract #4876 (FFDH's Spec).Generated by Claude Code