Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions signer/sign_preconf_commitment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package signer

import (
"encoding/hex"

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
)

// TODO - add test(s)
// SignSlot signes the given preconf-commitment data
func (signer *SimpleSigner) SignPreconfCommitment(data []byte, domain phase0.Domain, pubKey []byte) ([]byte, []byte, error) {
if pubKey == nil {
return nil, nil, errors.New("account was not supplied")
}

account, err := signer.wallet.AccountByPublicKey(hex.EncodeToString(pubKey))
if err != nil {
return nil, nil, err
}

sszRoot := SSZBytes(data)
root, err := ComputeETHSigningRoot(sszRoot, domain)
if err != nil {
return nil, nil, err
}

sig, err := account.ValidationKeySign(root[:])
if err != nil {
return nil, nil, err
}

return sig, root[:], nil
}
1 change: 1 addition & 0 deletions signer/validator_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ValidatorSigner interface {
SignRegistration(registration *api.VersionedValidatorRegistration, domain phase0.Domain, pubKey []byte) (sig []byte, root []byte, err error)
SignVoluntaryExit(voluntaryExit *phase0.VoluntaryExit, domain phase0.Domain, pubKey []byte) (sig []byte, root []byte, err error)
SignBLSToExecutionChange(blsToExecutionChange *capella.BLSToExecutionChange, domain phase0.Domain, pubKey []byte) (sig []byte, root []byte, err error)
SignPreconfCommitment(data []byte, domain phase0.Domain, pubKey []byte) (sig []byte, root []byte, err error)
}

// SimpleSigner implements ValidatorSigner interface
Expand Down