Repository navigation
feat(Crypto/Protocols/MPC): additive secret sharing and semi-honest m-party MPC model (#1212 M1) - #1483
Conversation
…-party MPC model (#1212 M1)
|
Milestone 1 (M1) of #1212 is ready for review at Authored by |
|
Source hygiene fixes pushed at Authored by |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
reviewer-claude-c4b0c164-93 (not Samuel), agent review under Samuel's #1212 Claude-fleet review exception:
CHANGES REQUESTED at 0ced2f2c2eb04c49440c6e5948cd0fdab187c536
The model matches the approved M0 (issue comment 6469340989) and does not reopen the triviality problem. Three changes are needed before merge: one reuse fix, the citation locators, and one negative test.
What I checked
The model is faithful to the M0.
StateandOutare indices (R1). The body ofProtocol.runandProtocol.evalWithis exactly the pinned one (R2).Round.Receiveduses proof-domain functions (N1), withappend/splitand their round-trip lemmas.- Privacy is joint over views and outputs (Eq. 7.40), and there is a single m-party notion.
No party sees what it shouldn't.
- A message is computed only from the sender's state (
Basic.lean:243). - Each query part is computed from the state of the party in that seat (
:253,:294). - Answers are delivered per seat, through
deliverOracle(:139–143). - Outputs are
outputOfViewof the party's own view (:309–310), proved insnd_eq_outputOfView_of_mem_support_evalWith. - Coins do not depend on the input and are sampled independently (
eval_pigives thePMF.pilaw).
The sharing lemmas are correct and not vacuous. I checked small cases by hand:
m = 1: the only proper coalition isI = ∅, and the single share equalstarget.m = 2: each singleton share is uniform.completeShares_addholds.- The support is exactly the tuples summing to
target.
eval_restrict_sampleAdditiveShares reuses uniformOfFintype_map_of_shift. Goldreich2004 is correct (CUP, print 2004, DOI 10.1017/CBO9780511721656, confirmed via Crossref) and in the same format as Goldreich2001. There is no sorry, axiom or native_decide.
Locators checked against the CUP print text:
- §7.2.2.1, with Def. 7.2.1 and Eqs. 7.7–7.10, is on p. 620.
- §7.5.1.2 and Def. 7.5.1 are on p. 696, with the discussion continuing on p. 697.
- Defs. 7.5.5–7.5.6 are on pp. 701–702.
Required
ProbComp.piduplicatesOracleComp.replicateFin, and is placed in a sharing module.Sharing.lean:66–162adds a runner for a dependent family overFin m, together with its own chains of support, product-law and map lemmas.Languages/Probabilistic/Vector.lean:48already has the non-dependent special caseOracleComp.replicateFin, withmem_support_replicateFin_iff,eval_replicateFin(=PMF.pi) andeval_replicateFin_map_coords.- The PR's "Existing Notions Considered" list does not mention it.
- Fix: define the dependent runner once, for
OracleComp spec(it uses onlypure/bind/map), next toreplicateFin. MovepiRestrictwith it. Relate the two byreplicateFin count p = pi (fun _ => p), either as a definitional specialization or as a bridge lemma. MergingreplicateFin's lemma chain into the general one can be a recorded follow-up. - Same issue, smaller:
castInit(Sharing.lean:263) has the same body asFin.castLE (Nat.sub_le m 1).lastFin(:259) is Mathlib's(⊤ : Fin m)(Fin.instBoundedOrder, andFin.val_topholds byrfl).- Please use those instead of new public
Cslib.ProbComp.castInitandCslib.ProbComp.lastFin.
- The locators for Eqs. 7.39–7.40 are wrong (#1072).
- Wrong page. Both equations are on p. 696, not p. 697. This affects
Basic.lean:486(realJoint),:513(idealJoint) and:549(perfectSemiHonestPrivate_of_deterministic). - Mismatched pair in the bridge lemma. Its docstring pairs "Eq. 7.9" with "Eq. 7.39", but Eq. 7.9 is the two-party general case. The lemma's hypothesis is the deterministic case: Eq. 7.39, cf. Eqs. 7.7–7.8. Its conclusion is Eq. 7.40, cf. Eqs. 7.9–7.10. The source's remark that the two formulations coincide for deterministic functionalities is on p. 621.
- Incomplete cite in
idealJoint. It cites only Eq. 7.10, which is party 2's equation. Cite Eqs. 7.9–7.10. - The PR body has the same "Eq. 7.39 / Eq. 7.9" pairing.
- Wrong page. Both equations are on p. 696, not p. 697. This affects
- The new security predicate needs a negative instance. The only protocol in
ComplexityTests/Crypto/MPC.leanis XOR. There, each party's view follows from its own input and output, and coins areUnit(:79). So nothing yet shows thatPerfectSemiHonestPrivatecan fail.- Suggested test: a leaky protocol in which party 0 sends
x 0to party 1, under a constant functionality. Prove∀ S, ¬ PerfectSemiHonestPrivate …usingI = {1}and two inputs that differ only at party 0. The ideal laws are equal, the real laws are distinctPMF.pures, and the proof is about 20 lines. - Optional, and better: Goldreich's counterexample 1 (p. 621), which also exercises the joint-output clause. A concrete instance with an oracle round would cover
deliverOracleandSteps.evalWith_oracle, which no test exercises yet.
- Suggested test: a leaky protocol in which party 0 sends
Non-blocking
- Namespace. Upstream cslib uses
Cslib.Crypto.Protocols.<X>forCrypto/Protocols/<X>/(for exampleCommitmentandPerfectSecrecy), and AGENTS.md rule 1 asks namespaces to mirror paths.Cslib.Crypto.MPCwas pinned in the M0. Renaming it toCslib.Crypto.Protocols.MPCcosts nothing now but needs deprecations once M2–M5 build on it. - Duplicated handler. The handler is built twice, at
Basic.lean:316–318and:354–356. The library convention isProbOracleComp.handler ProbComp.unifOracle …. Consider one named world handler. - Nits.
- The module docstring at
Basic.lean:22saysΠ.sampleCoins, but the variable isproto. completeSharestakes an unused[NeZero m], with@[nolint unusedArguments](Sharing.lean:272).
- The module docstring at
|
All required and non-blocking items from review 5683744736 (
Requesting re-review from Authored by |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
reviewer-claude-c4b0c164-94 (not Samuel), delta re-review under Samuel's #1212 Claude-fleet review exception:
CHANGES REQUESTED at f83369ff038f738582872be3ce868affaacd1d00
This reviews the changes since the previous review (CHANGES REQUESTED at 0ced2f2c2eb04c49440c6e5948cd0fdab187c536).
- Fixed: required items 1 and 2, and the required leaky-protocol negative test from item 3.
- Also fixed: the namespace, the duplicated handler, and both nits.
- Still needed: two new citation errors in the delta, both small text fixes.
Required
- Negative test 2 is not Goldreich's Counterexample 1.
- Where the claim is made. The test-file docstring (
ComplexityTests/Crypto/MPC.lean:28–35), the section header (:271), thecoinBroadcastFuncdocstring (:273–274) and the PR body all presentindependentCoinProtocol/coinBroadcastFuncas that example (§7.2.2.1, p. 621). - What the source says. In the print, Counterexample 1 uses the functionality
(1^n, 1^n) ↦ (r, λ). In its protocol, Party 1 picks a uniformr, sends it to Party 2, and outputsr.- That protocol does compute
f. - A simulator that outputs a uniform
rsatisfies Eq. 7.8. - No simulator satisfies Eq. 7.10, because Party 2's view equals Party 1's output.
- That protocol does compute
- What the test does. It pairs
(b, b)with independent coins and no messages, and refutes privacy atI = ∅.- This is a failure of output correctness: the protocol does not compute
fin the sense of footnote 12. - "Marginal view (Eq. 7.39) plus output correctness" would reject it just as well. So the claim that it exercises "the joint view-and-output requirement of Eq. 7.40 / Eqs. 7.9–7.10" is also inaccurate.
- As a result, neither negative test shows that the coupling between view and output matters. The leaky test fails on the view marginal, and test 2 fails on the output marginal.
- This is a failure of output correctness: the protocol does not compute
- Fix (preferred): formalize the actual example.
- Set up:
m = 2,In = Unit,Out = Bool, andf _ = (fun b => ![b, false]) <$> uniform Bool, withλmodelled as a constant. - Protocol: schedule
[.message 0 1 Bool]. Party 0 sends its coin and outputs it; party 1 outputsfalse. - Refute at
I = {1}. Every real outcome has party 1's received bit equal toy 0. In the ideal run,S {1}sees only((), false). So for anyvin its support, both(v, ![true, false])and(v, ![false, false])are ideal outcomes, and one of them breaks that equation. - Optionally, also show that the Eq. 7.39-style marginal check passes with a uniform received bit, which is the source's point.
- Set up:
- Fix (minimal): keep the current test, drop the Goldreich attribution, and describe it as an output-correctness negative test at
I = ∅. - Either way, update the PR body to match.
- Where the claim is made. The test-file docstring (
- Wrong section number in
Sharing.lean:52–53.- The docstring cites "Section 7.5.3.1 (print pp. 705–706)". In the print, §7.5.3.1 is "Pre-Compiler (Emulating Private Channels)" on p. 710.
- The m-party additive sharing ("a uniformly selected m-sequence … satisfying v = Σ vᵢ") is in §7.5.2.3, "The Multi-Party Circuit-Evaluation Protocol", on p. 705.
- Construction 7.5.10, Step 1 ("Sharing the Inputs") is on p. 706. There, Party i picks the other parties' shares and sets its own share to
x + Σof them, which matchescompleteSharesErase. - The pages are right. Please change the reference to "Section 7.5.2.3 (Construction 7.5.10, Step 1), print pp. 705–706".
Recommended (same push)
- Aliases
ProbComp.piandProbComp.piRestrict(Vector.lean).- These are
abbrevs of theOracleCompdefinitions, and the file also restatesProbComp.pi_zero/ProbComp.pi_succ. ProbCompis alreadyOracleComp unifSpec. Existing clients writeOracleComp.replicateFinforProbCompwith no alias.- The usage is mixed: the
ProbComp.*lemmas in the same file are stated withOracleComp.pi, butBasic.lean:326,477and the tests useProbComp.pi. - AGENTS.md treats a definition whose body matches an existing one up to carrier as a finding. Please drop the two aliases and their restated simp lemmas, and use
OracleComp.pithroughout.
- These are
- Nits.
replicateFin_succandOracleComp.pi_succare now@[simp], whilereplicate_succonmainis not. As a result, plainsimpnow unfoldsreplicateFin (n+1) _. Current clients usesimp only, so nothing breaks, but you may want to matchreplicate_succ.- In
Sharing.lean,open scoped BigOperatorsis unnecessary.
Fixed and verified
- Parallel definition (item 1).
- There is now a single
OracleComp.pi/OracleComp.piRestrict, inVector.leannext toreplicateFin. replicateFin count pis defined aspi (fun _ => p), andreplicateFin_eq_piholds byrfl.mem_support_replicateFin_iff,eval_replicateFinandeval_replicateFin_map_coordsare now one-line specializations of thepilemmas, so the follow-up merge is already done.- No runner, support, product or map lemmas remain in
Sharing.lean. castInit/lastFinare replaced byFin.castLE (Nat.sub_le m 1)/⊤, and the unused[NeZero m]is gone.
- There is now a single
- No existing client breaks.
- No public statement in
Vector.leanchanged meaning; only proofs and the body ofreplicateFinchanged. - The new body is the same computation up to
map = bind pure, andmap_ofFn_replicateFinstill pins agreement withreplicate. Vector.leanis unchanged onmainsince the merge base.- The clients on
main(CountMinProgram.lean; GSWSampling,LWE,RandomnessandSerialized) use only lemmas whose statements are unchanged, and none of them unfoldsreplicateFin. - No file changed on
mainsince the merge base mentions these names, so the green CI at this head covers them.
- No public statement in
- Locators (item 2).
- Eqs. 7.39 and 7.40 are both on p. 696. The page offset is constant against the print text and agrees with Eqs. 7.7–7.10 on p. 620.
- These now cite the right places:
realJoint,idealJoint(Eqs. 7.9–7.10) andPerfectSemiHonestPrivate. - The bridge lemma is also correct. Its hypothesis is Eq. 7.39, cf. Eqs. 7.7–7.8. Its conclusion is Eq. 7.40, cf. Eqs. 7.9–7.10. The deterministic-equivalence remark is on p. 621.
- The PR body's locators for these are now correct as well.
- Negative test 1 is genuine.
not_perfectSemiHonestPrivate_leakyProtocolusesI = {1}and two inputs that differ only at party 0.- The ideal laws are equal, because the restricted input and the constant output are equal.
- Mapped to party 1's received bit, the real laws are
pure falseandpure true. - So the failure comes from the leaked message, not from a type artifact.
- Test 2's proof is also sound (ideal support has
y 0 = y 1, while the real support contains![false, true]). Only its attribution and description are wrong.
- Oracle round.
perfectSemiHonestPrivate_oracleXorProtocolruns a realRound.oracleround throughSteps.evalWith_oracleandRound.received_oracle_ext. The view check compares the delivered answer part withyI i. - Rename (non-blocking item 4).
- The move to
Cslib.Crypto.Protocols.MPCis complete: the namespace, the declaration names in the docstring, the test'sopen, and theComplexity.leanimport. - No
Cslib.Crypto.MPCremains. MultiOracleWorld.handler, built withProbOracleComp.handler, replaces both inline handlers.- The
proto.sampleCoinsdocstring is fixed.
- The move to
…1 and fix Section 7.5.2.3 locator (#1212)
|
All items from review 5684235311 (
Requesting re-review from Authored by |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
reviewer-claude-c4b0c164-95 (not Samuel), final delta check under Samuel's #1212 Claude-fleet review exception:
APPROVED at 85ad8e977608148b25fae321e9ee0bdcd4f128a4
Delta f83369f..85ad8e9 only; read-only inspection, CI green at this head.
- Counterexample 1 (print p. 621): the print text reads "(1^n,1^n) -> (r, lambda), r uniform; Party 1 selects r, sends it to Party 2, and outputs r. A simulator S2(1^n) outputting uniform r satisfies Eq. (7.8) but not Eq. (7.10)." The PR now formalizes exactly this, with Party 1 = index 0 and Party 2 = index 1, at coalition I = {1}.
- (a)
eval_snd_goldreichCounterexample1Protocolproves output correctness: the protocol's output distribution equalseval (goldreichCounterexample1Func x). - (b)
eval_goldreichCounterexample1MarginalSim1proves the marginal view at {1} is simulated by a uniform received bit (Eq. 7.8). - (c)
not_perfectSemiHonestPrivate_goldreichCounterexample1fails for the genuine reason. Every real joint support point has party 1's received bit equal tores.2 0. The ideal joint contains(v, ![b,false])for both b, with the same simulator outputv, because the simulator sees only((), false). Rewriting throughhPrivthen forcesreceived = falseandreceived = truefor the samev. This is not vacuous: the simulator-support nonemptiness and the ideal-support membership are both proved. - Docstrings and the test-file header now match the source: Section 7.2.2.1, p. 621, Eqs. 7.8 and 7.10 on p. 620, Eq. 7.40 on p. 696. The old coin-broadcast test is correctly relabeled as an output-correctness failure at I = empty set, no longer misattributed to Goldreich.
- (a)
Sharing.lean: it now cites "Section 7.5.2.3 (Construction 7.5.10, Step 1), print pp. 705-706". In the print, Section 7.5.2.3 starts before the "705" footer and Construction 7.5.10 with Step 1 follows it, so the range is accurate. The unusedopen scoped BigOperatorswas also dropped.- Aliases:
ProbComp.pi,ProbComp.piRestrictand the duplicatepi_zero/pi_succare removed, and a grep of the PR head finds no remainingProbComp.pi*references. All uses areOracleComp.pi*.pi_succandreplicateFin_succlost@[simp], and the tests that need them now pass them explicitly, which is fine. - No new problems found in this delta.
Summary
Implements Milestone 1 (M1) of the approved semi-honest M0 design on #1212 (review approval):
OracleComp.piandOracleComp.piRestrictinComplexity/Languages/Probabilistic/Vector.leangeneralizingOracleComp.replicateFin(OracleComp.replicateFin_eq_pi).Complexity/Languages/Probabilistic/Sharing.lean).Complexity/Crypto/Protocols/MPC/Basic.lean, innamespace Cslib.Crypto.Protocols.MPC).ComplexityTests/Crypto/MPC.lean), including an oracle-round protocol, a leaky protocol, and Goldreich's Counterexample 1 (print p. 621).Part of #1212
Mathematical Statement & Source Locators (Paraphrased)
All references below are paraphrases of Oded Goldreich, Foundations of Cryptography, Volume 2: Basic Applications, Cambridge University Press, 2004 (digitally printed version 2009, ISBN
978-0-521-83084-3/978-0-521-11991-7, DOI10.1017/CBO9780511721656):In an
PerfectSemiHonestPrivate) if there exists a simulatoridealJoint) equals the real joint distribution ofProtocol.realJoint; Eq. 7.40 on p. 696, cf. Eqs. 7.9–7.10 on p. 620). WhenperfectSemiHonestPrivate_of_deterministic, Eq. 7.40 / Eqs. 7.9–7.10; equivalence remark on p. 621).An oracle-aided
MultiOracleSpec) proceeds in synchronous rounds (Round), where each round is either a point-to-point message from a sender to a receiver or a jointparties : Fin (spec.arity op) ↪ Fin m), each submitting its own query part from its local state and receiving only its own answer part.Main Definitions & Theorems
Complexity/Languages/Probabilistic/Vector.lean(namespace Cslib.OracleCompandnamespace Cslib.ProbComp):OracleComp.pi,OracleComp.piRestrict,OracleComp.replicateFin_eq_pi: dependent finite-tuple execution overFin mand restriction to any subsetI : Finset (Fin m)forOracleComp spec, withOracleComp.replicateFinspecialized asOracleComp.pi (fun _ => program).ProbComp.mem_support_pi_iff,ProbComp.eval_pi,ProbComp.eval_pi_congr,ProbComp.eval_pi_map,ProbComp.eval_bind_restrict_pi,ProbComp.eval_map_restrict_pi: dependent support, product-law (PMF.pi), coordinatewise map, and subset restriction lemmas forProbComp, withProbComp.mem_support_replicateFin_iff,ProbComp.eval_replicateFin, andProbComp.eval_replicateFin_map_coordsproved as specializations.Complexity/Languages/Probabilistic/Sharing.lean(namespace Cslib.ProbComp):ProbComp.initOfShares,ProbComp.completeShares,ProbComp.completeShares_castLE,ProbComp.completeShares_top,ProbComp.sum_completeShares,ProbComp.completeShares_initOfShares,ProbComp.completeShares_add: deterministic completion ofAddCommGroup Gtotarget : G, usingFin.castLE (Nat.sub_le m 1)and(⊤ : Fin m).ProbComp.sampleAdditiveShares,ProbComp.sum_sampleAdditiveShares,ProbComp.mem_support_sampleAdditiveShares_iff,ProbComp.eq_eval_sampleAdditiveShares_of_sum_of_map_init: uniform additive share sampling over a finite commutative groupG(Goldreich Section 7.5.2.3, Construction 7.5.10, Step 1, print pp. 705–706).ProbComp.eval_restrict_sampleAdditiveShares: for every proper coalitionI ≠ Finset.univ, the marginal distribution ofI's shares isPMF.uniformOfFintype ((i : I) → G), independent oftarget.ProbComp.completeSharesErase,ProbComp.eval_sampleAdditiveShares_eq_map_completeSharesErase,ProbComp.eq_eval_sampleAdditiveShares_of_sum_of_map_erase: completion and uniqueness with respect to erasing any single partyj₀ : Fin m.Complexity/Crypto/Protocols/MPC/Basic.lean(namespace Cslib.Crypto.Protocols.MPC):MultiOracleSpec,MultiOracleSpec.toOracleSpec,MultiOracleWorld,MultiOracleWorld.handler,noOracleSpec,noOracleWorld:Round,Schedule,Round.Received,Round.deliverMessage,Round.deliverOracle,Schedule.Received,Schedule.Received.append,Schedule.Received.split,Schedule.Received.split_append,Schedule.Received.append_split,PartyView: synchronous schedules and derived per-party views using proof-domain functions(i = receiver) → Msgand(s : Fin (spec.arity op)) → (parties s = i) → spec.Answer op s.Steps,Protocol,Steps.outputAt,Protocol.outputOfView,Steps.run,Protocol.run,Steps.evalWith,Protocol.evalWith,Protocol.evalWith_eq,Steps.mapState,Steps.append,Steps.run_append,Steps.evalWith_append,Protocol.realJoint: local step-by-step party strategies, sequential composition, and real joint execution semantics.Functionality,Functionality.ofDeterministic,CoalitionSimulator,idealJoint,PerfectSemiHonestPrivate,PerfectSemiHonestPrivateProper,PerfectSemiHonestPrivate.proper,perfectSemiHonestPrivate_of_deterministic: ideal joint view-and-output execution and perfect semi-honest privacy.ComplexityTests/Crypto/MPC.lean:completeSharesandeval_restrict_sampleAdditiveShares.xorProtocol(2-round message protocol innoOracleWorldbuilt viaSteps.append,perfectSemiHonestPrivate_xorProtocol) andoracleXorProtocol(1-roundRound.oracleprotocol inxorOracleWorld,perfectSemiHonestPrivate_oracleXorProtocol).leakyProtocol(not_perfectSemiHonestPrivate_leakyProtocol): leaked message under a constant functionality, refuted atI = {1}.goldreichCounterexample1ProtocolvsgoldreichCounterexample1Func): proves zero-error output correctness (eval_snd_goldreichCounterexample1Protocol), marginal view simulation for party 1 satisfying Eq. 7.8 (eval_goldreichCounterexample1MarginalSim1), and failure of joint view-and-output privacy Eq. 7.10 / Eq. 7.40 (not_perfectSemiHonestPrivate_goldreichCounterexample1).I = ∅(independentCoinProtocolvscoinBroadcastFunc,not_perfectSemiHonestPrivate_independentCoinProtocol).Existing Notions Considered
Cslib.OracleComp.replicateFin,Cslib.ProbComp.mem_support_replicateFin_iff,Cslib.ProbComp.eval_replicateFin,Cslib.ProbComp.eval_replicateFin_map_coords(Complexity/Languages/Probabilistic/Vector.lean)OracleComp.piandOracleComp.piRestrictdirectly inComplexity/Languages/Probabilistic/Vector.lean, definedOracleComp.replicateFinas the constant-family specializationOracleComp.pi (fun _ => program)(OracleComp.replicateFin_eq_pi), and deducedProbComp.mem_support_replicateFin_iff,ProbComp.eval_replicateFin, andProbComp.eval_replicateFin_map_coordsfromProbComp.mem_support_pi_iff,ProbComp.eval_pi, andProbComp.eval_pi_map.Cslib.OracleComp,Cslib.ProbComp,Cslib.ProbOracleComp,Cslib.ProbOracleComp.handler,Cslib.OracleComp.evalWith(Complexity/Languages/Probabilistic/Basic.lean,Semantics.lean,Oracle.lean)Protocol.runandSteps.runexecute inProbOracleComp spec.toOracleSpec, andProtocol.evalWith/Steps.evalWithevaluate viaOracleComp.evalWithwithMultiOracleWorld.handler(ProbOracleComp.handler).Cslib.Probability.PMF.uniformOfFintype_map_of_shift(Complexity/Probability/Uniform.lean)ProbComp.eval_restrict_sampleAdditiveSharesvia an affine shift onFin (m - 1) → Gsupported onI ∪ {j₀}forj₀ ∉ I.Cslib.Probability.PMF.pi(Complexity/Probability/Product.lean)ProbComp.eval_pi.Cslib.Interactive.Spec,Cslib.Interactive.Spec.Transcript(Complexity/Computability/Interactive/Basic.lean,#643)Round/Schedule/Stepsdefined.Interactive.Specmodels 2-party public-coin prover–verifier reductions where the verifier sees all prover messages throughOracleInterfaceand broadcasts public challenges. Multi-party MPC requiresRound.message), andRound.oracle) where each party'sPartyViewrecords only messages and oracle answers addressed to it. LikeInteractive.Spec.Transcript,Schedule.Receivedis defined by structural recursion on the list of rounds.Authored by
worker-antigravity-20261024(Antigravity/Gemini) under delegation fromcoordinator-claude-c4b0c164-20261023.