accounts/keystore: handle error for invalid key in DecryptKey (#27432)

Co-authored-by: KAI <kaili@coinsummer.io>
Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
Daniel Liu 2025-01-14 10:56:15 +08:00
parent d4bf06d689
commit a57f3583fc

View file

@ -225,10 +225,13 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
if err != nil {
return nil, err
}
key := crypto.ToECDSAUnsafe(keyBytes)
key, err := crypto.ToECDSA(keyBytes)
if err != nil {
return nil, fmt.Errorf("invalid key: %w", err)
}
id, err := uuid.FromBytes(keyId)
if err != nil {
return nil, err
return nil, fmt.Errorf("invalid UUID: %w", err)
}
return &Key{
Id: id,