Skip to content

Commit

Permalink
move keyset id verification
Browse files Browse the repository at this point in the history
  • Loading branch information
elnosh committed Nov 18, 2024
1 parent 6fa314d commit dd88e5a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions wallet/keyset.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ func GetMintActiveKeyset(mintURL string, unit cashu.Unit) (*crypto.WalletKeyset,
if err != nil {
return nil, err
}
id := crypto.DeriveKeysetId(keys)
if id != keyset.Id {
return nil, fmt.Errorf("Got invalid keyset. Derived id: '%v' but got '%v' from mint", id, keyset.Id)
}
return &crypto.WalletKeyset{
Id: id,
Id: keyset.Id,
MintURL: mintURL,
Unit: keyset.Unit,
Active: true,
Expand Down Expand Up @@ -81,6 +77,10 @@ func GetKeysetKeys(mintURL, id string) (map[uint64]*secp256k1.PublicKey, error)
return nil, err
}
}
derivedId := crypto.DeriveKeysetId(keys)
if id != derivedId {
return nil, fmt.Errorf("Got invalid keyset. Derived id: '%v' but got '%v' from mint", derivedId, keysetsResponse.Keysets[0].Id)
}

return keys, nil
}
Expand Down Expand Up @@ -139,13 +139,8 @@ func (w *Wallet) getActiveKeyset(mintURL string) (*crypto.WalletKeyset, error) {
if err != nil {
return nil, err
}
id := crypto.DeriveKeysetId(keys)
if id != keyset.Id {
return nil, fmt.Errorf("Got invalid keyset. Derived id: '%v' but got '%v' from mint", id, keyset.Id)
}

activeKeyset = crypto.WalletKeyset{
Id: id,
Id: keyset.Id,
MintURL: mintURL,
Unit: keyset.Unit,
Active: true,
Expand Down

0 comments on commit dd88e5a

Please sign in to comment.