Skip to content

Commit 817ef8b

Browse files
MagicalTuxclaude
andcommitted
mldsatss: per-party round-3 response validity for identifiable abort
FIX 2 (Low). combine() previously summed every party's z_i block unconditionally with no per-party validity check, so a single malicious party could submit garbage z_i and force ErrAllTriesRejected for the whole committee with no attribution (a silent DoS). Add validatePartyResponses(), run before aggregation in combine(): each party's non-zero z_i block must satisfy the L-part of that party's own rejection gate, i.e. its nu-scaled L2 norm Sum_L (z_i[j]/nu)^2 must not exceed Rp^2. An honest party either rejects a try (all-zero block, passes trivially) or accepts it (block came from a zf that passed !zf.Excess(R, nu), so the L-part alone is within R, and rounding stays inside Rp). Gross garbage (the DoS vector) exceeds Rp^2 and is rejected with *ErrPartyResponseInvalid naming the offending committee slot and keyId. PARTIAL: this is a structural bound, not a full algebraic check. A full identifiable abort would verify HighBits(A*z_i - c*t_i) == HighBits(w_i) against the committed w_i, which needs each party's public key share t_i = A*s1_i + s2_i. This trusted-dealer protocol never transmits or stores t_i (only the aggregate t1 is public), so a small-but-wrong z_i that passes the bound still surfaces as the non-attributable ErrAllTriesRejected. Closing that gap requires publishing per-party t_i or a per-party commitment/proof binding z_i to w_i. Adds TestSigning44_InvalidResponseIsAttributed: a party broadcasts a saturated garbage z_i and the honest combiner returns *ErrPartyResponseInvalid naming its slot rather than ErrAllTriesRejected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8dd909c commit 817ef8b

2 files changed

Lines changed: 187 additions & 0 deletions

File tree

‎mldsatss/signing.go‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,29 @@ func zeroizeNttVecK44(v *[mldsa.K44]mldsa.NttElement) {
4545
// Combine-side correctness). Callers should retry with a fresh attempt.
4646
var ErrAllTriesRejected = errors.New("mldsatss: all tries rejected; retry")
4747

48+
// ErrPartyResponseInvalid is returned by combine when a specific party's
49+
// round-3 response block fails the per-party validity check. Unlike
50+
// ErrAllTriesRejected (a non-attributable retry signal), this error names the
51+
// offending committee slot so the abort is identifiable. The caller should
52+
// drop/penalize that party rather than blindly retry.
53+
//
54+
// NOTE: the check this error reports is a *partial* identifiable-abort check
55+
// (a structural L2 bound on each z_i, mirroring the L-part of the party's own
56+
// rejection gate). A full algebraic check — verifying A·z_i − c·t_i matches
57+
// the committed w_i — requires each party's public key share t_i = A·s1_i +
58+
// s2_i, which this protocol never transmits or stores. See validatePartyResponses.
59+
type ErrPartyResponseInvalid struct {
60+
Slot int // committee slot of the offending party
61+
KeyId uint8 // Key44.Id of the offending party
62+
Try int // which of the K tries failed
63+
Cause string // human-readable reason
64+
}
65+
66+
func (e *ErrPartyResponseInvalid) Error() string {
67+
return fmt.Sprintf("mldsatss: invalid round-3 response from committee slot %d (keyId %d), try %d: %s",
68+
e.Slot, e.KeyId, e.Try, e.Cause)
69+
}
70+
4871
// Parameters bundles the session configuration for a threshold ML-DSA-44
4972
// signing run.
5073
type Parameters struct {
@@ -565,6 +588,17 @@ func (s *Signing44) combine() {
565588
}
566589
params := s.params.thParams
567590

591+
// Per-party response validity (FIX 2 — identifiable abort). Before summing
592+
// every party's z_i unconditionally, range/bound-check each party's block.
593+
// A malicious party that submits garbage z_i (large coefficients) would
594+
// otherwise corrupt the aggregate and force ErrAllTriesRejected for the
595+
// whole committee with no attribution (a silent DoS). On failure we name
596+
// the offending committee slot instead of silently summing.
597+
if err := s.validatePartyResponses(); err != nil {
598+
s.fail(err)
599+
return
600+
}
601+
568602
// Aggregate zfinal[try][j] = Σ_{slot} z_try_from_party[j]
569603
zfinal := make([][mldsa.L44]mldsa.RingElement, params.K)
570604
for slot := 0; slot < int(params.T); slot++ {
@@ -704,6 +738,71 @@ func (s *Signing44) combine() {
704738
s.fail(ErrAllTriesRejected)
705739
}
706740

741+
// validatePartyResponses checks every party's round-3 response block for
742+
// per-party validity *before* combine sums them, so a single malformed/
743+
// malicious z_i is attributed to its sender instead of silently corrupting
744+
// the aggregate (FIX 2 — identifiable abort).
745+
//
746+
// Derivable check (strongest available from public values at combine time):
747+
// an honest party either rejects a try (sends an all-zero z_i block, which
748+
// passes trivially) or accepts it, in which case its z_i is the L-part of a
749+
// hyperball-masked response zf that passed the party's own gate
750+
// !zf.Excess(R, ν), i.e. Σ_L (zf_L[j]/ν)² + Σ_K (zf_K[j])² ≤ R². The L-part
751+
// alone therefore satisfies Σ_L (z_i[j]/ν)² ≤ R²; integer rounding adds at
752+
// most √(L·N)·0.5/ν ≈ 5.3 to the ν-scaled L2 norm, comfortably inside the
753+
// secondary radius Rp (Rp − R ≥ 55 across the whole parameter table). So we
754+
// reject any non-zero z_i block whose ν-scaled L2 norm exceeds Rp — an honest
755+
// accepted block never does, while gross garbage (the DoS vector) is caught
756+
// and its sender named.
757+
//
758+
// LIMITATION (partial identifiable abort): this is a structural bound, not a
759+
// full algebraic check. A full check would verify HighBits(A·z_i − c·t_i) ==
760+
// HighBits(w_i) against the party's committed w_i, but that needs each party's
761+
// public key share t_i = A·s1_i + s2_i, which this trusted-dealer protocol
762+
// never transmits or stores (only the aggregate t1 is public). A party can
763+
// thus still submit a small but algebraically-wrong z_i that passes this bound
764+
// yet breaks the aggregate; such a case still surfaces as ErrAllTriesRejected
765+
// (non-attributable). Catching it would require publishing per-party t_i (or a
766+
// per-party commitment/proof binding z_i to w_i), which is out of scope here.
767+
func (s *Signing44) validatePartyResponses() error {
768+
params := s.params.thParams
769+
nu := params.Nu
770+
rpSq := params.Rp * params.Rp
771+
772+
for slot := 0; slot < int(params.T); slot++ {
773+
resp := s.r3resps[slot]
774+
off := 0
775+
for tryIdx := 0; tryIdx < int(params.K); tryIdx++ {
776+
var l2 float64 // Σ_L (z_i[j]/ν)² for this try's block
777+
nonZero := false
778+
for j := 0; j < mldsa.L44; j++ {
779+
poly := mldsa.UnpackZ17(resp[off : off+mldsa.EncodingSize18])
780+
off += mldsa.EncodingSize18
781+
for c := 0; c < mldsa.N; c++ {
782+
// Recenter to a signed magnitude in [0, Q/2].
783+
mag := float64(mldsa.InfinityNorm(poly[c]))
784+
if mag != 0 {
785+
nonZero = true
786+
}
787+
scaled := mag / nu
788+
l2 += scaled * scaled
789+
}
790+
}
791+
// An all-zero block is a legitimate "try rejected at party"; only
792+
// bound-check blocks that actually carry a response.
793+
if nonZero && l2 > rpSq {
794+
return &ErrPartyResponseInvalid{
795+
Slot: slot,
796+
KeyId: s.params.keyIds[slot],
797+
Try: tryIdx,
798+
Cause: fmt.Sprintf("z_i ν-scaled L2 norm² %.0f exceeds Rp² %.0f", l2, rpSq),
799+
}
800+
}
801+
}
802+
}
803+
return nil
804+
}
805+
707806
// --- helpers ---------------------------------------------------------------
708807

709808
// validateCanonicalWbuf unpacks a peer-supplied packed-w buffer one polynomial

‎mldsatss/signing_test.go‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ type hubBroker struct {
2626

2727
type testHub struct {
2828
brokers []*hubBroker
29+
// mutate, when set, is invoked on every message a broker forwards to its
30+
// peers (i.e. on each outgoing broadcast). It may rewrite msg.Data in place
31+
// to model a malicious party. It receives the sender's broker index.
32+
mutate func(fromIdx int, msg *tss.JsonMessage)
2933
}
3034

3135
func newTestHub(n int) *testHub {
@@ -58,6 +62,9 @@ func (b *hubBroker) Connect(typ string, dest tss.MessageReceiver) {
5862

5963
func (b *hubBroker) Receive(msg *tss.JsonMessage) error {
6064
if msg.From.Index == b.partyIdx {
65+
if b.hub.mutate != nil {
66+
b.hub.mutate(b.partyIdx, msg)
67+
}
6168
if msg.To != nil {
6269
return b.hub.brokers[msg.To.Index].Receive(msg)
6370
}
@@ -252,3 +259,84 @@ func TestSigning44_BadContextMismatch(t *testing.T) {
252259
require.False(t, pk.Verify(sig, msg, []byte("ctx-B")))
253260
require.False(t, pk.Verify(sig, []byte("other msg"), []byte("ctx-A")))
254261
}
262+
263+
// TestSigning44_InvalidResponseIsAttributed exercises FIX 2: when one party
264+
// broadcasts a garbage round-3 response (a z_i block with grossly out-of-bound
265+
// coefficients), the combiner at every honest party must IDENTIFY that party
266+
// (returning *ErrPartyResponseInvalid naming its committee slot) rather than
267+
// silently summing the garbage and surfacing an unattributable
268+
// ErrAllTriesRejected.
269+
func TestSigning44_InvalidResponseIsAttributed(t *testing.T) {
270+
var seed [32]byte
271+
seed[0] = 0x99
272+
tParams, err := GetThresholdParams44(2, 2)
273+
require.NoError(t, err)
274+
pk, keys, err := TrustedDealerKeygen44(seed, tParams)
275+
require.NoError(t, err)
276+
_ = pk
277+
278+
signers, _, keyIds := buildCommittee(2, 2)
279+
msg := []byte("identifiable-abort test")
280+
ctx := []byte("ctx")
281+
282+
// The malicious party is committee slot 1 (broker index 1). Its round-3
283+
// Resp is overwritten in-flight with an all-max-coefficient block, whose
284+
// ν-scaled L2 norm vastly exceeds Rp² — the strongest case the partial
285+
// per-party check catches.
286+
const maliciousIdx = 1
287+
respLen := int(tParams.K) * mldsa.L44 * mldsa.EncodingSize18
288+
289+
hub := newTestHub(len(signers))
290+
hub.mutate = func(fromIdx int, m *tss.JsonMessage) {
291+
if fromIdx != maliciousIdx {
292+
return
293+
}
294+
if m.Type != (&Parameters{attemptID: 0}).msgType(MsgTypeR3_44) {
295+
return
296+
}
297+
// Build a fully-saturated garbage response: every coefficient = γ1,
298+
// which packs/unpacks cleanly through Z17 but blows the L2 bound.
299+
var maxPoly mldsa.RingElement
300+
for c := 0; c < mldsa.N; c++ {
301+
maxPoly[c] = mldsa.FieldElement(mldsa.Gamma1Pow17)
302+
}
303+
garbage := make([]byte, 0, respLen)
304+
for tryIdx := 0; tryIdx < int(tParams.K); tryIdx++ {
305+
for j := 0; j < mldsa.L44; j++ {
306+
garbage = append(garbage, mldsa.PackZ17(maxPoly)...)
307+
}
308+
}
309+
m.Data = &signRound3msg44{Resp: garbage}
310+
}
311+
312+
p2pCtx := tss.NewPeerContext(signers)
313+
sigs := make([]*Signing44, len(signers))
314+
for i, pid := range signers {
315+
params, perr := NewParameters(pid, p2pCtx, tParams, keyIds, hub.brokers[i])
316+
require.NoError(t, perr)
317+
params.SetAttemptID(0)
318+
key := keys[keyIds[i]]
319+
s, serr := NewSigning44(context.Background(), params, key, msg, ctx)
320+
require.NoError(t, serr)
321+
sigs[i] = s
322+
}
323+
324+
// The honest party (slot 0) receives the malicious slot-1 response and must
325+
// attribute the abort to slot 1. (The malicious party itself sees its own
326+
// genuine response, so we only assert on the honest victim.)
327+
deadline := time.After(30 * time.Second)
328+
select {
329+
case <-sigs[0].Done:
330+
t.Fatalf("honest party unexpectedly produced a signature from garbage input")
331+
case err := <-sigs[0].Err:
332+
var pe *ErrPartyResponseInvalid
333+
require.ErrorAs(t, err, &pe,
334+
"combiner must return *ErrPartyResponseInvalid, got %v", err)
335+
require.Equal(t, maliciousIdx, pe.Slot, "must name the offending committee slot")
336+
require.Equal(t, keyIds[maliciousIdx], pe.KeyId, "must name the offending keyId")
337+
require.NotErrorIs(t, err, ErrAllTriesRejected,
338+
"must not be an unattributable ErrAllTriesRejected")
339+
case <-deadline:
340+
t.Fatal("honest party timed out")
341+
}
342+
}

0 commit comments

Comments
 (0)