ssvlabs/ssv

Misleading Function Prototype

Opened this issue · 0 comments

Is your feature request related to a problem? Please describe.
In the package github.com/ssv-labs/ssv/utils/rsaencryption, the following function is
defined:

// DecodeKey with secret key (rsa) and hash (base64), return the decrypted key
func DecodeKey(sk *rsa.PrivateKey, hash []byte) ([]byte, error) {
decryptedKey, err := rsa.DecryptPKCS1v15(rand.Reader, sk, hash)
if err != nil {
return nil, errors.Wrap(err, "could not decrypt key")
}
return decryptedKey, nil
}

Describe the solution you'd like
Rather than simply a decoding function, it is a decryption function. Its hash argument is not a hash but a
ciphertext. This is confusing for readers, who have to check the implementation of the function to find out
that it is in fact performing PKCS1v1.5 decryption.

Additional context
This is result of the dkg audit