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:
KAI 2023-06-07 21:10:42 +08:00 committed by GitHub
parent 99eb0b52aa
commit 5c51ef8527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

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,