xwing

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package xwing implements the hybrid quantum-resistant key encapsulation method X-Wing, which combines X25519, ML-KEM-768, and SHA3-256 as specified in draft-connolly-cfrg-xwing-kem-00.

Future v0 versions of this package might introduce backwards incompatible changes to implement changes to draft-connolly-cfrg-xwing-kem or FIPS 203.

Index

Constants

View Source
const (
	CiphertextSize        = mlkem768.CiphertextSize + 32
	EncapsulationKeySize  = mlkem768.EncapsulationKeySize + 32
	DecapsulationKeySize  = mlkem768.DecapsulationKeySize + 32
	SharedKeySize         = 32
	X25519SeedSize        = 32
	KeySeedSize           = X25519SeedSize + mlkem768.KeySeedSize
	EncapsulationSeedSize = X25519SeedSize + mlkem768.EncapsulationSeedSize
)

Variables

This section is empty.

Functions

func Decapsulate

func Decapsulate(decapsulationKey, ciphertext []byte) (sharedKey []byte, err error)

Decapsulate generates a shared key from a ciphertext and a decapsulation key. If the decapsulation key or the ciphertext are not valid, Decapsulate returns an error.

The shared key must be kept secret.

func Encapsulate

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.

func EncapsulateFromSeed

func EncapsulateFromSeed(encapsulationKey, seed []byte) (ciphertext, sharedKey []byte, err error)

EncapsulateFromSeed generates a shared key and an associated ciphertext from an encapsulation key, drawing random bytes from the given seed. If the encapsulation key is not valid, Encapsulate returns an error.

The shared key must be kept secret.

func GenerateKey

func GenerateKey() (encapsulationKey, decapsulationKey []byte, err error)

GenerateKey generates an encapsulation key and a corresponding decapsulation key, drawing random bytes from crypto/rand.

The decapsulation key must be kept secret.

func GenerateKeyFromSeed

func GenerateKeyFromSeed(seed []byte) (encapsulationKey, decapsulationKey []byte, err error)

GenerateKeyFromSeed generates an encapsulation key and a corresponding decapsulation key, drawing random bytes from the given seed.

The decapsulation key must be kept secret.

def GenerateKeyPairDerand(seed):

(pk_M, sk_M) = ML-KEM-768.KeyGenDerand(seed[0:64])
sk_X = seed[64:96]
pk_X = X25519(sk_X, X25519_BASE)
return concat(sk_M, sk_X), concat(pk_M, pk_X)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL