INNER CODE UNIT · Go
privateKeySize
aead/minisign · private.go:177
privateKeySize = 158 // 2 + 2 + 2 + 32 + 8 + 8 + 104
)
// EncryptKey encrypts the private key with the given password
// using some entropy from the RNG of the OS.
func EncryptKey(password string, privateKey PrivateKey) ([]byte, error) {
var privateKeyBytes [72]byte
binary.LittleEndian.PutUint64(privateKeyBytes[:], privateKey.ID())
copy(privateKeyBytes[8:], privateKey.bytes[:])
var salt [32]byte
if _, err := io.ReadFull(rand.Reader, salt[:]); err != nil {
return nil, err
}
var bytes [privateKeySize]byte
binary.LittleEndian.PutUint16(bytes[0:], EdDSA)
binary.LittleEndian.PutUint16(bytes[2:], algorithmScrypt)