diff --git a/chainio/clients/avsregistry/writer_test.go b/chainio/clients/avsregistry/writer_test.go index 11537dc5..79326d6b 100644 --- a/chainio/clients/avsregistry/writer_test.go +++ b/chainio/clients/avsregistry/writer_test.go @@ -6,10 +6,12 @@ import ( chainioutils "github.com/Layr-Labs/eigensdk-go/chainio/utils" "github.com/Layr-Labs/eigensdk-go/crypto/bls" + "github.com/Layr-Labs/eigensdk-go/testutils" "github.com/Layr-Labs/eigensdk-go/testutils/testclients" "github.com/Layr-Labs/eigensdk-go/types" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -72,3 +74,33 @@ func TestWriterMethods(t *testing.T) { require.NotNil(t, receipt) }) } + +func TestBlsSignature(t *testing.T) { + // read input from JSON if available, otherwise use default values + var defaultInput = struct { + Message string `json:"message"` + BlsPrivKey string `json:"bls_priv_key"` + }{ + Message: "Hello, world!Hello, world!123456", + BlsPrivKey: "12248929636257230549931416853095037629726205319386239410403476017439825112537", + } + + testData := testutils.NewTestData(defaultInput) + // The message to sign + messageArray := []byte(testData.Input.Message) + + var messageArray32 [32]byte + copy(messageArray32[:], messageArray) + + // The private key as a string + privKey, _ := bls.NewPrivateKey(testData.Input.BlsPrivKey) + keyPair := bls.NewKeyPair(privKey) + + sig := keyPair.SignMessage(messageArray32) + + x := sig.G1Affine.X.String() + y := sig.G1Affine.Y.String() + + assert.Equal(t, x, "15790168376429033610067099039091292283117017641532256477437243974517959682102") + assert.Equal(t, y, "4960450323239587206117776989095741074887370703941588742100855592356200866613") +}