diff --git a/precompiles/avs/IAVSManager.sol b/precompiles/avs/IAVSManager.sol index 9b62e9fa4..9450d3cc5 100644 --- a/precompiles/avs/IAVSManager.sol +++ b/precompiles/avs/IAVSManager.sol @@ -195,14 +195,16 @@ interface IAVSManager { /// @param sender The external address for calling this method. /// @param avsAddress The address of AVS. /// @param pubKey the public keys of the operator - /// @param pubkeyRegistrationSignature the public keys of the operator - /// @param pubkeyRegistrationMessageHash the public keys of the operator + /// @param pubKeyRegistrationSignature the public keys of the operator + /// @param pubKeyRegistrationMessageHash the public keys of the operator + /// @param msg is the message which signed using a private key function registerBLSPublicKey( address sender, address avsAddress, bytes calldata pubKey, - bytes calldata pubkeyRegistrationSignature, - bytes calldata pubkeyRegistrationMessageHash + bytes calldata pubKeyRegistrationSignature, + bytes calldata pubKeyRegistrationMessageHash, + string msg ) external returns (bool success); /// @dev operatorSubmitTask , this function enables a operator submit a task result. diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 67db55608..eb23bbf7a 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -314,14 +314,19 @@ func (p Precompile) RegisterBLSPublicKey( if !ok { return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 3, "[]byte", pubKeyRegistrationSignature) } - blsParams.PubkeyRegistrationSignature = pubKeyRegistrationSignature + blsParams.PubKeyRegistrationSignature = pubKeyRegistrationSignature pubKeyRegistrationMessageHash, ok := args[4].([]byte) if !ok { return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 4, "[]byte", pubKeyRegistrationMessageHash) } - blsParams.PubkeyRegistrationMessageHash = pubKeyRegistrationMessageHash + blsParams.PubKeyRegistrationMessageHash = pubKeyRegistrationMessageHash + msg, ok := args[5].(string) + if !ok { + return nil, fmt.Errorf(exocmn.ErrContractInputParamOrType, 5, "string", msg) + } + blsParams.Message = msg err := p.avsKeeper.RegisterBLSPublicKey(ctx, blsParams) if err != nil { return nil, err diff --git a/x/avs/keeper/avs_test.go b/x/avs/keeper/avs_test.go index 68e7b0544..7b74daf54 100644 --- a/x/avs/keeper/avs_test.go +++ b/x/avs/keeper/avs_test.go @@ -211,11 +211,11 @@ func (suite *AVSTestSuite) TestRegisterBLSPublicKey() { OperatorAddress: operatorAddress, AvsAddress: testutiltx.GenerateAddress(), PubKey: publicKey.Marshal(), - PubkeyRegistrationSignature: sig.Marshal(), - PubkeyRegistrationMessageHash: expectedHash.Bytes(), + PubKeyRegistrationSignature: sig.Marshal(), + PubKeyRegistrationMessageHash: expectedHash.Bytes(), Message: expectedMessage, } - + err = suite.App.AVSManagerKeeper.RegisterBLSPublicKey(suite.Ctx, params) suite.NoError(err) diff --git a/x/avs/keeper/keeper.go b/x/avs/keeper/keeper.go index cc477dcf2..e5b2aaeeb 100644 --- a/x/avs/keeper/keeper.go +++ b/x/avs/keeper/keeper.go @@ -298,14 +298,14 @@ func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *types.BlsParams) e return fmt.Errorf("invalid message format: %s", params.Message) } // check msg hash - msgHash := params.PubkeyRegistrationMessageHash + msgHash := params.PubKeyRegistrationMessageHash expectedHash := crypto.Keccak256Hash([]byte(expectedMessage)) if !bytes.Equal(msgHash, expectedHash.Bytes()) { return fmt.Errorf("the input hash failed to validate: %s", params.Message) } - sig := params.PubkeyRegistrationSignature + sig := params.PubKeyRegistrationSignature pubKey, _ := bls.PublicKeyFromBytes(params.PubKey) valid, err := blst.VerifySignature(sig, [32]byte(msgHash), pubKey) if err != nil || !valid { @@ -323,7 +323,7 @@ func (k Keeper) RegisterBLSPublicKey(ctx sdk.Context, params *types.BlsParams) e // if operator are using multiple servers for different AVSs . // In case one server is compromised, signing can continue as expected on the AVSs for which there has been no compromise. if k.IsExistPubKey(ctx, blsInfo) { - return errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the bls key is already exists:%s", bls.PubKey)) + return errorsmod.Wrap(types.ErrAlreadyExists, fmt.Sprintf("the bls key is already exists:%s", blsInfo.PubKey)) } return k.SetOperatorPubKey(ctx, blsInfo) } diff --git a/x/avs/types/utils.go b/x/avs/types/utils.go index 46f6232db..0788005c5 100644 --- a/x/avs/types/utils.go +++ b/x/avs/types/utils.go @@ -42,8 +42,8 @@ type BlsParams struct { OperatorAddress sdk.AccAddress AvsAddress common.Address PubKey []byte - PubkeyRegistrationSignature []byte - PubkeyRegistrationMessageHash []byte + PubKeyRegistrationSignature []byte + PubKeyRegistrationMessageHash []byte Message string }