From 31a573b0541bb336977dfdf546cd58595a21dee8 Mon Sep 17 00:00:00 2001 From: Dhruv Bodani Date: Wed, 10 Aug 2022 13:32:39 +0530 Subject: [PATCH 1/2] add verification functions to validatorapi --- core/validatorapi/validatorapi.go | 77 ++++++------ eth2util/signing/signing.go | 190 ++++++++++++++---------------- eth2util/signing/signing_test.go | 54 ++++----- 3 files changed, 151 insertions(+), 170 deletions(-) diff --git a/core/validatorapi/validatorapi.go b/core/validatorapi/validatorapi.go index 28c3d2215..9f176af16 100644 --- a/core/validatorapi/validatorapi.go +++ b/core/validatorapi/validatorapi.go @@ -33,7 +33,6 @@ import ( "github.com/obolnetwork/charon/app/log" "github.com/obolnetwork/charon/app/z" "github.com/obolnetwork/charon/core" - "github.com/obolnetwork/charon/eth2util" "github.com/obolnetwork/charon/eth2util/signing" "github.com/obolnetwork/charon/tbls/tblsconv" ) @@ -259,8 +258,11 @@ func (c Component) SubmitAttestations(ctx context.Context, attestations []*eth2p return err } - // Verify signature - if err = c.verifySignedData(ctx, c.eth2Cl, pubkey, att); err != nil { + // Verify attestation signature + err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { + return signing.VerifyAttestation(ctx, c.eth2Cl, pubshare, *att) + }) + if err != nil { return err } @@ -304,7 +306,11 @@ func (c Component) BeaconBlockProposal(ctx context.Context, slot eth2p0.Slot, ra // TODO(corver): Refactor RANDAO partial signature to contain epoch. parSig := core.NewPartialSignature(core.SigFromETH2(randao), c.shareIdx) - if err := c.verifyRandaoParSig(ctx, slot, randao, pubkey); err != nil { + // Verify randao signature + err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { + return signing.VerifyRandao(ctx, c.eth2Cl, pubshare, randao, slot) + }) + if err != nil { return nil, err } @@ -356,7 +362,11 @@ func (c Component) SubmitBeaconBlock(ctx context.Context, block *spec.VersionedS duty := core.NewProposerDuty(int64(slot)) ctx = log.WithCtx(ctx, z.Any("duty", duty)) - if err = c.verifySignedData(ctx, c.eth2Cl, pubkey, block); err != nil { + // Verify block signature + err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { + return signing.VerifyBlock(ctx, c.eth2Cl, pubshare, *block) + }) + if err != nil { return err } @@ -386,7 +396,11 @@ func (c Component) BlindedBeaconBlockProposal(ctx context.Context, slot eth2p0.S return nil, err } - if err := c.verifyRandaoParSig(ctx, slot, randao, pubkey); err != nil { + // Verify randao signature + err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { + return signing.VerifyRandao(ctx, c.eth2Cl, pubshare, randao, slot) + }) + if err != nil { return nil, err } @@ -441,7 +455,11 @@ func (c Component) SubmitBlindedBeaconBlock(ctx context.Context, block *eth2api. duty := core.NewBuilderProposerDuty(int64(slot)) ctx = log.WithCtx(ctx, z.Any("duty", duty)) - if err = c.verifySignedData(ctx, c.eth2Cl, pubkey, block); err != nil { + // Verify Blinded block signature + err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { + return signing.VerifyBlindedBlock(ctx, c.eth2Cl, pubshare, *block) + }) + if err != nil { return err } @@ -489,7 +507,10 @@ func (c Component) submitRegistration(ctx context.Context, registration *eth2api duty := core.NewBuilderRegistrationDuty(int64(slot)) ctx = log.WithCtx(ctx, z.Any("duty", duty)) - if err = c.verifySignedData(ctx, c.eth2Cl, pubkey, registration); err != nil { + err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { + return signing.VerifyValidatorRegistration(ctx, c.eth2Cl, pubshare, *registration) + }) + if err != nil { return err } @@ -556,7 +577,11 @@ func (c Component) SubmitVoluntaryExit(ctx context.Context, exit *eth2p0.SignedV duty := core.NewVoluntaryExit(int64(slotsPerEpoch) * int64(exit.Message.Epoch)) ctx = log.WithCtx(ctx, z.Any("duty", duty)) - if err = c.verifySignedData(ctx, c.eth2Cl, pubkey, exit); err != nil { + // Verify voluntary exit signature + err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { + return signing.VerifyVoluntaryExit(ctx, c.eth2Cl, pubshare, *exit) + }) + if err != nil { return err } @@ -703,37 +728,7 @@ func (c Component) getProposerPubkey(ctx context.Context, duty core.Duty) (core. return pubkey, nil } -// TODO(corver): Use verifySignedData once randao partial signature contains epoch. -func (c Component) verifyRandaoParSig(ctx context.Context, slot eth2p0.Slot, - randao eth2p0.BLSSignature, pubkey core.PubKey, -) error { - if c.insecureTest { - return nil - } - - epoch, err := c.epochFromSlot(ctx, slot) - if err != nil { - return err - } - - // Randao signing root is the epoch. - sigRoot, err := eth2util.EpochHashRoot(epoch) - if err != nil { - return err - } - - pubshare, err := c.getVerifyShareFunc(pubkey) - if err != nil { - return err - } - - return signing.Verify(ctx, c.eth2Cl, signing.DomainRandao, epoch, sigRoot, randao, pubshare) -} - -// verifySignedData aliases signing.VerifySignedData skipping it for insecureTest. -func (c Component) verifySignedData(ctx context.Context, eth2Cl signing.Eth2Provider, - pubkey core.PubKey, eth2SignedType interface{}, -) error { +func (c Component) verifyPartialSig(pubkey core.PubKey, verifyFunc func(pubshare *bls_sig.PublicKey) error) error { if c.insecureTest { return nil } @@ -743,5 +738,5 @@ func (c Component) verifySignedData(ctx context.Context, eth2Cl signing.Eth2Prov return err } - return signing.VerifySignedData(ctx, eth2Cl, pubshare, eth2SignedType) + return verifyFunc(pubshare) } diff --git a/eth2util/signing/signing.go b/eth2util/signing/signing.go index a60b76343..165d2175f 100644 --- a/eth2util/signing/signing.go +++ b/eth2util/signing/signing.go @@ -17,8 +17,6 @@ package signing import ( "context" - "fmt" - "reflect" eth2client "github.com/attestantio/go-eth2-client" eth2api "github.com/attestantio/go-eth2-client/api" @@ -27,7 +25,7 @@ import ( "github.com/coinbase/kryptology/pkg/signatures/bls/bls_sig" "github.com/obolnetwork/charon/app/errors" - "github.com/obolnetwork/charon/app/z" + "github.com/obolnetwork/charon/eth2util" "github.com/obolnetwork/charon/tbls" "github.com/obolnetwork/charon/tbls/tblsconv" ) @@ -128,121 +126,111 @@ func GetDataRoot(ctx context.Context, eth2Cl Eth2Provider, name DomainName, epoc // //} -// VerifySignedData verifies any eth2 signed data signature. -// If it is partially signed, provide the pubshare. -// If it is aggregate signed, provide the group pubkey. -func VerifySignedData(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, - eth2SignedType interface{}, -) error { - // eth2util shouldn't import core package, so can't use core.SignedData. - // To avoid pointer vs non-pointer issues, always get value if pointer is provided. - if reflect.TypeOf(eth2SignedType).Kind() == reflect.Pointer { - eth2SignedType = reflect.ValueOf(eth2SignedType).Elem().Interface() +func VerifyAttestation(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, att eth2p0.Attestation) error { + sigRoot, err := att.Data.HashTreeRoot() + if err != nil { + return errors.Wrap(err, "hash attestation data") } - switch signed := eth2SignedType.(type) { - case eth2p0.Attestation: - sigRoot, err := signed.Data.HashTreeRoot() - if err != nil { - return errors.Wrap(err, "hash attestation data") - } + return verify(ctx, eth2Cl, DomainBeaconAttester, att.Data.Target.Epoch, sigRoot, att.Signature, pubkey) +} - return Verify(ctx, eth2Cl, DomainBeaconAttester, signed.Data.Target.Epoch, - sigRoot, signed.Signature, pubkey) - case spec.VersionedSignedBeaconBlock: +func VerifyBlock(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, block spec.VersionedSignedBeaconBlock) error { + slot, err := block.Slot() + if err != nil { + return err + } - slot, err := signed.Slot() - if err != nil { - return err - } + // Calculate slot epoch + epoch, err := epochFromSlot(ctx, eth2Cl, slot) + if err != nil { + return err + } - // Calculate slot epoch - epoch, err := epochFromSlot(ctx, eth2Cl, slot) - if err != nil { - return err - } + sigRoot, err := block.Root() + if err != nil { + return err + } - sigRoot, err := signed.Root() - if err != nil { - return err - } + var sig eth2p0.BLSSignature + switch block.Version { + case spec.DataVersionPhase0: + sig = block.Phase0.Signature + case spec.DataVersionAltair: + sig = block.Altair.Signature + case spec.DataVersionBellatrix: + sig = block.Bellatrix.Signature + default: + return errors.New("unknown version") + } - var sig eth2p0.BLSSignature - switch signed.Version { - case spec.DataVersionPhase0: - sig = signed.Phase0.Signature - case spec.DataVersionAltair: - sig = signed.Altair.Signature - case spec.DataVersionBellatrix: - sig = signed.Bellatrix.Signature - default: - return errors.New("unknown version") - } + return verify(ctx, eth2Cl, DomainBeaconProposer, epoch, sigRoot, sig, pubkey) +} - return Verify(ctx, eth2Cl, DomainBeaconProposer, epoch, sigRoot, sig, pubkey) - case eth2api.VersionedSignedBlindedBeaconBlock: - slot, err := signed.Slot() - if err != nil { - return err - } +func VerifyBlindedBlock(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, block eth2api.VersionedSignedBlindedBeaconBlock) error { + slot, err := block.Slot() + if err != nil { + return err + } - // Calculate slot epoch - epoch, err := epochFromSlot(ctx, eth2Cl, slot) - if err != nil { - return err - } + // Calculate slot epoch + epoch, err := epochFromSlot(ctx, eth2Cl, slot) + if err != nil { + return err + } - sigRoot, err := signed.Root() - if err != nil { - return err - } + sigRoot, err := block.Root() + if err != nil { + return err + } - var sig eth2p0.BLSSignature - switch signed.Version { - case spec.DataVersionBellatrix: - sig = signed.Bellatrix.Signature - default: - return errors.New("unknown version") - } + var sig eth2p0.BLSSignature + switch block.Version { + case spec.DataVersionBellatrix: + sig = block.Bellatrix.Signature + default: + return errors.New("unknown version") + } - return Verify(ctx, eth2Cl, DomainBeaconProposer, epoch, sigRoot, sig, pubkey) - // case core.Signature: - // TODO(corver): Refactor randao SignedData to include epoch. - // return errors.New("randao not supported yet") - - // var epoch eth2p0.Epoch - // - // sigRoot, err := eth2util.EpochHashRoot(epoch) - // if err != nil { - // return err - //} - // - // return Verify(ctx, eth2Cl, DomainRandao, epoch, sigRoot, signed.ToETH2(), pubkey) - case eth2p0.SignedVoluntaryExit: - sigRoot, err := signed.Message.HashTreeRoot() - if err != nil { - return err - } + return verify(ctx, eth2Cl, DomainBeaconProposer, epoch, sigRoot, sig, pubkey) +} - return Verify(ctx, eth2Cl, DomainExit, signed.Message.Epoch, sigRoot, - signed.Signature, pubkey) - case eth2api.VersionedSignedValidatorRegistration: - // TODO: switch to signed.Root() when implemented on go-eth2-client (PR has been raised) - sigRoot, err := signed.V1.Message.HashTreeRoot() - if err != nil { - return err - } +func VerifyRandao(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, randao eth2p0.BLSSignature, slot eth2p0.Slot) error { + // Calculate slot epoch + epoch, err := epochFromSlot(ctx, eth2Cl, slot) + if err != nil { + return err + } - return Verify(ctx, eth2Cl, DomainApplicationBuilder, 0, sigRoot, - signed.V1.Signature, pubkey) - default: - return errors.New("unsupported eth2 signed data type", z.Str("type", fmt.Sprintf("%T", eth2SignedType))) + sigRoot, err := eth2util.EpochHashRoot(epoch) + if err != nil { + return err + } + + return verify(ctx, eth2Cl, DomainRandao, epoch, sigRoot, randao, pubkey) +} + +func VerifyVoluntaryExit(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, exit eth2p0.SignedVoluntaryExit) error { + sigRoot, err := exit.Message.HashTreeRoot() + if err != nil { + return err + } + + return verify(ctx, eth2Cl, DomainExit, exit.Message.Epoch, sigRoot, exit.Signature, pubkey) +} + +func VerifyValidatorRegistration(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, reg eth2api.VersionedSignedValidatorRegistration) error { + // TODO: switch to signed.Root() when implemented on go-eth2-client (PR has been raised) + sigRoot, err := reg.V1.Message.HashTreeRoot() + if err != nil { + return err } + + return verify(ctx, eth2Cl, DomainApplicationBuilder, 0, sigRoot, reg.V1.Signature, pubkey) } -// Verify returns an error if the signature doesn't match the eth2 domain signed root. -// TODO(corver): Unexport this once Randao partial signatures contain their epoch. -func Verify(ctx context.Context, eth2Cl Eth2Provider, domain DomainName, epoch eth2p0.Epoch, +// verify returns an error if the signature doesn't match the eth2 domain signed root. +func verify(ctx context.Context, eth2Cl Eth2Provider, domain DomainName, epoch eth2p0.Epoch, sigRoot [32]byte, sig eth2p0.BLSSignature, pubshare *bls_sig.PublicKey, ) error { sigData, err := GetDataRoot(ctx, eth2Cl, domain, epoch, sigRoot) diff --git a/eth2util/signing/signing_test.go b/eth2util/signing/signing_test.go index 080cec474..3844a9cd8 100644 --- a/eth2util/signing/signing_test.go +++ b/eth2util/signing/signing_test.go @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/obolnetwork/charon/core" + "github.com/obolnetwork/charon/eth2util" "github.com/obolnetwork/charon/eth2util/signing" "github.com/obolnetwork/charon/tbls" "github.com/obolnetwork/charon/tbls/tblsconv" @@ -46,7 +47,7 @@ func TestVerifyAttestation(t *testing.T) { sig, pubkey := sign(t, sigData[:]) att.Signature = tblsconv.SigToETH2(sig) - require.NoError(t, signing.VerifySignedData(context.Background(), bmock, pubkey, att)) + require.NoError(t, signing.VerifyAttestation(context.Background(), bmock, pubkey, *att)) } func TestVerifyBeaconBlock(t *testing.T) { @@ -74,32 +75,29 @@ func TestVerifyBeaconBlock(t *testing.T) { versionedBlock := data.(core.VersionedSignedBeaconBlock).VersionedSignedBeaconBlock - require.NoError(t, signing.VerifySignedData(context.Background(), bmock, pubkey, versionedBlock)) + require.NoError(t, signing.VerifyBlock(context.Background(), bmock, pubkey, versionedBlock)) } -// -// func TestVerifyDutyRandao(t *testing.T) { -// duty := core.NewRandaoDuty(123) -// -// bmock, err := beaconmock.New() -// require.NoError(t, err) -// -// slotsPerEpoch, err := bmock.SlotsPerEpoch(context.Background()) -// require.NoError(t, err) -// -// epoch := eth2p0.Epoch(uint64(duty.Slot) / slotsPerEpoch) -// sigRoot, err := eth2util.EpochHashRoot(epoch) -// require.NoError(t, err) -// -// sigData, err := signing.GetDataRoot(context.Background(), bmock, signing.DomainRandao, epoch, sigRoot) -// require.NoError(t, err) -// -// sig, pubkey := sign(t, sigData[:]) -// psig := core.NewPartialSignature(tblsconv.SigToCore(sig), 0) -// -// verifyFunc := signing.NewVerifyFunc(bmock) -// require.NoError(t, verifyFunc(context.Background(), duty, pubkey, psig)) -//} +func TestVerifyDutyRandao(t *testing.T) { + duty := core.NewRandaoDuty(123) + + bmock, err := beaconmock.New() + require.NoError(t, err) + + slotsPerEpoch, err := bmock.SlotsPerEpoch(context.Background()) + require.NoError(t, err) + + epoch := eth2p0.Epoch(uint64(duty.Slot) / slotsPerEpoch) + sigRoot, err := eth2util.EpochHashRoot(epoch) + require.NoError(t, err) + + sigData, err := signing.GetDataRoot(context.Background(), bmock, signing.DomainRandao, epoch, sigRoot) + require.NoError(t, err) + + sig, pubkey := sign(t, sigData[:]) + + require.NoError(t, signing.VerifyRandao(context.Background(), bmock, pubkey, tblsconv.SigToETH2(sig), eth2p0.Slot(duty.Slot))) +} func TestVerifyVoluntaryExit(t *testing.T) { bmock, err := beaconmock.New() @@ -116,7 +114,7 @@ func TestVerifyVoluntaryExit(t *testing.T) { sig, pubkey := sign(t, sigData[:]) exit.Signature = tblsconv.SigToETH2(sig) - require.NoError(t, signing.VerifySignedData(context.Background(), bmock, pubkey, exit)) + require.NoError(t, signing.VerifyVoluntaryExit(context.Background(), bmock, pubkey, *exit)) } func TestVerifyBlindedBeaconBlock(t *testing.T) { @@ -144,7 +142,7 @@ func TestVerifyBlindedBeaconBlock(t *testing.T) { versionedBlock := data.(core.VersionedSignedBlindedBeaconBlock).VersionedSignedBlindedBeaconBlock - require.NoError(t, signing.VerifySignedData(context.Background(), bmock, pubkey, versionedBlock)) + require.NoError(t, signing.VerifyBlindedBlock(context.Background(), bmock, pubkey, versionedBlock)) } func TestVerifyBuilderRegistration(t *testing.T) { @@ -162,7 +160,7 @@ func TestVerifyBuilderRegistration(t *testing.T) { sig, pubkey := sign(t, sigData[:]) registration.V1.Signature = tblsconv.SigToETH2(sig) - require.NoError(t, signing.VerifySignedData(context.Background(), bmock, pubkey, registration)) + require.NoError(t, signing.VerifyValidatorRegistration(context.Background(), bmock, pubkey, registration)) } func sign(t *testing.T, data []byte) (*bls_sig.Signature, *bls_sig.PublicKey) { From a8db5f5e20150d3bfe0b17d6094166b706f4fdfa Mon Sep 17 00:00:00 2001 From: Dhruv Bodani Date: Wed, 10 Aug 2022 13:53:28 +0530 Subject: [PATCH 2/2] cleanup --- core/validatorapi/validatorapi.go | 10 +++++----- eth2util/signing/signing.go | 10 +++++----- eth2util/signing/signing_test.go | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/validatorapi/validatorapi.go b/core/validatorapi/validatorapi.go index 9f176af16..5e7cbeed2 100644 --- a/core/validatorapi/validatorapi.go +++ b/core/validatorapi/validatorapi.go @@ -260,7 +260,7 @@ func (c Component) SubmitAttestations(ctx context.Context, attestations []*eth2p // Verify attestation signature err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { - return signing.VerifyAttestation(ctx, c.eth2Cl, pubshare, *att) + return signing.VerifyAttestation(ctx, c.eth2Cl, pubshare, att) }) if err != nil { return err @@ -364,7 +364,7 @@ func (c Component) SubmitBeaconBlock(ctx context.Context, block *spec.VersionedS // Verify block signature err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { - return signing.VerifyBlock(ctx, c.eth2Cl, pubshare, *block) + return signing.VerifyBlock(ctx, c.eth2Cl, pubshare, block) }) if err != nil { return err @@ -457,7 +457,7 @@ func (c Component) SubmitBlindedBeaconBlock(ctx context.Context, block *eth2api. // Verify Blinded block signature err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { - return signing.VerifyBlindedBlock(ctx, c.eth2Cl, pubshare, *block) + return signing.VerifyBlindedBlock(ctx, c.eth2Cl, pubshare, block) }) if err != nil { return err @@ -508,7 +508,7 @@ func (c Component) submitRegistration(ctx context.Context, registration *eth2api ctx = log.WithCtx(ctx, z.Any("duty", duty)) err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { - return signing.VerifyValidatorRegistration(ctx, c.eth2Cl, pubshare, *registration) + return signing.VerifyValidatorRegistration(ctx, c.eth2Cl, pubshare, registration) }) if err != nil { return err @@ -579,7 +579,7 @@ func (c Component) SubmitVoluntaryExit(ctx context.Context, exit *eth2p0.SignedV // Verify voluntary exit signature err = c.verifyPartialSig(pubkey, func(pubshare *bls_sig.PublicKey) error { - return signing.VerifyVoluntaryExit(ctx, c.eth2Cl, pubshare, *exit) + return signing.VerifyVoluntaryExit(ctx, c.eth2Cl, pubshare, exit) }) if err != nil { return err diff --git a/eth2util/signing/signing.go b/eth2util/signing/signing.go index 165d2175f..82363b1f4 100644 --- a/eth2util/signing/signing.go +++ b/eth2util/signing/signing.go @@ -126,7 +126,7 @@ func GetDataRoot(ctx context.Context, eth2Cl Eth2Provider, name DomainName, epoc // //} -func VerifyAttestation(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, att eth2p0.Attestation) error { +func VerifyAttestation(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, att *eth2p0.Attestation) error { sigRoot, err := att.Data.HashTreeRoot() if err != nil { return errors.Wrap(err, "hash attestation data") @@ -135,7 +135,7 @@ func VerifyAttestation(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig return verify(ctx, eth2Cl, DomainBeaconAttester, att.Data.Target.Epoch, sigRoot, att.Signature, pubkey) } -func VerifyBlock(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, block spec.VersionedSignedBeaconBlock) error { +func VerifyBlock(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, block *spec.VersionedSignedBeaconBlock) error { slot, err := block.Slot() if err != nil { return err @@ -167,7 +167,7 @@ func VerifyBlock(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.Publi return verify(ctx, eth2Cl, DomainBeaconProposer, epoch, sigRoot, sig, pubkey) } -func VerifyBlindedBlock(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, block eth2api.VersionedSignedBlindedBeaconBlock) error { +func VerifyBlindedBlock(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, block *eth2api.VersionedSignedBlindedBeaconBlock) error { slot, err := block.Slot() if err != nil { return err @@ -210,7 +210,7 @@ func VerifyRandao(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.Publ return verify(ctx, eth2Cl, DomainRandao, epoch, sigRoot, randao, pubkey) } -func VerifyVoluntaryExit(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, exit eth2p0.SignedVoluntaryExit) error { +func VerifyVoluntaryExit(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, exit *eth2p0.SignedVoluntaryExit) error { sigRoot, err := exit.Message.HashTreeRoot() if err != nil { return err @@ -219,7 +219,7 @@ func VerifyVoluntaryExit(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_s return verify(ctx, eth2Cl, DomainExit, exit.Message.Epoch, sigRoot, exit.Signature, pubkey) } -func VerifyValidatorRegistration(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, reg eth2api.VersionedSignedValidatorRegistration) error { +func VerifyValidatorRegistration(ctx context.Context, eth2Cl Eth2Provider, pubkey *bls_sig.PublicKey, reg *eth2api.VersionedSignedValidatorRegistration) error { // TODO: switch to signed.Root() when implemented on go-eth2-client (PR has been raised) sigRoot, err := reg.V1.Message.HashTreeRoot() if err != nil { diff --git a/eth2util/signing/signing_test.go b/eth2util/signing/signing_test.go index 3844a9cd8..ad15b9b12 100644 --- a/eth2util/signing/signing_test.go +++ b/eth2util/signing/signing_test.go @@ -47,7 +47,7 @@ func TestVerifyAttestation(t *testing.T) { sig, pubkey := sign(t, sigData[:]) att.Signature = tblsconv.SigToETH2(sig) - require.NoError(t, signing.VerifyAttestation(context.Background(), bmock, pubkey, *att)) + require.NoError(t, signing.VerifyAttestation(context.Background(), bmock, pubkey, att)) } func TestVerifyBeaconBlock(t *testing.T) { @@ -75,7 +75,7 @@ func TestVerifyBeaconBlock(t *testing.T) { versionedBlock := data.(core.VersionedSignedBeaconBlock).VersionedSignedBeaconBlock - require.NoError(t, signing.VerifyBlock(context.Background(), bmock, pubkey, versionedBlock)) + require.NoError(t, signing.VerifyBlock(context.Background(), bmock, pubkey, &versionedBlock)) } func TestVerifyDutyRandao(t *testing.T) { @@ -114,7 +114,7 @@ func TestVerifyVoluntaryExit(t *testing.T) { sig, pubkey := sign(t, sigData[:]) exit.Signature = tblsconv.SigToETH2(sig) - require.NoError(t, signing.VerifyVoluntaryExit(context.Background(), bmock, pubkey, *exit)) + require.NoError(t, signing.VerifyVoluntaryExit(context.Background(), bmock, pubkey, exit)) } func TestVerifyBlindedBeaconBlock(t *testing.T) { @@ -142,7 +142,7 @@ func TestVerifyBlindedBeaconBlock(t *testing.T) { versionedBlock := data.(core.VersionedSignedBlindedBeaconBlock).VersionedSignedBlindedBeaconBlock - require.NoError(t, signing.VerifyBlindedBlock(context.Background(), bmock, pubkey, versionedBlock)) + require.NoError(t, signing.VerifyBlindedBlock(context.Background(), bmock, pubkey, &versionedBlock)) } func TestVerifyBuilderRegistration(t *testing.T) { @@ -160,7 +160,7 @@ func TestVerifyBuilderRegistration(t *testing.T) { sig, pubkey := sign(t, sigData[:]) registration.V1.Signature = tblsconv.SigToETH2(sig) - require.NoError(t, signing.VerifyValidatorRegistration(context.Background(), bmock, pubkey, registration)) + require.NoError(t, signing.VerifyValidatorRegistration(context.Background(), bmock, pubkey, ®istration)) } func sign(t *testing.T, data []byte) (*bls_sig.Signature, *bls_sig.PublicKey) {