Skip to content

Commit

Permalink
chore: fix go mod
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Dec 9, 2024
1 parent 6291a0e commit 0ab756c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
1 change: 1 addition & 0 deletions p2p/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/armon/go-radix v1.0.0
github.com/bufbuild/protovalidate-go v0.6.0
github.com/cloudflare/circl v1.5.0
github.com/cockroachdb/pebble v1.1.2
github.com/ethereum/go-ethereum v1.14.11
github.com/go-logr/logr v1.4.2
Expand Down
1 change: 1 addition & 0 deletions p2p/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I=
Expand Down
65 changes: 41 additions & 24 deletions p2p/pkg/rpc/provider/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
providerapiv1 "github.com/primev/mev-commit/p2p/gen/go/providerapi/v1"
providerapi "github.com/primev/mev-commit/p2p/pkg/rpc/provider"
"github.com/primev/mev-commit/x/util"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"
Expand Down Expand Up @@ -486,30 +487,46 @@ func TestBidHandling(t *testing.T) {
}
}

// func TestBLSKeys(t *testing.T) {

// iv := make([]byte, 32)
// _, err := rand.Read(iv)
// assert.NoError(t, err)
// blsPrivKey, err := bls.KeyGen[bls.G1](iv, []byte{}, []byte{})
// assert.NoError(t, err)

// pubKey := blsPrivKey.PublicKey()

// // Keccak the value 0x53c61cfb8128ad59244e8c1d26109252ace23d14
// value := common.Hex2Bytes("53c61cfb8128ad59244e8c1d26109252ace23d14")
// hash := crypto.Keccak256Hash(value)
// t.Logf("Keccak hash: %s", hash.Hex())

// signature := bls.Sign(blsPrivKey, hash.Bytes())
// pubKeyBytes, _ := pubKey.MarshalBinary()
// if !bls.Verify[bls.G1](pubKeyBytes, hash.Bytes(), signature) {
// t.Errorf("Signature verification failed")
// }
// // return nil, nil
// // }
// // return input[:48], nil
// }
func TestBLSKeys(t *testing.T) {

iv := make([]byte, 32)
_, err := rand.Read(iv)
assert.NoError(t, err)
blsPrivKey, err := bls.KeyGen[bls.G1](iv, []byte{}, []byte{})
assert.NoError(t, err)

pubKey := blsPrivKey.PublicKey()

// Keccak the value 0x53c61cfb8128ad59244e8c1d26109252ace23d14
value := common.Hex2Bytes("53c61cfb8128ad59244e8c1d26109252ace23d14")
hash := crypto.Keccak256Hash(value)
t.Logf("Keccak hash: %s", hash.Hex())

signature := bls.Sign(blsPrivKey, hash.Bytes())
pubKeyBytes, _ := pubKey.MarshalBinary()
encodedPubKey := hex.EncodeToString(pubKeyBytes)
t.Logf("Encoded Public Key: %s", encodedPubKey)

encodedSignature := hex.EncodeToString(signature)
t.Logf("Encoded Signature: %s", encodedSignature)

pubKey2, err := hex.DecodeString(encodedPubKey)
assert.NoError(t, err)

var pubkey2bytes bls.PublicKey[bls.G1]
if err := pubkey2bytes.UnmarshalBinary(pubKey2); err != nil {
t.Fatalf("error unmarshalling public key: %v", err)
}

signature2, err := hex.DecodeString(encodedSignature)

if !bls.Verify[bls.G1](&pubkey2bytes, hash.Bytes(), signature2) {
t.Errorf("Signature verification failed")
}
// return nil, nil
// }
// return input[:48], nil
}

func TestWithdrawStakedAmount(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit 0ab756c

Please sign in to comment.