const ( CiphertextSize = k*encodingSize10 + encodingSize4 EncapsulationKeySize = encryptionKeySize DecapsulationKeySize = decryptionKeySize + encryptionKeySize + 32 + 32 = 32 SeedSize = 32 + 32 )
func Decapsulate(dk *DecapsulationKey, ciphertext []byte) (sharedKey []byte, err error)
Decapsulate generates a shared key from a ciphertext and a decapsulation key. If the ciphertext is not valid, Decapsulate returns an error.
The shared key must be kept secret.
func Encapsulate(encapsulationKey []byte) (ciphertext, sharedKey []byte, err error)
Encapsulate generates a shared key and an associated ciphertext from an encapsulation key, drawing random bytes from crypto/rand. If the encapsulation key is not valid, Encapsulate returns an error.
The shared key must be kept secret.
A DecapsulationKey is the secret key used to decapsulate a shared key from a ciphertext. It includes various precomputed values.
type DecapsulationKey struct {
// contains filtered or unexported fields
}
func GenerateKey() (*DecapsulationKey, error)
GenerateKey generates a new decapsulation key, drawing random bytes from crypto/rand. The decapsulation key must be kept secret.
func NewKeyFromExtendedEncoding(decapsulationKey []byte) (*DecapsulationKey, error)
NewKeyFromExtendedEncoding parses a decapsulation key from its FIPS 203 (DRAFT) extended encoding.
func NewKeyFromSeed(seed []byte) (*DecapsulationKey, error)
NewKeyFromSeed deterministically generates a decapsulation key from a 64-byte seed in the "d || z" form. The seed must be uniformly random.
func (dk *DecapsulationKey) Bytes() []byte
Bytes returns the extended encoding of the decapsulation key, according to FIPS 203 (DRAFT).
func (dk *DecapsulationKey) EncapsulationKey() []byte
EncapsulationKey returns the public encapsulation key necessary to produce ciphertexts.