xwing

package
v0.0.0-...-d85de16 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: BSD-3-Clause Imports: 6 Imported by: 3

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.

Index

Constants

View Source
const (
	CiphertextSize       = mlkem768.CiphertextSize + 32
	EncapsulationKeySize = mlkem768.EncapsulationKeySize + 32
	SharedKeySize        = 32
	SeedSize             = 32
)

Variables

This section is empty.

Functions

func Decapsulate

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

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.

Types

type DecapsulationKey

type DecapsulationKey struct {
	// contains filtered or unexported fields
}

A DecapsulationKey is the secret key used to decapsulate a shared key from a ciphertext. It includes various precomputed values.

func GenerateKey

func GenerateKey() (*DecapsulationKey, error)

GenerateKey generates a new decapsulation key, drawing random bytes from crypto/rand. The decapsulation key must be kept secret.

func NewKeyFromSeed

func NewKeyFromSeed(sk []byte) (*DecapsulationKey, error)

NewKeyFromSeed deterministically generates a decapsulation key from a 32-byte seed. The seed must be uniformly random.

func (*DecapsulationKey) Bytes

func (dk *DecapsulationKey) Bytes() []byte

Bytes returns the decapsulation key as a 32-byte seed.

func (*DecapsulationKey) EncapsulationKey

func (dk *DecapsulationKey) EncapsulationKey() []byte

EncapsulationKey returns the public encapsulation key necessary to produce ciphertexts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳