mirror of
https://github.com/luxfi/threshold.git
synced 2026-10-30 15:15:53 +00:00
VerifyMessage/StoreMessage/MessageContent/Number/BroadcastContent on round structs were value receivers. Go FAQ: "if any method on T takes *T, all methods should take *T." Finalize already takes *T (it mutates round state) so the others should too. Aligns the method set, removes silent struct-copies on every dispatch, and prevents future drift where a value-receiver method accidentally observes pre-Finalize state. No behavior change — all current methods are no-ops or return constants. Touched: round.Abort, round.Output, all CMP keygen/presign/sign rounds, all Doerner keygen/sign rounds, all FROST keygen/sign rounds, xor example. Build + vet clean; CMP/FROST/Doerner -race tests PASS.
42 lines
919 B
Go
42 lines
919 B
Go
package sign
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/luxfi/threshold/internal/round"
|
|
"github.com/luxfi/threshold/pkg/ecdsa"
|
|
)
|
|
|
|
// round2S is the final round of the signature protocol.
|
|
type round2S struct {
|
|
*round1S
|
|
Sig ecdsa.Signature
|
|
}
|
|
|
|
func (r *round2S) VerifyMessage(msg round.Message) error {
|
|
body, ok := msg.Content.(*message2R)
|
|
if !ok || body == nil {
|
|
return round.ErrInvalidContent
|
|
}
|
|
if !body.Sig.Verify(r.config.Public, r.hash) {
|
|
return errors.New("failed to verify signature")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (r *round2S) StoreMessage(msg round.Message) (err error) {
|
|
body := msg.Content.(*message2R)
|
|
r.Sig = body.Sig
|
|
return nil
|
|
}
|
|
|
|
func (r *round2S) Finalize(out chan<- *round.Message) (round.Session, error) {
|
|
return r.ResultRound(&r.Sig), nil
|
|
}
|
|
|
|
func (r *round2S) MessageContent() round.Content {
|
|
return &message2R{Sig: ecdsa.EmptySignature(r.Group())}
|
|
}
|
|
|
|
func (*round2S) Number() round.Number { return 2 }
|