Skip to content

Commit

Permalink
cluster: fix lint (#1228)
Browse files Browse the repository at this point in the history
Fixes golangci-lint on main.

category: fixbuild
ticket: none
  • Loading branch information
dB2510 authored Oct 5, 2022
1 parent 328cb6e commit 50e2461
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cluster/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,19 @@ func (d Definition) NodeIdx(pID peer.ID) (NodeIdx, error) {
}

// VerifySignatures returns true if all config signatures are fully populated and valid. A verified definition is ready for use in DKG.
//
//nolint:gocognit
func (d Definition) VerifySignatures() error {
// Skip signature verification for definition versions earlier than v1.3 since there are no EIP712 signatures before v1.3.0.
if !supportEIP712Sigs(d.Version) {
// For definition versions earlier than v1.3.0, error if either config signature or enr signature for any operator is present.
if eip712SigsPresent(d.Operators) {
return errors.New("older version signatures not supported")
}

if !supportEIP712Sigs(d.Version) && !eip712SigsPresent(d.Operators) {
return nil
}

// For definition versions earlier than v1.3.0, error if either config signature or enr signature for any operator is present.
if !supportEIP712Sigs(d.Version) && eip712SigsPresent(d.Operators) {
return errors.New("older version signatures not supported")
}

configHash, err := hashDefinition(d, true)
if err != nil {
return errors.Wrap(err, "config hash")
Expand Down Expand Up @@ -182,7 +184,7 @@ func (d Definition) VerifySignatures() error {
return err
}

if ok, err := verifySig(o.Address, digest[:], o.ConfigSignature); err != nil {
if ok, err := verifySig(o.Address, digest, o.ConfigSignature); err != nil {
return err
} else if !ok {
return errors.New("invalid operator config signature", z.Any("operator_address", o.Address))
Expand All @@ -194,7 +196,7 @@ func (d Definition) VerifySignatures() error {
return err
}

if ok, err := verifySig(o.Address, digest[:], o.ENRSignature); err != nil {
if ok, err := verifySig(o.Address, digest, o.ENRSignature); err != nil {
return err
} else if !ok {
return errors.New("invalid operator enr signature", z.Any("operator_address", o.Address))
Expand Down

0 comments on commit 50e2461

Please sign in to comment.