Skip to content

Commit

Permalink
fix: generate blspubkeys for providers
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Jul 8, 2024
1 parent 85d29c1 commit b37c377
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion p2p/integrationtest/provider/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package main

import (
"context"
"crypto/rand"
"crypto/tls"
"encoding/hex"
"errors"
"log/slog"
"math/big"
"time"

bls "github.com/ethereum/go-ethereum/crypto/bls12381"
providerapiv1 "github.com/primev/mev-commit/p2p/gen/go/providerapi/v1"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -109,8 +112,15 @@ func (b *ProviderClient) CheckAndStake() error {
return nil
}

g1 := bls.NewG1()
privKey, _ := rand.Int(rand.Reader, g1.Q())
blsPubkey := g1.One()
g1.MulScalar(blsPubkey, blsPubkey, privKey)
blsPubkeyBytes := g1.ToBytes(blsPubkey)

_, err = b.client.RegisterStake(context.Background(), &providerapiv1.StakeRequest{
Amount: "10000000000000000000",
Amount: "10000000000000000000",
BlsPublicKey: hex.EncodeToString(blsPubkeyBytes),
})
if err != nil {
b.logger.Error("failed to register stake", "err", err)
Expand Down

0 comments on commit b37c377

Please sign in to comment.