Files
zeekay 75be0e607e round: rename Helper to Base — name the value, not the laziness
round.Helper was the canonical anti-pattern: a bare-noun
qualifier-name that told you nothing about what the type does. The
type is the embeddable Session implementation that protocol round
structs anchor on — its VALUE is "the base every round builds on".
Rename it to that.

  type Helper struct { ... }   → type Base struct { ... }
  func (h *Helper) ...         → func (h *Base) ...
  func NewSession(...) (*Helper, error) → (*Base, error)
  Output { *Helper }           → Output { *Base }
  Abort  { *Helper }           → Abort  { *Base }
  round.Helper                 → round.Base   (18 files)
  Helper: helper               → Base: helper (struct literal init)
  r.Helper.X / r.Helper        → r.Base.X / r.Base (field access)

internal/round/helper.go    → base.go
internal/round/helper_test.go → base_test.go

Forward-only — no type alias, no deprecation. The Go FAQ pointer-
receiver consistency landed in the prior commit (f7b1365) so the
method set is already aligned; this commit only renames the type.

Build + vet clean; round / CMP keygen smoke / FROST keygen all
PASS unchanged.
2026-06-01 00:26:33 -07:00

68 lines
2.1 KiB
Go

package sign
import (
"crypto/rand"
"github.com/luxfi/threshold/internal/ot"
"github.com/luxfi/threshold/internal/round"
"github.com/luxfi/threshold/pkg/hash"
"github.com/luxfi/threshold/pkg/math/curve"
"github.com/luxfi/threshold/pkg/math/sample"
"github.com/luxfi/threshold/protocols/doerner/keygen"
)
// message1R is the first message sent by the Receiver.
type message1R struct {
// D is our nonce share times the generator.
D curve.Point
// We have three messages for the three multiplications.
MulMsg0 *ot.MultiplyReceiveRound1Message
MulMsg1 *ot.MultiplyReceiveRound1Message
MulMsg2 *ot.MultiplyReceiveRound1Message
}
func (message1R) RoundNumber() round.Number { return 1 }
type round1R struct {
*round.Base
hash []byte
config *keygen.ConfigReceiver
}
func (r *round1R) VerifyMessage(round.Message) error { return nil }
func (r *round1R) StoreMessage(round.Message) error { return nil }
func (r *round1R) Finalize(out chan<- *round.Message) (round.Session, error) {
kB := sample.Scalar(rand.Reader, r.Group())
D := kB.ActOnBase()
kB.Invert()
tag0 := &hash.BytesWithDomain{TheDomain: "Multiply0", Bytes: nil}
multiply0, err := ot.NewMultiplyReceiver(r.Hash().Fork(tag0), r.config.Setup, kB)
if err != nil {
return r, err
}
tag1 := &hash.BytesWithDomain{TheDomain: "Multiply1", Bytes: nil}
multiply1, err := ot.NewMultiplyReceiver(r.Hash().Fork(tag1), r.config.Setup, kB)
if err != nil {
return r, err
}
beta := r.Group().NewScalar().Set(r.config.SecretShare).Mul(kB)
tag2 := &hash.BytesWithDomain{TheDomain: "Multiply1", Bytes: nil}
multiply2, err := ot.NewMultiplyReceiver(r.Hash().Fork(tag2), r.config.Setup, beta)
if err != nil {
return r, err
}
msg0 := multiply0.Round1()
msg1 := multiply1.Round1()
msg2 := multiply2.Round1()
if err := r.SendMessage(out, &message1R{D, msg0, msg1, msg2}, ""); err != nil {
return r, err
}
return &round2R{round1R: r, kBInv: kB, D: D, multiply0: multiply0, multiply1: multiply1, multiply2: multiply2}, nil
}
func (*round1R) MessageContent() round.Content { return nil }
func (*round1R) Number() round.Number { return 1 }