[#539] Fix nonce size computation

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-06-23 17:50:15 +03:00 committed by Kira
parent 35f55c5af5
commit e84ff96593

View file

@ -271,7 +271,7 @@ func encrypt(owner *keys.PrivateKey, sender *keys.PublicKey, data []byte) ([]byt
return nil, fmt.Errorf("get chiper: %w", err)
}
nonce := make([]byte, enc.NonceSize(), enc.NonceSize()+len(data)+enc.Overhead())
nonce := make([]byte, enc.NonceSize())
if _, err = rand.Read(nonce); err != nil {
return nil, fmt.Errorf("generate random nonce: %w", err)
}