diff --git a/proto/side/btcbridge/bitcoin.proto b/proto/side/btcbridge/bitcoin.proto index c3e53761..1c376b85 100644 --- a/proto/side/btcbridge/bitcoin.proto +++ b/proto/side/btcbridge/bitcoin.proto @@ -101,5 +101,9 @@ message DKGCompletionRequest { // sender string sender = 2; // new vaults generated by DKG - repeated Vault vaults = 3; + repeated string vaults = 3; + // validator address + string validator = 4; + // hex encoded validator signature + string signature = 5; } diff --git a/proto/side/btcbridge/tx.proto b/proto/side/btcbridge/tx.proto index 8035c519..766c5751 100644 --- a/proto/side/btcbridge/tx.proto +++ b/proto/side/btcbridge/tx.proto @@ -112,12 +112,16 @@ message MsgInitiateDKGResponse {} // MsgCompleteDKG is the Msg/CompleteDKG request type. message MsgCompleteDKG { - // the sender is expected to be the validator which participates in DKG + // the sender string sender = 1; - // request id + // DKG request id uint64 id = 2; // new vaults generated by DKG - repeated Vault vaults = 3; + repeated string vaults = 3; + // validator address + string validator = 4; + // hex encoded validator signature + string signature = 5; } // MsgCompleteDKGResponse defines the Msg/CompleteDKG response type. diff --git a/x/btcbridge/abci.go b/x/btcbridge/abci.go index df891334..bdb98f6d 100644 --- a/x/btcbridge/abci.go +++ b/x/btcbridge/abci.go @@ -25,14 +25,15 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) { } // check if the DKG completion requests are valid - if !types.CheckCompletionRequests(completionRequests) { + if !types.CheckDKGCompletionRequests(completionRequests) { req.Status = types.DKGRequestStatus_DKG_REQUEST_STATUS_FAILED continue } - req.Status = types.DKGRequestStatus_DKG_REQUEST_STATUS_COMPLETED - // update vaults k.UpdateVaults(ctx, completionRequests[0].Vaults) + + // update status + req.Status = types.DKGRequestStatus_DKG_REQUEST_STATUS_COMPLETED } } diff --git a/x/btcbridge/keeper/keeper_tss.go b/x/btcbridge/keeper/keeper_tss.go index b020ce14..6c74d410 100644 --- a/x/btcbridge/keeper/keeper_tss.go +++ b/x/btcbridge/keeper/keeper_tss.go @@ -120,14 +120,14 @@ func (k Keeper) SetDKGCompletionRequest(ctx sdk.Context, req *types.DKGCompletio store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(req) - store.Set(types.DKGCompletionRequestKey(req.Id, req.Sender), bz) + store.Set(types.DKGCompletionRequestKey(req.Id, req.Validator), bz) } // HasDKGCompletionRequest returns true if the given completion request exists, false otherwise -func (k Keeper) HasDKGCompletionRequest(ctx sdk.Context, id uint64, sender string) bool { +func (k Keeper) HasDKGCompletionRequest(ctx sdk.Context, id uint64, validator string) bool { store := ctx.KVStore(k.storeKey) - return store.Has(types.DKGCompletionRequestKey(id, sender)) + return store.Has(types.DKGCompletionRequestKey(id, validator)) } // GetDKGCompletionRequests gets DKG completion requests by the given id @@ -175,18 +175,31 @@ func (k Keeper) CompleteDKG(ctx sdk.Context, req *types.DKGCompletionRequest) er return types.ErrInvalidDKGCompletionRequest } - if k.HasDKGCompletionRequest(ctx, req.Id, req.Sender) { + if k.HasDKGCompletionRequest(ctx, req.Id, req.Validator) { return types.ErrDKGCompletionRequestExists } - if !types.ParticipantExists(dkgReq.Participants, req.Sender) { + validatorConsAddr, _ := sdk.ConsAddressFromHex(req.Validator) + validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, validatorConsAddr) + if !found { + return types.ErrInvalidDKGCompletionRequest + } + + if !types.ParticipantExists(dkgReq.Participants, validator.OperatorAddress) { return types.ErrUnauthorizedDKGCompletionRequest } - for _, v := range req.Vaults { - if types.SelectVaultByPubKey(k.GetParams(ctx).Vaults, v.PubKey) != nil { - return types.ErrInvalidDKGCompletionRequest - } + if err := k.CheckVaults(ctx, req.Vaults); err != nil { + return err + } + + pubKey, err := validator.ConsPubKey() + if err != nil { + return err + } + + if !types.VerifySignature(req.Signature, pubKey.Bytes(), req) { + return types.ErrInvalidDKGCompletionRequest } k.SetDKGCompletionRequest(ctx, req) @@ -194,22 +207,36 @@ func (k Keeper) CompleteDKG(ctx sdk.Context, req *types.DKGCompletionRequest) er return nil } -// UpdateVaults updates the asset vaults of the btc bridge -func (k Keeper) UpdateVaults(ctx sdk.Context, newVaults []*types.Vault) { - params := k.GetParams(ctx) +// CheckVaults checks if the provided vaults are valid +func (k Keeper) CheckVaults(ctx sdk.Context, vaults []string) error { + currentVaults := k.GetParams(ctx).Vaults - for _, v := range newVaults { - address, err := types.GetVaultAddressFromPubKey(v.PubKey) - if err != nil { - panic(err) + if len(vaults) != len(currentVaults) { + return types.ErrInvalidDKGCompletionRequest + } + + for _, v := range vaults { + if types.SelectVaultByBitcoinAddress(currentVaults, v) != nil { + return types.ErrInvalidDKGCompletionRequest } + } - v.Address = address + return nil +} - // TODO - v.Version = 1 +// UpdateVaults updates the asset vaults of the btc bridge +func (k Keeper) UpdateVaults(ctx sdk.Context, newVaults []string) { + params := k.GetParams(ctx) + + for i, v := range newVaults { + newVault := &types.Vault{ + Address: v, + AssetType: params.Vaults[i].AssetType, + // TODO + Version: 1, + } - params.Vaults = append(params.Vaults, v) + params.Vaults = append(params.Vaults, newVault) } k.SetParams(ctx, params) diff --git a/x/btcbridge/types/bitcoin.go b/x/btcbridge/types/bitcoin.go index 5296b983..ca96f7e3 100644 --- a/x/btcbridge/types/bitcoin.go +++ b/x/btcbridge/types/bitcoin.go @@ -1,13 +1,10 @@ package types import ( - "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/decred/dcrd/dcrec/secp256k1/v4" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -23,11 +20,6 @@ const ( DefaultSigHashType = txscript.SigHashAll ) -// GetTaprootAddress gets the taproot address from the given public key -func GetTaprootAddress(pubKey *secp256k1.PublicKey, chainCfg *chaincfg.Params) (*btcutil.AddressTaproot, error) { - return btcutil.NewAddressTaproot(schnorr.SerializePubKey(txscript.ComputeTaprootKeyNoScript(pubKey)), chainCfg) -} - // IsDustOut returns true if the given output is dust, false otherwise func IsDustOut(out *wire.TxOut) bool { return !IsOpReturnOutput(out) && mempool.IsDust(out, MinRelayFee) diff --git a/x/btcbridge/types/bitcoin.pb.go b/x/btcbridge/types/bitcoin.pb.go index dd0691e2..3793cc27 100644 --- a/x/btcbridge/types/bitcoin.pb.go +++ b/x/btcbridge/types/bitcoin.pb.go @@ -547,7 +547,11 @@ type DKGCompletionRequest struct { // sender Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"` // new vaults generated by DKG - Vaults []*Vault `protobuf:"bytes,3,rep,name=vaults,proto3" json:"vaults,omitempty"` + Vaults []string `protobuf:"bytes,3,rep,name=vaults,proto3" json:"vaults,omitempty"` + // validator address + Validator string `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty"` + // hex encoded validator signature + Signature string `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` } func (m *DKGCompletionRequest) Reset() { *m = DKGCompletionRequest{} } @@ -597,13 +601,27 @@ func (m *DKGCompletionRequest) GetSender() string { return "" } -func (m *DKGCompletionRequest) GetVaults() []*Vault { +func (m *DKGCompletionRequest) GetVaults() []string { if m != nil { return m.Vaults } return nil } +func (m *DKGCompletionRequest) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *DKGCompletionRequest) GetSignature() string { + if m != nil { + return m.Signature + } + return "" +} + func init() { proto.RegisterEnum("side.btcbridge.WithdrawStatus", WithdrawStatus_name, WithdrawStatus_value) proto.RegisterEnum("side.btcbridge.DKGRequestStatus", DKGRequestStatus_name, DKGRequestStatus_value) @@ -619,61 +637,62 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/bitcoin.proto", fileDescriptor_b004a69efe3c7d84) } var fileDescriptor_b004a69efe3c7d84 = []byte{ - // 856 bytes of a gzipped FileDescriptorProto + // 875 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x41, 0x6f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5b, 0xb0, 0xe9, 0xcd, 0x29, 0x71, 0x7d, 0x12, 0x23, 0x1d, 0x9e, 0xdf, 0x92, 0x98, - 0x53, 0x16, 0xea, 0xda, 0xa1, 0x76, 0x54, 0xc6, 0x39, 0x44, 0x08, 0xca, 0x73, 0x97, 0xcf, 0xf5, - 0xe2, 0xa1, 0x76, 0x54, 0xc5, 0x6a, 0x8d, 0x9a, 0x50, 0x99, 0x13, 0x3a, 0x9b, 0x0b, 0xbd, 0xa4, - 0xc4, 0x19, 0x42, 0x26, 0x7c, 0x16, 0xc5, 0xe4, 0x96, 0xb2, 0x84, 0x4f, 0x3c, 0xb9, 0xfb, 0x44, - 0x95, 0x96, 0x55, 0xe9, 0xa7, 0x39, 0x95, 0xf6, 0x95, 0xfb, 0xb4, 0xa1, 0x16, 0x90, 0xf8, 0x66, - 0x41, 0x26, 0x31, 0x63, 0x42, 0x7f, 0xa6, 0x74, 0x90, 0x7e, 0xc2, 0x8c, 0x09, 0xb4, 0x0b, 0xcf, - 0x42, 0x16, 0x4e, 0x89, 0x5e, 0x51, 0x7d, 0x52, 0x20, 0x2d, 0x79, 0x54, 0x70, 0xfd, 0x79, 0x6a, - 0x49, 0xae, 0xe5, 0x37, 0x99, 0x9d, 0xbe, 0xa3, 0x84, 0x6a, 0x8d, 0x1a, 0x50, 0x0a, 0xc5, 0x52, - 0xaf, 0xaa, 0x4f, 0x72, 0xd9, 0xf9, 0x43, 0x83, 0x66, 0x2f, 0x1d, 0xe1, 0x35, 0x15, 0x73, 0x3f, - 0x76, 0x7f, 0xc5, 0xe4, 0x97, 0x84, 0x70, 0x21, 0x13, 0x70, 0x7d, 0x3f, 0x26, 0x9c, 0xab, 0x04, - 0xaa, 0x38, 0x87, 0xe8, 0x3b, 0xa8, 0xb8, 0x01, 0x4b, 0x42, 0xa1, 0x32, 0xa8, 0x1d, 0xef, 0x99, - 0x59, 0xce, 0x72, 0x28, 0x66, 0x36, 0x14, 0xb3, 0xcf, 0x68, 0xd8, 0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x3e, 0x1b, 0x4c, 0xb0, 0xf3, 0xc3, 0x95, 0x33, 0x1a, - 0x6f, 0x77, 0x65, 0x40, 0x6b, 0x8b, 0xe6, 0xd2, 0x39, 0xb7, 0x87, 0xe7, 0x83, 0x86, 0x86, 0x0e, - 0xe1, 0x60, 0x0b, 0xdf, 0xbf, 0x78, 0x73, 0xf9, 0xda, 0x59, 0x39, 0xdb, 0xa2, 0x38, 0xe9, 0x0e, - 0x5f, 0x4b, 0x67, 0xbd, 0xd3, 0xbb, 0x7b, 0x43, 0x7b, 0x7f, 0x6f, 0x68, 0x7f, 0xdf, 0x1b, 0xda, - 0xbb, 0x07, 0xa3, 0xf0, 0xfe, 0xc1, 0x28, 0xfc, 0xf9, 0x60, 0x14, 0x7e, 0x32, 0x67, 0x54, 0xcc, - 0x13, 0xcf, 0x9c, 0xb2, 0xc0, 0x92, 0x69, 0xab, 0x6b, 0x32, 0x65, 0x0b, 0x05, 0xac, 0xe5, 0x93, - 0xff, 0xb1, 0x78, 0x1b, 0x11, 0xee, 0x55, 0x94, 0xe0, 0x9b, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, - 0xe1, 0x18, 0xd8, 0xec, 0x69, 0x06, 0x00, 0x00, + 0x14, 0x8e, 0x81, 0xb0, 0xe1, 0xd1, 0x45, 0x74, 0x1a, 0x51, 0x87, 0xa4, 0x06, 0x71, 0xa8, 0xa2, + 0x3d, 0xd8, 0xda, 0x54, 0x6a, 0x7b, 0x05, 0xec, 0x10, 0x94, 0xdd, 0x24, 0x35, 0x44, 0x91, 0x7a, + 0x41, 0x63, 0x3c, 0x85, 0x51, 0xc0, 0xe3, 0x7a, 0xc6, 0x94, 0xfd, 0x13, 0xd5, 0xaa, 0x97, 0xfe, + 0xa5, 0x1c, 0x57, 0xea, 0xa5, 0xa7, 0x6d, 0x95, 0xfc, 0x85, 0x9e, 0xab, 0x6a, 0xc6, 0x36, 0x04, + 0x96, 0xde, 0xde, 0xf7, 0xde, 0xf7, 0x3c, 0xdf, 0x7c, 0xef, 0x8d, 0xe1, 0x84, 0x53, 0x9f, 0x58, + 0x9e, 0x18, 0x7b, 0x11, 0xf5, 0x27, 0xc4, 0xf2, 0xa8, 0x18, 0x33, 0x1a, 0x98, 0x61, 0xc4, 0x04, + 0x43, 0x15, 0x59, 0x35, 0x57, 0xd5, 0xfa, 0xe1, 0x84, 0x4d, 0x98, 0x2a, 0x59, 0x32, 0x4a, 0x58, + 0xf5, 0xa3, 0x09, 0x63, 0x93, 0x19, 0xb1, 0x14, 0xf2, 0xe2, 0x9f, 0x2c, 0x1c, 0xbc, 0x4b, 0x4b, + 0x8d, 0xed, 0x92, 0xa0, 0x73, 0xc2, 0x05, 0x9e, 0x87, 0x29, 0xc1, 0x18, 0x33, 0x3e, 0x67, 0xdc, + 0xf2, 0x30, 0x27, 0xd6, 0xe2, 0xb5, 0x47, 0x04, 0x7e, 0x6d, 0xad, 0x15, 0xd4, 0x8f, 0x92, 0xfa, + 0x28, 0x39, 0x34, 0x01, 0x69, 0xe9, 0x78, 0x4b, 0x7a, 0x88, 0x23, 0x3c, 0x4f, 0x8b, 0xad, 0x7f, + 0x34, 0x28, 0x77, 0x66, 0x6c, 0x7c, 0x7f, 0x41, 0xb0, 0x4f, 0x22, 0xa4, 0xc3, 0x8b, 0x05, 0x89, + 0x38, 0x65, 0x81, 0xae, 0x35, 0xb5, 0xd3, 0x82, 0x9b, 0x41, 0x84, 0xa0, 0x30, 0xc5, 0x7c, 0xaa, + 0xe7, 0x9a, 0xda, 0x69, 0xc9, 0x55, 0x31, 0xaa, 0x41, 0x71, 0x4a, 0xe8, 0x64, 0x2a, 0xf4, 0xbc, + 0x22, 0xa7, 0x08, 0x99, 0xf0, 0x45, 0x18, 0x91, 0x05, 0x65, 0x31, 0x1f, 0x79, 0xf2, 0xeb, 0x23, + 0xd5, 0x5a, 0x50, 0xad, 0x9f, 0x67, 0xa5, 0xe4, 0x5c, 0xf9, 0x9d, 0x06, 0x94, 0xe7, 0x24, 0x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 0x7b, 0xff, 0x64, 0xec, 0x7d, 0x78, 0x32, 0xf6, 0xfe, 0x7c, 0x32, 0xf6, 0x7e, 0x34, + 0x27, 0x54, 0x4c, 0x63, 0xcf, 0x1c, 0xb3, 0xb9, 0x25, 0xb7, 0x41, 0x2d, 0xd3, 0x98, 0xcd, 0x14, + 0xb0, 0x96, 0xcf, 0xfe, 0xda, 0xe2, 0x5d, 0x48, 0xb8, 0x57, 0x54, 0x84, 0x6f, 0xfe, 0x0b, 0x00, + 0x00, 0xff, 0xff, 0x21, 0x06, 0x83, 0xb9, 0x8f, 0x06, 0x00, 0x00, } func (m *BlockHeader) Marshal() (dAtA []byte, err error) { @@ -1008,16 +1027,25 @@ func (m *DKGCompletionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x2a + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0x22 + } if len(m.Vaults) > 0 { for iNdEx := len(m.Vaults) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Vaults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBitcoin(dAtA, i, uint64(size)) - } + i -= len(m.Vaults[iNdEx]) + copy(dAtA[i:], m.Vaults[iNdEx]) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Vaults[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -1207,11 +1235,19 @@ func (m *DKGCompletionRequest) Size() (n int) { n += 1 + l + sovBitcoin(uint64(l)) } if len(m.Vaults) > 0 { - for _, e := range m.Vaults { - l = e.Size() + for _, s := range m.Vaults { + l = len(s) n += 1 + l + sovBitcoin(uint64(l)) } } + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } return n } @@ -2279,7 +2315,7 @@ func (m *DKGCompletionRequest) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Vaults", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBitcoin @@ -2289,25 +2325,87 @@ func (m *DKGCompletionRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthBitcoin } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthBitcoin } if postIndex > l { return io.ErrUnexpectedEOF } - m.Vaults = append(m.Vaults, &Vault{}) - if err := m.Vaults[len(m.Vaults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Vaults = append(m.Vaults, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.Signature = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/btcbridge/types/keys.go b/x/btcbridge/types/keys.go index d629aec1..5779610a 100644 --- a/x/btcbridge/types/keys.go +++ b/x/btcbridge/types/keys.go @@ -70,6 +70,6 @@ func DKGRequestKey(id uint64) []byte { return append(DKGRequestKeyPrefix, Int64ToBytes(id)...) } -func DKGCompletionRequestKey(id uint64, sender string) []byte { - return append(append(DKGCompletionRequestKeyPrefix, Int64ToBytes(id)...), []byte(sender)...) +func DKGCompletionRequestKey(id uint64, validator string) []byte { + return append(append(DKGCompletionRequestKeyPrefix, Int64ToBytes(id)...), []byte(validator)...) } diff --git a/x/btcbridge/types/message_complete_dkg.go b/x/btcbridge/types/message_complete_dkg.go index d38a0925..d5f6c4b1 100644 --- a/x/btcbridge/types/message_complete_dkg.go +++ b/x/btcbridge/types/message_complete_dkg.go @@ -1,6 +1,9 @@ package types import ( + "encoding/hex" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -30,12 +33,25 @@ func (m *MsgCompleteDKG) GetSigners() []sdk.AccAddress { // ValidateBasic performs basic MsgCompleteDKG message validation. func (m *MsgCompleteDKG) ValidateBasic() error { - if _, err := sdk.ConsAddressFromBech32(m.Sender); err != nil { + if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { return sdkerrors.Wrap(err, "invalid sender address") } - if len(m.Vaults) != 2 { - return ErrInvalidDKGParams + if len(m.Vaults) == 0 { + return ErrInvalidDKGCompletionRequest + } + + if _, err := sdk.ConsAddressFromHex(m.Validator); err != nil { + return ErrInvalidDKGCompletionRequest + } + + sigBytes, err := hex.DecodeString(m.Signature) + if err != nil { + return ErrInvalidDKGCompletionRequest + } + + if len(sigBytes) != ed25519.SignatureSize { + return ErrInvalidDKGCompletionRequest } return nil diff --git a/x/btcbridge/types/tss.go b/x/btcbridge/types/tss.go index d75d31f0..b83823a9 100644 --- a/x/btcbridge/types/tss.go +++ b/x/btcbridge/types/tss.go @@ -1,12 +1,11 @@ package types import ( + "crypto/ed25519" "encoding/hex" "reflect" - "github.com/btcsuite/btcd/btcec/v2/schnorr" - - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cometbft/cometbft/crypto" ) // ParticipantExists returns true if the given address is a participant, false otherwise @@ -20,8 +19,8 @@ func ParticipantExists(participants []*DKGParticipant, addr string) bool { return false } -// CheckCompletionRequests checks if the vaults of all the completion requests are same -func CheckCompletionRequests(requests []*DKGCompletionRequest) bool { +// CheckDKGCompletionRequests checks if the vaults of all the DKG completion requests are same +func CheckDKGCompletionRequests(requests []*DKGCompletionRequest) bool { if len(requests) == 0 { return false } @@ -37,23 +36,25 @@ func CheckCompletionRequests(requests []*DKGCompletionRequest) bool { return true } -// GetVaultAddressFromPubKey gets the vault address from the given public key -// Note: the method generates taproot address -func GetVaultAddressFromPubKey(pubKey string) (string, error) { - pubKeyBytes, err := hex.DecodeString(pubKey) +// VerifySignature verifies the given signature against the given DKG completion request +func VerifySignature(signature string, pubKey []byte, req *DKGCompletionRequest) bool { + sig, err := hex.DecodeString(signature) if err != nil { - return "", err + return false } - parsedPubKey, err := schnorr.ParsePubKey(pubKeyBytes) - if err != nil { - return "", err - } + sigMsg := GetSigMsgFromDKGCompletionReq(req) - address, err := GetTaprootAddress(parsedPubKey, sdk.GetConfig().GetBtcChainCfg()) - if err != nil { - return "", err + return ed25519.Verify(pubKey, sigMsg, sig) +} + +// GetSigMsgFromDKGCompletionReq gets the msg to be signed from the given DKG completion request +func GetSigMsgFromDKGCompletionReq(req *DKGCompletionRequest) []byte { + rawMsg := Int64ToBytes(req.Id) + + for _, v := range req.Vaults { + rawMsg = append(rawMsg, []byte(v)...) } - return address.String(), nil + return crypto.Sha256(rawMsg) } diff --git a/x/btcbridge/types/tx.pb.go b/x/btcbridge/types/tx.pb.go index 2f96cea7..937f7091 100644 --- a/x/btcbridge/types/tx.pb.go +++ b/x/btcbridge/types/tx.pb.go @@ -653,12 +653,16 @@ var xxx_messageInfo_MsgInitiateDKGResponse proto.InternalMessageInfo // MsgCompleteDKG is the Msg/CompleteDKG request type. type MsgCompleteDKG struct { - // the sender is expected to be the validator which participates in DKG + // the sender Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // request id + // DKG request id Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` // new vaults generated by DKG - Vaults []*Vault `protobuf:"bytes,3,rep,name=vaults,proto3" json:"vaults,omitempty"` + Vaults []string `protobuf:"bytes,3,rep,name=vaults,proto3" json:"vaults,omitempty"` + // validator address + Validator string `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty"` + // hex encoded validator signature + Signature string `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` } func (m *MsgCompleteDKG) Reset() { *m = MsgCompleteDKG{} } @@ -708,13 +712,27 @@ func (m *MsgCompleteDKG) GetId() uint64 { return 0 } -func (m *MsgCompleteDKG) GetVaults() []*Vault { +func (m *MsgCompleteDKG) GetVaults() []string { if m != nil { return m.Vaults } return nil } +func (m *MsgCompleteDKG) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *MsgCompleteDKG) GetSignature() string { + if m != nil { + return m.Signature + } + return "" +} + // MsgCompleteDKGResponse defines the Msg/CompleteDKG response type. type MsgCompleteDKGResponse struct { } @@ -872,56 +890,58 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/tx.proto", fileDescriptor_785ca8e1e4227068) } var fileDescriptor_785ca8e1e4227068 = []byte{ - // 780 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcb, 0x4e, 0xf3, 0x46, - 0x18, 0x8d, 0x93, 0x90, 0x92, 0x2f, 0x90, 0xaa, 0x56, 0x08, 0xc6, 0x50, 0x27, 0x75, 0xb9, 0x44, - 0x2a, 0x24, 0x52, 0x40, 0x5d, 0x57, 0x29, 0x2a, 0x54, 0x28, 0x12, 0x32, 0xd0, 0x56, 0xdd, 0x20, - 0x5f, 0xa6, 0xf6, 0xb4, 0x89, 0xc7, 0x78, 0x26, 0x34, 0x48, 0x95, 0xfa, 0x0a, 0x6c, 0xfb, 0x06, - 0xed, 0x9b, 0xb0, 0x44, 0xea, 0xa6, 0xab, 0xaa, 0x82, 0x17, 0xa9, 0x7c, 0xc9, 0xc4, 0x49, 0x6c, - 0x2e, 0xbb, 0x7f, 0xe7, 0x99, 0x73, 0xe6, 0x9c, 0x33, 0x9f, 0xf3, 0x7d, 0x31, 0xac, 0x53, 0x6c, - 0xa1, 0x8e, 0xc1, 0x4c, 0xc3, 0xc7, 0x96, 0x8d, 0x3a, 0x6c, 0xdc, 0xf6, 0x7c, 0xc2, 0x88, 0x58, - 0x0d, 0x80, 0x36, 0x07, 0xe4, 0x9a, 0x4d, 0x6c, 0x12, 0x42, 0x9d, 0xe0, 0x29, 0x62, 0xc9, 0x9b, - 0x73, 0xc7, 0x3d, 0xdd, 0xd7, 0x87, 0x34, 0x06, 0xb7, 0xe6, 0x40, 0x03, 0x33, 0x93, 0x60, 0x37, - 0x42, 0xd5, 0x3f, 0x04, 0x58, 0xef, 0x53, 0xfb, 0x62, 0x64, 0x0c, 0x31, 0xfb, 0x1e, 0x33, 0xc7, - 0xf2, 0xf5, 0x5f, 0x2f, 0x98, 0xce, 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x89, 0x72, 0xef, 0xf4, 0xe1, 0x49, 0x11, 0x1e, 0x9f, 0x14, - 0xe1, 0xbf, 0x27, 0x45, 0xb8, 0x7f, 0x56, 0x72, 0x8f, 0xcf, 0x4a, 0xee, 0x9f, 0x67, 0x25, 0xf7, - 0x63, 0xdb, 0xc6, 0xcc, 0x19, 0x19, 0x6d, 0x93, 0x0c, 0x3b, 0x81, 0x58, 0xf8, 0x61, 0x62, 0x92, - 0x41, 0xb8, 0xe8, 0x8c, 0x93, 0x9f, 0x45, 0x77, 0x1e, 0xa2, 0x46, 0x29, 0x24, 0x1c, 0xfe, 0x1f, - 0x00, 0x00, 0xff, 0xff, 0x5c, 0xdd, 0x13, 0xd9, 0x35, 0x09, 0x00, 0x00, + // 803 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcd, 0x6e, 0xeb, 0x44, + 0x14, 0x8e, 0x93, 0x34, 0xdc, 0x9c, 0xb4, 0x41, 0x58, 0x21, 0xd7, 0x75, 0x8b, 0x13, 0xcc, 0xfd, + 0x89, 0xc4, 0x25, 0x91, 0x72, 0xaf, 0x58, 0xa3, 0x50, 0xd1, 0xa2, 0x2a, 0x52, 0xe5, 0xb6, 0x02, + 0xb1, 0xa9, 0xc6, 0xf6, 0x60, 0x0f, 0x24, 0x1e, 0xd7, 0x33, 0x2e, 0xa9, 0x84, 0xc4, 0x0b, 0xb0, + 0xe8, 0x96, 0x37, 0x80, 0x37, 0xe9, 0xb2, 0x12, 0x1b, 0x56, 0x08, 0xb5, 0x2f, 0x82, 0xfc, 0x93, + 0x89, 0x93, 0xd8, 0xfd, 0xd9, 0xdd, 0x5d, 0xe6, 0x7c, 0xdf, 0x7c, 0xe7, 0x3b, 0x67, 0x7a, 0x4e, + 0x0d, 0xcf, 0x19, 0xb1, 0xf1, 0xc0, 0xe4, 0x96, 0x19, 0x10, 0xdb, 0xc1, 0x03, 0x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+ 0xa7, 0xb0, 0x85, 0x01, 0x07, 0x3e, 0x5a, 0x9f, 0xd7, 0x17, 0x39, 0x52, 0x6b, 0x2c, 0xf5, 0xcd, + 0x63, 0x58, 0x22, 0x91, 0x0f, 0xad, 0xdc, 0x7f, 0x88, 0xaf, 0x1f, 0xb4, 0x9d, 0x10, 0xd5, 0xc1, + 0x23, 0x89, 0x22, 0xe3, 0x29, 0x34, 0xb2, 0x1b, 0x42, 0xcb, 0xb9, 0x9f, 0xc1, 0xd5, 0x57, 0xf7, + 0xe3, 0x59, 0xd9, 0xec, 0x2c, 0xe7, 0xc9, 0x66, 0xf0, 0x5c, 0xd9, 0x9c, 0xe9, 0x93, 0xbf, 0x87, + 0xcd, 0xa5, 0xd1, 0xeb, 0xe4, 0xdc, 0xcb, 0x12, 0xd4, 0xd7, 0x0f, 0x10, 0xe6, 0xca, 0xa3, 0x83, + 0xeb, 0x5b, 0x4d, 0xba, 0xb9, 0xd5, 0xa4, 0xff, 0x6e, 0x35, 0xe9, 0xea, 0x4e, 0x2b, 0xdd, 0xdc, + 0x69, 0xa5, 0x7f, 0xee, 0xb4, 0xd2, 0x0f, 0x7d, 0x87, 0x70, 0x37, 0x34, 0xfb, 0x16, 0x9d, 0x0e, + 0x22, 0xb1, 0xf8, 0xf3, 0xc5, 0xa2, 0x93, 0xf8, 0x30, 0x98, 0x65, 0x3f, 0x9e, 0x2e, 0x7d, 0xcc, + 0xcc, 0x5a, 0x4c, 0x78, 0xfb, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x1d, 0x96, 0x4a, 0x5b, + 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1733,16 +1753,25 @@ func (m *MsgCompleteDKG) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x2a + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0x22 + } if len(m.Vaults) > 0 { for iNdEx := len(m.Vaults) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Vaults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } + i -= len(m.Vaults[iNdEx]) + copy(dAtA[i:], m.Vaults[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Vaults[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -2070,11 +2099,19 @@ func (m *MsgCompleteDKG) Size() (n int) { n += 1 + sovTx(uint64(m.Id)) } if len(m.Vaults) > 0 { - for _, e := range m.Vaults { - l = e.Size() + for _, s := range m.Vaults { + l = len(s) n += 1 + l + sovTx(uint64(l)) } } + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -3438,7 +3475,7 @@ func (m *MsgCompleteDKG) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Vaults", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3448,25 +3485,87 @@ func (m *MsgCompleteDKG) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Vaults = append(m.Vaults, &Vault{}) - if err := m.Vaults[len(m.Vaults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Vaults = append(m.Vaults, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.Signature = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex