Skip to content

Add LargeZNorm disposition for ML-DSA sigVer - #464

Open
Arpan0995 wants to merge 1 commit into
usnistgov:masterfrom
Arpan0995:add-mldsa-largeznorm-disposition
Open

Arpan0995 wants to merge 1 commit into
usnistgov:masterfrom
Arpan0995:add-mldsa-largeznorm-disposition

Conversation

@Arpan0995

Copy link
Copy Markdown

Implements the LargeZNorm item from the TODO discussed in #462.

Why a mutation cannot cover this

The existing "modified signature - z" disposition mutates an existing signature. Any change to z also changes w', so the commitment hash rejects the signature even in a verifier that omits the ||z|| check entirely. Across the current 180-case sigVer file, removing the ||z||inf < gamma1 - beta check from a verifier changes zero outcomes. The check needs a signature that is valid everywhere except the z bound, and only the signer can produce one.

What this does

  • DilithiumLargeZNorm derives from Dilithium and overrides Sign with the z half of the rejection step inverted: it keeps only candidates where ||z||inf >= gamma1 - beta, while the r0, ct0 and hint conditions stay in place. The signature remains internally consistent, so the commitment hash comparison in Verify passes and the ||z|| bound is the only condition that rejects it.
  • Candidates with a coefficient outside [-(gamma1 - 1), gamma1] are skipped, since SigEncode cannot represent them; the emitted signature round-trips through SigEncode/SigDecode exactly.
  • About 40 percent of candidates land out of bound (as estimated in the issue thread), so the loop terminates after a few iterations; measured convergence is 5 to 6 iterations per signature.
  • New disposition invalid signature - z norm too large wired through MLDSASignatureDisposition, the sigVer expectation provider (three occurrences per group, matching the existing reasons), and the sigVer grain across all four interface paths (internal, externalMu, external pure, external pre-hash).
  • One change to existing code: Dilithium.SignExternalMu is marked virtual so the derived signer covers the externalMu path. Sign was already overridable.

Verification

  • New unit tests, per parameter set: the emitted signature has ||z||inf >= gamma1 - beta and fails Verify; re-deriving the commitment hash the way Algorithm 8 does reproduces the c_tilde carried in the signature, so the z bound is the only failing check; and the signature round-trips through SigEncode. 9 tests, all passing.
  • Existing Dilithium test suite: 209 passing, 0 failures.
  • ML-DSA sigVer generation tests: 26 passing, 0 failures.
  • Cross-checked against an independent Python implementation of FIPS 204 written from the standard text: 12 signatures produced by this signer (all three parameter sets) are rejected by a conformant verifier with the z bound as the only failing condition, and are accepted by the same verifier with the z check removed. That last part is the property the disposition exists to test, and it is the acceptance test proposed in ML-DSA sigVer "modified signature - z" vectors modify the hint block instead of z; the z-bound check is never exercised #462.

The sample json files are not regenerated here, per the note in #462 that the corner-case database and sample generation live on the internal side.

The "modified signature - z" disposition mutates an existing signature, and
any change to z also changes w', so the commitment hash rejects the signature
even in a verifier that omits the ||z|| check. The ||z||inf >= gamma1 - beta
bound in FIPS 204 Algorithm 8 was therefore never the deciding check for any
published test case. Discussed in usnistgov#462.

DilithiumLargeZNorm derives from Dilithium and overrides Sign with the z half
of the rejection step inverted, keeping the r0, ct0 and hint conditions in
place. The signature stays internally consistent, the commitment hash
verifies, and the ||z|| bound becomes the only condition that rejects it.
Candidates with a coefficient outside the [-(gamma1 - 1), gamma1] range that
SigEncode can represent are skipped so the signature round-trips. Roughly 40
percent of candidates have ||z|| out of bound, so the loop terminates after a
few iterations.

The sigVer grain re-signs with this signer for the new disposition across all
four interface paths, and the disposition is drawn three times per group like
the existing reasons. SignExternalMu is marked virtual so the derived signer
covers the externalMu path.
@KurathSec

Copy link
Copy Markdown

Supporting this, with a measurement of what the current set reaches and a test
vector for the disposition being added.

The gap this closes is total, not partial

Running a predicate battery over every signature-bearing ML-DSA case in the
shipped corpus, 1260 of them across sigGen, sigGen-tr1 and sigVer: none
violates ||z||_inf < gamma_1 - beta at any of the three most recent releases
c924096a71e5, ad33b3d95044 or a7f283cdc87d.

We confirmed that by mutation rather than by counting. Neutralising the bound in
mldsa-native:

-  if (mld_polyvecl_chknorm(z, MLDSA_GAMMA1 - MLDSA_BETA))
+  if (0 && mld_polyvecl_chknorm(z, MLDSA_GAMMA1 - MLDSA_BETA))

and replaying the full mandated set leaves every verdict unchanged. A verifier
that omits this check passes. The sentinel mutant on the same arm, neutralising
the commitment hash comparison, is caught, so the harness is capable of seeing a
difference.

The reason is the subject of #462: the ModifyZ disposition writes into the
hint block rather than into z, at all three parameter sets.

A vector for the new disposition

Since a surviving mutant can always be explained by the mutant being equivalent
to the original, we constructed a case that separates them. A second
producer-side mutant, with the rejection sampling bound removed from the signing
loop, emits signatures the standard forbids. For ML-DSA-44:

  • max|z_i| = 131009, against the bound gamma_1 - beta = 131072 - 78 = 130994
  • the commitment hash is correct and the hint block is well formed, so the
    signature violates this clause and no other
  • the pristine mldsa-native verifier rejects it
  • the same build with the norm check neutralised accepts it

That last pair is the property a test vector for LargeZNorm needs: it fails
only for the reason the disposition is named for. Full key, message and signature below.

It might be worth asserting the same property inside the generator, so a
LargeZNorm case cannot be emitted unless max|z_i| >= gamma_1 - beta actually
holds. The disposition being replaced looked correct by inspection and was not.

Two neighbouring members

While reading MLDSASignatureDisposition we noticed that HintCheck and
CommitmentHash carry the same marking LargeZNorm does, stating they are
covered by the modify signature and modify message dispositions. For the norm
bound that is not the case, as above. The other two may be worth re-checking on
the same basis; we have not measured them to the same standard and are not
claiming they are wrong.

Witness for LargeZNorm, ML-DSA-44 (JSON, 6.7 KB)
{
  "param_set": "ML-DSA-44",
  "bound": 130994,
  "max_abs_z": 131009,
  "pk": "C0BA660E95EE71D5132A47087DA7334874D592E38064B564FF371ED06577DAC6A9D2B4A67F79FFE6E9BD050DC5CE6B6D11E739018179EAB56ABF29BC0EEBFF4AAFB8D3A867EEBFC9DD306E807D6C88D6CF5B265C7A0839AA8B4B73D6750466023EC799A020586BDC59866D6E277A3350B5BBCD9C483A522195E7A31A20F8A2F8936E447C20675C68921ECE4C268292253810223419B2E9B0713020E1B075C9D3D82C9A60E9226619D6432516DF9448CDBBC6A504DBA3380E5CEC3E119D98AEFF9CEF6EC4BB769981EB9C81731493ED093251D43B4219572C88636BEFF37DE125352F73F0EE2A4F016508FD6EF9D7131EEB9562AEB76C5B023E540227086350F736ADA31FD71D722D708A2F037590467E97EADE060A2C30F06E62DCA034DEE936A9FCEAA29F0AEAA71DCFC89CD3B0959D386A94658A986E7E4713D2E5893367E122E5617A1487C7B65C7D310E2CCACCCC3D3A71F1BF420EF676A24CC99E7C0C4DACD3C193D75F9CBDB0B1688A1D13468CFACD2F60EC025DD1B99FF53F2A8FE708D30D1EB285DCD54ECD7203F94ADA5105C64B6C676EBECB1C637752F252D8210D7A592EA5EF513F0D94D4EA55F29BA461AC0FDC4E5016B893AD45E50426C2151A6251CD29415FB008A70F01B615E2FD2EC0229C4C8C90258B14877ACC42E7ECCCB3712E77234E3B3D088F55E8CCA2FD8C076C80D20ABA08244753493CFBB485E1B2C2DF82AD06227D10A6B4498AEF7FDC79D86D445EB629E07E8DEB179A5735DD39901EE4D41B94FFAC0C5C73C03D4CBADA664D4FF055FAC48AEA4D19889EDC86E9CCD28FAADA599F9B30FDF190B4162AF05A93E17B062167FFA5CE8B67686AE14FC35816D9C70DE9A60860528ED2E88000CE768260D61F0C79A6FEBEE9D37BB02CA37E4CDA4A1C4C0F3C7EB501B1EE189074C10C3501C8CA708DBA83836E25F01DAA4749B107B947149C3390803931F6B7DE1F3EE49F835A51232D9CF026DF0F4C3413995B2E2930E3AE3E959B25566912B4DA40E84C3EE21195C4D5662F24BDA3F80969E8BDB5F91230E58F9B484BE898B383D80454D5DAF599609D0086143F4B6310926FA9F0EF66AB1B7E127DD5E7B8A4A81DE92E2A38AF44DDE677C6B71C7E2336E58E89BEEBA49AEA917A086C90919378BF0F80471B677171B9A0FA06C63331F4E9E69EA093F77FF7A1ECD30440541E0115F0ECF90F25851BFDBA173CAD987F43578C98270C1FD4A6EB6900A1E8BC23EE88C68E6AA8D29B81CE91F01A618D9133D152191D98BAFB8BFCF21F33FFAAB69B8C8997754623C8A9CF36CB80B3358FA79EC917364218A2A0852F15AF01C28713F1C2A51E485039A4930D5083C65C1F8F3C098C8193718DF0D564F449DD380108980085946CB8BF1889652787347CBAA4B2ADE2B6E2917906FA9DB4C589C6E241049F44D0308417B13D2455A9B6C0FA0D128545670B10A011D4AE0927FD3906E054C3AD52D2954DA8881331683E57E696895602E8C22D77F15DEAC4ABFF24A490B3FE0A745FC88750B1C36FD1478D3113DEC20FAF1A85A9A54C9011E6CC75AC4183567A00907690023AAEA2F46AC925BE5D9817646122F815F918E31E5FA7D3E7EFE0ADE3B1B97802FAA866DDD61E40EF4525A8432E8181EA8D81F52B13C91D19061C0F532FCA65C34BBAAAEC1FB5FD6423FAD30676B77E85D609381A99DFE980A929744E0E708AF300D5243FA97EFA3A3762913DE7B815C9A97CE4E53247D987ECCD3C292D294D4FDCCA3C40F7217DDDB15C64A384FCAA4F8E02BC448BECBDFA707CFB4E986F9073F716163498C0137C5B675DB525E081F682F339B9B9E1D238D1DD9C2090EAD0ADD3F126059E",
  "message": "1ae71e21712e23f2b6d142df50ed82064b589d19db88f105fcf9b52acd8b4123",
  "context": "",
  "signature": "264E84644BD8B9CC33EA6FE2F0353EF7FCCD96E930BE2011D6ED9DFD95893A28CF6521404646095327BB2CEC4AF420CDE6B163CACD60FF607D102DB9C50A00E464F031C0AB1EADC577752C67599F05E1AA9F0AA4CDB8D5E7236C1B2FC279617AC3ADDA6E59F2D48A4FDF74A21080952D5B0773F62534EA34D45B86D13D823C3561F9567DFE3E111F779EF5D0DF7B25E5CF49A38A4F9CCEAB7C0860E5B178EEC98C570EC0345866551694A62A8AA080E1E73D209D9B12ADC5D82F897602A3C0F7F487B2A274670150E1125769C5907BD7EC0498B4DE2B3A9A90BB72C0E6809F550DB16660AF760499721DE914EB740968BDB720F3AABB2422A76D9546C2CDC8DA6BD0D9F2B090364931B9E69484563C74A70E32FB945AE6A002A06B64FD7253116DDCD9A6AF328B101E19AD7BE87C560A77802268CE3B4CBB7A1166F1C02DF7FB8393D1809E8B41B2ECCA3E7C4AAF9883B5956046FFEC527840E5CCF14A56C2BF4378E4566B2EAF2E0DECCFE762B42B2039E01D1C31DED6BD2473326053BEE5D0A4F13EF99A03BA90E8B85B787D2594C1832133AB1A20A682A5B9537AFD001081FDAA4870713906057ED68DA7C09D3C7030CC1A5F4C111308989B1610E28CE1CE0001CA54339FE9F168B59AA5AABFD777EE81A61174227212629EFAB4BDF8191CF335D9E73EA0A9FF118C9BBE84DB9A1CA0D4116264C6D595EE05AB729EF35753196263E109431570DF2CDD84EA7796B88146F9B6835E55C2DD30548BA53E30E42356DFC279A902774B557891A6BB74617CAA0FC01368DB9C7D678A0AA749304E861D7009B5CD1203667116A2FE6617255D5793D0C4C941E4F72B95D68B1C8BD5499EC332227889C9E468CEF51CF3428BC2D1792129B628BCCB47D3B58C1F46BB60C1136CF4D0866B2175699C124AAFEA2F27A759F417E8C2D66E2437971BB13698039414E6E578263A0ECDACD15B7141FEFF7F7564A975FCFBD2ABACBCDB4EB28B71607C032C2AB28B2B3894D51B1EEE04BF01D943624897FB508299EBB63D9161FD8A14ECB756BD7F839CC3C09792F8C77A239290C8D060B14F07892B84C46ADA2D537745C60767353A8566B580FCBD1A2F2094986A481A5ECA8DFC4DECB514DA351F5C57079969564054C5C3CD33C55221E71FFD41E18F69F28B249DEDAB4597CE2C5D94558EAE39C3C93EFCBFE7BE7AA76E27DE49EE48821E94F1826CF63B06C1B9A5D5397376F5F8D2B965B1CFB98549D7902A36BC7C1C46DAD375995E8BCC841D553B547B0CB08FF190DF69CA8B657F0DE1E961AC1EC8365937846CD649658698A0121BDD58C27EFA437128C74DAAB311A74554F2C8B7F3E4A7CDC203DCD645B39BA2C8D3BE002F4A74F12641367A2363548B1A80B4EF959D41721B801893810CB81616AB59B0803A28ACC2C809938A66682E5B8B3F0503EFDDCD437CFFE5B2772796A97FDCD083F87AD6CDA2A72084D121F7663169796FF7D16C178B86B7F590718E21CEA933965C81F89D52FAAED10A866F823C4F8E95AD7C50F7F1220AB52835751FB74A5276D04ABCEBC8CDA06245C3AF4CD10DBC0E14A7435F557E799C4615D6B57AF5F2F6F38D9A045EE18CBD5079FDB1DDDEF7719D344588F10BE7BB756A311A348514BFC390FC174E37BCD14846A09DE12984A1DE6416494FD52094B7B65E0BF962AD00AB8978D7F393769948C473776D100CB8586EEDF49E05169B4BCF3B000BEA8C0D271A8CFA12D2827444B6C0436795AE2EBB0D4040CE2267A6021FC1A1B72450C60E5EB5F8960B6401528A16B22007B50218A6DDFC705BCCEF7A54B3B8D525DACC104C632B0934B1B3E644A3E563F20100F4E2E37EEEB354C8CB309109824B22BD90CED462F44B4E1C4AAE482D055E210E90CCC92E13C1C2DC8D0F11DD199C312CAB1029EBCB5DAFF3B8C163EA7B4C2F08FD2AD3E4DCB6849B8C06AF12E04D64488D23150F8F8775F7BCDDBB1E421173D7316A6ABE185A1BA4D9F9E870B6C3697E95FBD81A3963C9C1C20640EF59A4685C1AF0A9F09921431B1CFA6A886348BEE0C6BC3DD37E62BC06F0E8ADAEF744509067C13F6E213FFBE277D74A8AEF05BC2F9B8FBA77689127F5CFDBD894376E702C581A0793848683ACD469A52B13FEC2FDA2A43197A98E62B95F752A98A2673D170ADD57340723FD92E71BF951230F74C8CBE3A1E1BA63494986C6769040FF77F8CAD8B7C75D34E9D10F4C6A275850A53B91CD742C114AC91BFC6F6C221B0AD881938C586362E296CC2F1CF67C8D500B124027A46D6D16D868FFDD33C00B92C43BC8C258549024FE5780FF873AAA9DB474FA1C9A24F5B259A7B71B95B880EEAEE9EE5E3C471AB1C3A95924499B90727D789B24F664F107A889F17865D9A5A05F7FAC13DC48C87E06027DB07E5E43AB0EE7811C5CCAA658D1A4D854F45F8EF030BDF995A56AB63A67C4BE03126FDF60AFE9F096E932465BF876CA6C4074E7AE1EEE6C6EE20FB0AD4D7465DFAAD58904B72C22286708C4FE22346B485EA039CCEC9553F8F38C85EE58CB42816011A954336EEC41431446063949FE7CC511D86B29484996D48F9DF2DC869D33E37FDAA1D942961427A0EB9F8C412C69C1391CD4BAA3B02C6F4D40B3EE16E9196E2B5C7D5F67A56AAAEF59BC7DCEFD86409168457E5F3BF6CA3711114AB64117958ED07BD5BAEF2A918DE9D144210EF4EA18D708DBCA54631F8AA20BE20DCA579015E5C0C1C986D3E21EC3E2242C3648CFEE1E5D2C31A6AA4F15070CDA06C59539A83572C89CF972993C7CB0CDF09D6B4AA41E389440096353C9E504640B07BCBDAA2F343E418B8FB7449A1879BECAC5C163A665267B772A35D2668E02F04CE6F76A7F06018A50CA5435E7DDCFDECB85E60B547062666F277112FE6F7A0A94C1DC857A2A5E3B9A2145E47D01F556843BA23778ACAB3784041822C3F6379E584F70105AB086858DD31039F6F71E1A012B967B25CA12F71EA9765EEB68C3E34E078AAA00DD801CC3F98C2CE28BB7D20CE4A86EC28D563A3C9EC38E322216075C69860B4099C4E9071596BC861FDE5BD6ACE021D3DDBD37B4C8DA6589407BD0831EFB9A8A6820C2561B3D64DD88FC1BF3AEB943E71379CEC422E73376B6509519273995822ECA0B3890E10B69BBEEEB0741443DC7E219E545AEC79DC757B25CE7A1673A02CAB5D33D628608E5192450E7DA0D9F8E9B5B21C1D14531AFBCD0D4BA69C3694023D55F70EC2EB30C0C3D64650E4F713E04607DE7D91AD9C2CDEB2F64DCDCAEF95708EAD3212E4A9545B780DF52FF873B258C3FBC14E57FCC2F0405070E1125363E494B5F778BA5A7C4D7E0EFF21A3540474C5B5F708B98B3CFD8DDEBEDEEEFFA09303142434E587184879194D2F302263850535D60697886879DBDD4DCEBF4F6FE000000000000000014273548",
  "pristine_verdict": "reject",
  "mutant_verdict": "accept",
  "method": "dual producer-side mutant: z bound stripped from the signing loop",
  "note": "Produced by the dual producer-side mutant: the z bound removed from the signing loop's rejection sampling. c-tilde is correct and the hint is well formed, so the signature violates this clause and no other."
}

@Arpan0995

Copy link
Copy Markdown
Author

Thanks, this is a good independent check to have alongside the PR.

I ran your ML-DSA-44 witness through the from-spec FIPS 204 verifier I wrote for this (from the standard, nothing ported). It decodes to max|z_i| = 131009 against gamma_1 - beta = 130994, the commitment hash recomputes correctly and the hint block is well formed, so it fails the norm clause and nothing else, and the same verifier with that one check disabled accepts it. That lines up with your pristine-rejects, mutant-accepts result, so your C verifier and this Python one agree on the witness, and the C# signer in the PR produces the same kind of case by the same method.

We also landed on the same construction independently: the PR generates these by removing the z half of the rejection from a signing loop, exactly your dual producer-side mutant, keeping the r0, hint and ct0 conditions so the rest of the signature stays consistent.

On asserting the property in the generator, the PR does that in its tests rather than by inspection: for each parameter set it checks that the emitted signature has ||z||_inf >= gamma_1 - beta and that the commitment hash still verifies, so a case cannot pass the tests unless it fails on the norm and only the norm. Happy to lift that into a runtime assertion on the disposition as well if that reads better.

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.

2 participants