Skip to content

Commit

Permalink
fix old types for signing
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusKysel committed Jul 24, 2024
1 parent b8fc547 commit f656d56
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions ekm/genesis_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
"github.com/herumi/bls-eth-go-binary/bls"
"github.com/pkg/errors"
genesisspectypes "github.com/ssvlabs/ssv-spec-pre-cc/types"
spectypes "github.com/ssvlabs/ssv-spec/types"
)
Expand All @@ -13,6 +14,37 @@ type GenesisKeyManagerAdapter struct {
}

func (k *GenesisKeyManagerAdapter) SignBeaconObject(obj ssz.HashRoot, domain phase0.Domain, pk []byte, domainType phase0.DomainType) (genesisspectypes.Signature, [32]byte, error) {
// Convert genesisspectypes to spectypes before passing on to KeyManager.
switch domainType {
case genesisspectypes.DomainAttester:
case genesisspectypes.DomainProposer:
case genesisspectypes.DomainVoluntaryExit:
case genesisspectypes.DomainAggregateAndProof:
case genesisspectypes.DomainSelectionProof:
data, ok := obj.(genesisspectypes.SSZUint64)
if !ok {
return nil, [32]byte{}, errors.New("could not cast obj to SSZUint64")
}
obj = spectypes.SSZUint64(data)
case genesisspectypes.DomainRandao:
data, ok := obj.(genesisspectypes.SSZUint64)
if !ok {
return nil, [32]byte{}, errors.New("could not cast obj to SSZUint64")
}
obj = spectypes.SSZUint64(data)
case genesisspectypes.DomainSyncCommittee:
data, ok := obj.(genesisspectypes.SSZBytes)
if !ok {
return nil, [32]byte{}, errors.New("could not cast obj to SSZBytes")
}
obj = spectypes.SSZBytes(data)
case genesisspectypes.DomainSyncCommitteeSelectionProof:
case genesisspectypes.DomainContributionAndProof:
case genesisspectypes.DomainApplicationBuilder:
default:
return nil, [32]byte{}, errors.New("domain unknown")
}

signature, root, err := k.KeyManager.SignBeaconObject(obj, domain, pk, domainType)
if err != nil {
return nil, [32]byte{}, err
Expand Down

0 comments on commit f656d56

Please sign in to comment.