mirror of
https://github.com/luxfi/pulsar.git
synced 2026-09-24 00:25:52 +00:00
ref/go: collapse dead circl-anchor placeholders, drop empty-slice append patterns
This commit is contained in:
@@ -317,8 +317,7 @@ func TranscriptForComplaint(e *AbortEvidence) []byte {
|
||||
binary.BigEndian.PutUint64(epochBuf[:], e.Epoch)
|
||||
parts = append(parts, epochBuf[:])
|
||||
parts = append(parts, e.Evidence)
|
||||
out := []byte{}
|
||||
out = append(out, leftEncode(uint64(len(parts)))...)
|
||||
out := append([]byte{}, leftEncode(uint64(len(parts)))...)
|
||||
for _, p := range parts {
|
||||
out = append(out, encodeString(p)...)
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func (s *DKGSession) Round1() (*DKGRound1Msg, error) {
|
||||
// blind_i material which existed only to feed the dropped
|
||||
// commit-and-open layer.
|
||||
committeeRoot := s.commitCommitteeRoot()
|
||||
keyMaterial := []byte{}
|
||||
keyMaterial := make([]byte, 0, len("PULSAR-DKG-DEALER-V1")+len(committeeRoot)+2+SeedSize)
|
||||
keyMaterial = append(keyMaterial, []byte("PULSAR-DKG-DEALER-V1")...)
|
||||
keyMaterial = append(keyMaterial, committeeRoot[:]...)
|
||||
keyMaterial = append(keyMaterial, byte(s.myIndex>>8), byte(s.myIndex))
|
||||
|
||||
@@ -171,7 +171,7 @@ func (s *LargeDKGSession) Round1() (*LargeDKGRound1Msg, error) {
|
||||
// derived seed) so two DKG sessions on the same contribution
|
||||
// never collide.
|
||||
committeeRoot := s.commitCommitteeRoot()
|
||||
keyMaterial := []byte{}
|
||||
keyMaterial := make([]byte, 0, len("PULSAR-DKG-DEALER-V1")+len(committeeRoot)+2+SeedSize)
|
||||
keyMaterial = append(keyMaterial, []byte("PULSAR-DKG-DEALER-V1")...)
|
||||
keyMaterial = append(keyMaterial, committeeRoot[:]...)
|
||||
keyMaterial = append(keyMaterial, byte(s.myIndex>>8), byte(s.myIndex))
|
||||
|
||||
@@ -209,7 +209,7 @@ func (s *LargeReshareSession) Round1() (*LargeDKGRound1Msg, error) {
|
||||
return nil, ErrShortRand
|
||||
}
|
||||
|
||||
keyMaterial := []byte{}
|
||||
keyMaterial := make([]byte, 0, len("PULSAR-RESHARE-DEALER-V1")+64+len(blind))
|
||||
keyMaterial = append(keyMaterial, []byte("PULSAR-RESHARE-DEALER-V1")...)
|
||||
keyMaterial = append(keyMaterial, s.commitOldCommitteeRoot()...)
|
||||
keyMaterial = append(keyMaterial, s.commitNewCommitteeRoot()...)
|
||||
|
||||
@@ -281,7 +281,7 @@ func (s *ReshareSession) Round1() (*DKGRound1Msg, error) {
|
||||
}
|
||||
|
||||
// Shamir-share the contribution at threshold newT to the new committee.
|
||||
keyMaterial := []byte{}
|
||||
keyMaterial := make([]byte, 0, len("PULSAR-RESHARE-DEALER-V1")+64+len(blind))
|
||||
keyMaterial = append(keyMaterial, []byte("PULSAR-RESHARE-DEALER-V1")...)
|
||||
keyMaterial = append(keyMaterial, s.commitOldCommitteeRoot()...)
|
||||
keyMaterial = append(keyMaterial, s.commitNewCommitteeRoot()...)
|
||||
|
||||
@@ -115,9 +115,6 @@ import (
|
||||
"io"
|
||||
"sort"
|
||||
|
||||
"github.com/cloudflare/circl/sign/mldsa/mldsa44"
|
||||
"github.com/cloudflare/circl/sign/mldsa/mldsa65"
|
||||
"github.com/cloudflare/circl/sign/mldsa/mldsa87"
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
||||
@@ -1174,14 +1171,6 @@ func TransitionalAggregate(
|
||||
return &Signature{Mode: params.Mode, Bytes: sigBytes}, nil
|
||||
}
|
||||
|
||||
// ensureCirclLinked is a marker that pins the circl imports referenced
|
||||
// indirectly by mldsaSign through Sign in sign.go. Without this anchor
|
||||
// a future automated import cleanup could drop the explicit circl
|
||||
// dependencies threshold_v02.go relies on through the dispatch table.
|
||||
var _ = mldsa44.SignatureSize
|
||||
var _ = mldsa65.SignatureSize
|
||||
var _ = mldsa87.SignatureSize
|
||||
|
||||
// algTranscriptTau1 builds the Round-1 transcript τ_1 for v0.2. Same
|
||||
// structure as v0.1's transcriptTau1Bytes but uses tagAlgR1 customisation
|
||||
// (callers feed this into the cSHAKE256/KMAC256 customisation field).
|
||||
@@ -1209,10 +1198,10 @@ func algTranscriptTau1(sid [16]byte, attempt uint32, quorum []NodeID, sender Nod
|
||||
// per-party payload. MAC is taken over this transcript so any tamper
|
||||
// in (W, Z, CS2, CT0) flips the MAC.
|
||||
func algTranscriptTau2(sid [16]byte, attempt uint32, quorum []NodeID, sender NodeID, pk *PublicKey, message, w, z, cs2, ct0 []byte) []byte {
|
||||
parts := [][]byte{}
|
||||
parts = append(parts, []byte("ALG-V1-R2"))
|
||||
parts = append(parts, sid[:])
|
||||
parts = append(parts, []byte{byte(attempt >> 24), byte(attempt >> 16), byte(attempt >> 8), byte(attempt)})
|
||||
var attemptBE [4]byte
|
||||
binary.BigEndian.PutUint32(attemptBE[:], attempt)
|
||||
parts := make([][]byte, 0, 8+len(quorum)+1)
|
||||
parts = append(parts, []byte("ALG-V1-R2"), sid[:], attemptBE[:])
|
||||
for _, q := range quorum {
|
||||
parts = append(parts, q[:])
|
||||
}
|
||||
@@ -1220,13 +1209,8 @@ func algTranscriptTau2(sid [16]byte, attempt uint32, quorum []NodeID, sender Nod
|
||||
if pk != nil {
|
||||
parts = append(parts, pk.Bytes)
|
||||
}
|
||||
parts = append(parts, message)
|
||||
parts = append(parts, w)
|
||||
parts = append(parts, z)
|
||||
parts = append(parts, cs2)
|
||||
parts = append(parts, ct0)
|
||||
out := []byte{}
|
||||
out = append(out, leftEncode(uint64(len(parts)))...)
|
||||
parts = append(parts, message, w, z, cs2, ct0)
|
||||
out := append([]byte{}, leftEncode(uint64(len(parts)))...)
|
||||
for _, p := range parts {
|
||||
out = append(out, encodeString(p)...)
|
||||
}
|
||||
|
||||
@@ -134,9 +134,6 @@ import (
|
||||
"io"
|
||||
"sort"
|
||||
|
||||
"github.com/cloudflare/circl/sign/mldsa/mldsa44"
|
||||
"github.com/cloudflare/circl/sign/mldsa/mldsa65"
|
||||
"github.com/cloudflare/circl/sign/mldsa/mldsa87"
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
||||
@@ -1162,10 +1159,10 @@ func algV03TranscriptTau1(sid [16]byte, attempt uint32, quorum []NodeID, sender
|
||||
// per-party payload. MAC is taken over this transcript so any tamper
|
||||
// in (W, Z, CS2, CT0) flips the MAC.
|
||||
func algV03TranscriptTau2(sid [16]byte, attempt uint32, quorum []NodeID, sender NodeID, pk *PublicKey, message, w, z, cs2, ct0 []byte) []byte {
|
||||
parts := [][]byte{}
|
||||
parts = append(parts, []byte("V03-R2"))
|
||||
parts = append(parts, sid[:])
|
||||
parts = append(parts, []byte{byte(attempt >> 24), byte(attempt >> 16), byte(attempt >> 8), byte(attempt)})
|
||||
var attemptBE [4]byte
|
||||
binary.BigEndian.PutUint32(attemptBE[:], attempt)
|
||||
parts := make([][]byte, 0, 8+len(quorum)+1)
|
||||
parts = append(parts, []byte("V03-R2"), sid[:], attemptBE[:])
|
||||
for _, q := range quorum {
|
||||
parts = append(parts, q[:])
|
||||
}
|
||||
@@ -1173,13 +1170,8 @@ func algV03TranscriptTau2(sid [16]byte, attempt uint32, quorum []NodeID, sender
|
||||
if pk != nil {
|
||||
parts = append(parts, pk.Bytes)
|
||||
}
|
||||
parts = append(parts, message)
|
||||
parts = append(parts, w)
|
||||
parts = append(parts, z)
|
||||
parts = append(parts, cs2)
|
||||
parts = append(parts, ct0)
|
||||
out := []byte{}
|
||||
out = append(out, leftEncode(uint64(len(parts)))...)
|
||||
parts = append(parts, message, w, z, cs2, ct0)
|
||||
out := append([]byte{}, leftEncode(uint64(len(parts)))...)
|
||||
for _, p := range parts {
|
||||
out = append(out, encodeString(p)...)
|
||||
}
|
||||
@@ -1204,16 +1196,3 @@ func V03QuorumEvalPoints(quorum []NodeID, shares []*AlgebraicKeyShare) ([]uint32
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ensureV03CirclLinked pins the circl imports so a future automated
|
||||
// import cleanup does not drop them. v0.3 does NOT call mldsaSign or
|
||||
// circl SignTo at any point — the imports are kept ONLY because
|
||||
// (a) Verify code paths reference these packages elsewhere in the file
|
||||
// and (b) the test suite needs them for byte-validity checks.
|
||||
var _ = mldsa44.SignatureSize
|
||||
var _ = mldsa65.SignatureSize
|
||||
var _ = mldsa87.SignatureSize
|
||||
|
||||
// Ensure encoding/binary is imported (used by the test fixture pack/
|
||||
// unpack helpers and indirectly by polyDeriveUniformBall).
|
||||
var _ = binary.LittleEndian
|
||||
|
||||
Reference in New Issue
Block a user