@@ -2,6 +2,7 @@ package keeper
22
33import (
44 "bytes"
5+ "encoding/base64"
56 "time"
67
78 "github.com/btcsuite/btcd/btcutil/psbt"
@@ -126,14 +127,14 @@ func (k Keeper) SetDKGCompletionRequest(ctx sdk.Context, req *types.DKGCompletio
126127 store := ctx .KVStore (k .storeKey )
127128
128129 bz := k .cdc .MustMarshal (req )
129- store .Set (types .DKGCompletionRequestKey (req .Id , req .ConsensusAddress ), bz )
130+ store .Set (types .DKGCompletionRequestKey (req .Id , req .ConsensusPubkey ), bz )
130131}
131132
132133// HasDKGCompletionRequest returns true if the given completion request exists, false otherwise
133- func (k Keeper ) HasDKGCompletionRequest (ctx sdk.Context , id uint64 , consAddress string ) bool {
134+ func (k Keeper ) HasDKGCompletionRequest (ctx sdk.Context , id uint64 , consPubKey string ) bool {
134135 store := ctx .KVStore (k .storeKey )
135136
136- return store .Has (types .DKGCompletionRequestKey (id , consAddress ))
137+ return store .Has (types .DKGCompletionRequestKey (id , consPubKey ))
137138}
138139
139140// GetDKGCompletionRequests gets DKG completion requests by the given id
@@ -199,18 +200,18 @@ func (k Keeper) InitiateDKG(ctx sdk.Context, participants []*types.DKGParticipan
199200}
200201
201202// CompleteDKG completes the DKG request by the DKG participant
202- // The DKG request will be completed when all participants submit the valid completion request before timeout
203+ // The DKG request will be finalized when all participants submit the valid completion request before timeout
203204func (k Keeper ) CompleteDKG (ctx sdk.Context , req * types.DKGCompletionRequest ) error {
204205 dkgReq := k .GetDKGRequest (ctx , req .Id )
205206 if dkgReq == nil {
206207 return types .ErrDKGRequestDoesNotExist
207208 }
208209
209- if ! types .ParticipantExists (dkgReq .Participants , req .ConsensusAddress ) {
210+ if ! types .ParticipantExists (dkgReq .Participants , req .ConsensusPubkey ) {
210211 return types .ErrUnauthorizedDKGCompletionRequest
211212 }
212213
213- if k .HasDKGCompletionRequest (ctx , req .Id , req .ConsensusAddress ) {
214+ if k .HasDKGCompletionRequest (ctx , req .Id , req .ConsensusPubkey ) {
214215 return types .ErrDKGCompletionRequestExists
215216 }
216217
@@ -241,9 +242,11 @@ func (k Keeper) CompleteDKG(ctx sdk.Context, req *types.DKGCompletionRequest) er
241242 // return err
242243 // }
243244
244- // if !types.VerifySignature(req.Signature, pubKey.Bytes(), req) {
245- // return errorsmod.Wrap(types.ErrInvalidDKGCompletionRequest, "invalid signature")
246- // }
245+ pubKey , _ := base64 .StdEncoding .DecodeString (req .ConsensusPubkey )
246+
247+ if ! types .VerifySignature (req .Signature , pubKey , req ) {
248+ return errorsmod .Wrap (types .ErrInvalidDKGCompletionRequest , "invalid signature" )
249+ }
247250
248251 k .SetDKGCompletionRequest (ctx , req )
249252
0 commit comments