Skip to content

ml-dsa: Don't use tr pointer - #606

Merged
armfazh merged 2 commits into
mainfrom
bas/600
May 6, 2026
Merged

ml-dsa: Don't use tr pointer#606
armfazh merged 2 commits into
mainfrom
bas/600

Conversation

@bwesterb

@bwesterb bwesterb commented May 6, 2026

Copy link
Copy Markdown
Member

Closes #600

bshastry and others added 2 commits May 6, 2026 11:05
…KeyFromSeed

Previously the PublicKey returned by (*PrivateKey).Public() and
NewKeyFromSeed cached tr as a pointer aliasing sk.tr. As a result,
any later mutation of sk.tr -- for example via a subsequent
(*PrivateKey).Unpack on attacker-controlled bytes -- silently
propagated into a pk that had already been returned to the caller.

Switch both sites to a value copy. The returned pk now holds its own
[TRSize]byte and is independent of subsequent changes to sk.

Refs: #600

Edited in sign/dilithium/mode3/internal (master); regenerated to
mode2/5 and sign/mldsa/{mldsa44,mldsa65,mldsa87} via go generate.

A regression test (TestPublicTrIsIndependentOfPrivate) is added in
the same place and propagates to all six internal packages.
@armfazh
armfazh merged commit cedd4ed into main May 6, 2026
13 checks passed
@armfazh
armfazh deleted the bas/600 branch May 6, 2026 17:22
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.

sign/mldsa: is the pointer-sharing of sk.tr into the pk returned by (*PrivateKey).Public() intentional?

4 participants