Files
threshold/protocols/example/xor/round1.go
zeekay b41c78f5b3 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 (bf88f5a) 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

46 lines
1.4 KiB
Go

package xor
import (
"crypto/rand"
"github.com/luxfi/threshold/internal/round"
"github.com/luxfi/threshold/internal/types"
"github.com/luxfi/threshold/pkg/party"
)
// Round1 can embed round.Base which provides useful methods handling messages.
type Round1 struct {
*round.Base
}
// VerifyMessage in the first round does nothing since no messages are expected.
func (r *Round1) VerifyMessage(round.Message) error { return nil }
// StoreMessage in the first round does nothing since no messages are expected.
func (r *Round1) StoreMessage(round.Message) error { return nil }
// Finalize uses the out channel to communicate messages to other parties.
func (r *Round1) Finalize(out chan<- *round.Message) (round.Session, error) {
xor, err := types.NewRID(rand.Reader)
if err != nil {
// return the round since we did not actually abort due to malicious behaviour.
return r, err
}
// send the message to all other parties, and marshal it using the helper method which sets the appropriate headers.
err = r.SendMessage(out, &Round2Message{xor}, "")
if err != nil {
return r, err
}
return &Round2{
Round1: r,
received: map[party.ID]types.RID{r.SelfID(): xor},
}, nil
}
// MessageContent returns an empty message.First as a placeholder indicating that no message is expected.
func (*Round1) MessageContent() round.Content { return nil }
// Number implements round.Round.
func (*Round1) Number() round.Number { return 1 }