mirror of
https://github.com/luxfi/magnetar.git
synced 2026-07-27 02:53:47 +00:00
fix: gofmt -s across repo (CI format check)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
// Package dudect carries the Magnetar v1.1 strict-atom Combine CT
|
||||
// harness. Run via:
|
||||
//
|
||||
// go test -tags ct -run TestStrictAtom_CT ./ct/dudect/...
|
||||
// go test -tags ct -run TestStrictAtom_CT ./ct/dudect/...
|
||||
//
|
||||
// or via scripts/checks/dudect-smoke.sh.
|
||||
package dudect
|
||||
|
||||
@@ -57,7 +57,7 @@ import (
|
||||
// - key.Shares[i].Share = thbsseShareToBytes(aggregated share);
|
||||
// byte-equal for the same implicit master.
|
||||
// - key.SetupTranscript = cSHAKE256(pk_bytes || n || t ||
|
||||
// committee[i]...) per the
|
||||
// committee[i]...) per the
|
||||
// same canonical hash NewThbsSeKey uses.
|
||||
//
|
||||
// If the qualified set has fewer than threshold parties, returns
|
||||
|
||||
@@ -810,6 +810,7 @@ func VerifyShareConsistency(
|
||||
// - Its own m_i (= polyCoeffs[*][0]).
|
||||
// - The shares σ_{i→self} received from every other party.
|
||||
// - The aggregated final share σ_self after Round 2.
|
||||
//
|
||||
// The master is materialised only inside the PK-derivation closure
|
||||
// (deriveDKGPublicKey) which is a separate sibling function the
|
||||
// auditor or any third party invokes to extract the public key from
|
||||
|
||||
@@ -416,12 +416,13 @@ func synthesiseDealerShares(t *testing.T, params *Params, threshold int, committ
|
||||
// adversary's marginal distribution over M is uniform over GF(257)^L.
|
||||
//
|
||||
// Operationally we test by:
|
||||
// (1) Running a DKG.
|
||||
// (2) Picking (t-1) random parties and treating them as corrupted.
|
||||
// (3) Reconstructing the adversary's "best guess" at M from those
|
||||
// parties' contributions alone — i.e. Σ_{i ∈ corrupted} m_i.
|
||||
// (4) Asserting that the partial sum is NOT byte-equal to the full
|
||||
// reconstructed master.
|
||||
//
|
||||
// (1) Running a DKG.
|
||||
// (2) Picking (t-1) random parties and treating them as corrupted.
|
||||
// (3) Reconstructing the adversary's "best guess" at M from those
|
||||
// parties' contributions alone — i.e. Σ_{i ∈ corrupted} m_i.
|
||||
// (4) Asserting that the partial sum is NOT byte-equal to the full
|
||||
// reconstructed master.
|
||||
//
|
||||
// The probability of accidental byte-equality is (1/257)^L ≈ 2^-768
|
||||
// for L=96.
|
||||
@@ -494,11 +495,11 @@ func TestPVSS_DKG_AdversarialReveals(t *testing.T) {
|
||||
// malicious party who publishes a commitment that does not open to
|
||||
// their distributed shares. The test asserts:
|
||||
//
|
||||
// (1) VerifyContribution detects the inconsistency.
|
||||
// (2) RunDKGSimulation drops the malicious party from Q.
|
||||
// (3) If |Q| ≥ threshold, the protocol terminates with valid output.
|
||||
// (4) If |Q| < threshold, the protocol fails cleanly with
|
||||
// ErrPVSSQuorumLost.
|
||||
// (1) VerifyContribution detects the inconsistency.
|
||||
// (2) RunDKGSimulation drops the malicious party from Q.
|
||||
// (3) If |Q| ≥ threshold, the protocol terminates with valid output.
|
||||
// (4) If |Q| < threshold, the protocol fails cleanly with
|
||||
// ErrPVSSQuorumLost.
|
||||
//
|
||||
// We test both regimes: (n=5, t=3, 1 malicious) where |Q|=4≥t and
|
||||
// (n=5, t=4, 2 malicious) where |Q|=3<t.
|
||||
|
||||
@@ -262,11 +262,15 @@ func (a *adrsBuf) setTreeIndex(i uint32) {
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// PRF callback (the strict-atom seam)
|
||||
//
|
||||
// PRF callback (the strict-atom seam)
|
||||
//
|
||||
// =====================================================================
|
||||
//
|
||||
// prfOutFn is the FIPS 205 §11.2 PRF for SHAKE:
|
||||
// PRF(PK.seed, ADRS, X) = SHAKE256(PK.seed || ADRS || X)[:n]
|
||||
//
|
||||
// PRF(PK.seed, ADRS, X) = SHAKE256(PK.seed || ADRS || X)[:n]
|
||||
//
|
||||
// where X is the n-byte secret seed material per FIPS 205 §6.2 and §5.
|
||||
//
|
||||
// The strict-atom Combine path (thbsse_assemble.go) installs a closure
|
||||
@@ -282,7 +286,9 @@ func (a *adrsBuf) setTreeIndex(i uint32) {
|
||||
type prfOutFn func(out []byte, addr *adrsBuf)
|
||||
|
||||
// prfMsgFn is the FIPS 205 §11.2 PRF_msg for SHAKE:
|
||||
// PRF_msg(SK.prf, optRand, M) = SHAKE256(SK.prf || optRand || M)[:n]
|
||||
//
|
||||
// PRF_msg(SK.prf, optRand, M) = SHAKE256(SK.prf || optRand || M)[:n]
|
||||
//
|
||||
// SK.prf is the message-randomizer key half of the FIPS 205 expanded
|
||||
// material; it is hosted by the strict-atom atom bag for the same
|
||||
// reason X is.
|
||||
@@ -384,12 +390,12 @@ func nextHTIndex(idxTree *[3]uint32, n uint32) (idxLeaf uint32) {
|
||||
|
||||
// wotsChain implements the FIPS 205 §5 Algorithm 5 chain function:
|
||||
//
|
||||
// chain(X, i, s, PK.seed, ADRS):
|
||||
// tmp ← X
|
||||
// for j ∈ [i, i+s):
|
||||
// ADRS.SetHashAddress(j)
|
||||
// tmp ← F(PK.seed, ADRS, tmp)
|
||||
// return tmp
|
||||
// chain(X, i, s, PK.seed, ADRS):
|
||||
// tmp ← X
|
||||
// for j ∈ [i, i+s):
|
||||
// ADRS.SetHashAddress(j)
|
||||
// tmp ← F(PK.seed, ADRS, tmp)
|
||||
// return tmp
|
||||
//
|
||||
// X is the chain base (n bytes). The caller is responsible for the
|
||||
// outer address state; this routine mutates only the hash-address word.
|
||||
@@ -885,9 +891,9 @@ func forsPkFromSig(
|
||||
// - message: the user message bytes
|
||||
// - ctx: the FIPS 205 §10.2 context string (<= 255 bytes)
|
||||
// - prfOut: the secret-side PRF (FIPS 205 §11.2) — the only seam
|
||||
// for SK.seed access
|
||||
// for SK.seed access
|
||||
// - prfMsg: the message-randomizer PRF — the only seam for SK.prf
|
||||
// access
|
||||
// access
|
||||
//
|
||||
// Output: the signatureSize-byte FIPS 205 wire signature.
|
||||
func slhSignAtom(
|
||||
@@ -903,7 +909,7 @@ func slhSignAtom(
|
||||
|
||||
// FIPS 205 §10.2 Algorithm 23 — bind ctx to msgPrime.
|
||||
msgPrime := make([]byte, 0, 2+len(ctx)+len(message))
|
||||
msgPrime = append(msgPrime, 0) // domain separator: pure
|
||||
msgPrime = append(msgPrime, 0) // domain separator: pure
|
||||
msgPrime = append(msgPrime, byte(len(ctx))) // ctx length
|
||||
msgPrime = append(msgPrime, ctx...)
|
||||
msgPrime = append(msgPrime, message...)
|
||||
|
||||
@@ -337,9 +337,9 @@ func runtimeGOMAXPROCS() int {
|
||||
//
|
||||
// Wire layout (canonical, parallel-slices form):
|
||||
//
|
||||
// Mode || N || Signers[0] || ... || Signers[N-1]
|
||||
// || PubKeys[0] || ... || PubKeys[N-1]
|
||||
// || Sigs[0] || ... || Sigs[N-1]
|
||||
// Mode || N || Signers[0] || ... || Signers[N-1]
|
||||
// || PubKeys[0] || ... || PubKeys[N-1]
|
||||
// || Sigs[0] || ... || Sigs[N-1]
|
||||
//
|
||||
// where:
|
||||
// - Mode is one byte.
|
||||
|
||||
@@ -243,7 +243,7 @@ func assembleSignatureBytes(
|
||||
// makePRFClosure returns a prfOutFn that implements FIPS 205 §11.2 PRF
|
||||
// for SHAKE:
|
||||
//
|
||||
// PRF(PK.seed, ADRS, X) = SHAKE256(PK.seed || ADRS || X)[:n]
|
||||
// PRF(PK.seed, ADRS, X) = SHAKE256(PK.seed || ADRS || X)[:n]
|
||||
//
|
||||
// The `secretSegment` argument is the first n bytes of the SHAKE-
|
||||
// expanded master material — the X portion of every PRF absorb.
|
||||
@@ -278,7 +278,8 @@ func makePRFClosure(p *internalParams, pkSeed, secretSegment []byte) prfOutFn {
|
||||
// makePRFMsgClosure returns a prfMsgFn that implements FIPS 205 §11.2
|
||||
// PRF_msg for SHAKE:
|
||||
//
|
||||
// PRF_msg(key, optRand, M) = SHAKE256(key || optRand || M)[:n]
|
||||
// PRF_msg(key, optRand, M) = SHAKE256(key || optRand || M)[:n]
|
||||
//
|
||||
// where `key` is the second positional segment of the FIPS 205 SHAKE
|
||||
// expansion of the master.
|
||||
//
|
||||
|
||||
@@ -575,4 +575,3 @@ func compareNodeIDs(a, b NodeID) int {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -85,14 +85,14 @@ func runRound1Across(t *testing.T, params *Params, key *ThbsSeKey, binding *Thbs
|
||||
// three SLH-DSA SHAKE parameter sets, on a t=3, n=5 committee.
|
||||
//
|
||||
// The flow:
|
||||
// 1. NewThbsSeKey produces (PK, shares) for (n=5, t=3).
|
||||
// 2. Three honest signers run Round 1 + Round 2 against the slot
|
||||
// binding and the message.
|
||||
// 3. A public combiner (anyone) calls Combine with the assembled
|
||||
// Round-1 / Round-2 messages plus the published ThbsSeKey.
|
||||
// 4. The returned Signature.Bytes is fed DIRECTLY to circl's
|
||||
// slhdsa.Verify with the ctx = ctxFromSlot(binding). No
|
||||
// Magnetar code path is hit on the verifier side.
|
||||
// 1. NewThbsSeKey produces (PK, shares) for (n=5, t=3).
|
||||
// 2. Three honest signers run Round 1 + Round 2 against the slot
|
||||
// binding and the message.
|
||||
// 3. A public combiner (anyone) calls Combine with the assembled
|
||||
// Round-1 / Round-2 messages plus the published ThbsSeKey.
|
||||
// 4. The returned Signature.Bytes is fed DIRECTLY to circl's
|
||||
// slhdsa.Verify with the ctx = ctxFromSlot(binding). No
|
||||
// Magnetar code path is hit on the verifier side.
|
||||
//
|
||||
// PASS ⇔ the combiner produced a wire-canonical FIPS 205 signature
|
||||
// for every supported mode.
|
||||
|
||||
Reference in New Issue
Block a user