adapter

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package adapter provides an adhoc hashed ElGamal construction that essentially acts like an adapter, adapting a NIKE to KEM.

Index

Constants

View Source
const (
	// SeedSize is the number of bytes needed to seed deterministic methods below.
	SeedSize = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

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

PrivateKey is an adapter for nike.PrivateKey to kem.PrivateKey.

func (*PrivateKey) Equal

func (p *PrivateKey) Equal(privkey kem.PrivateKey) bool

func (*PrivateKey) MarshalBinary

func (p *PrivateKey) MarshalBinary() ([]byte, error)

func (*PrivateKey) Public

func (p *PrivateKey) Public() kem.PublicKey

func (*PrivateKey) Scheme

func (p *PrivateKey) Scheme() kem.Scheme

type PublicKey

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

PublicKey is an adapter for nike.PublicKey to kem.PublicKey.

func (*PublicKey) Equal

func (p *PublicKey) Equal(pubkey kem.PublicKey) bool

func (*PublicKey) MarshalBinary

func (p *PublicKey) MarshalBinary() ([]byte, error)

func (*PublicKey) MarshalText added in v0.0.3

func (p *PublicKey) MarshalText() (text []byte, err error)

func (*PublicKey) Scheme

func (p *PublicKey) Scheme() kem.Scheme

type Scheme

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

Scheme is an adapter for nike.Scheme to kem.Scheme. See docs/specs/kemsphinx.rst for some design notes on this NIKE to KEM adapter.

func FromNIKE

func FromNIKE(nike nike.Scheme) *Scheme

FromNIKE creates a new KEM adapter Scheme using the given NIKE Scheme.

func (*Scheme) CiphertextSize

func (a *Scheme) CiphertextSize() int

Size of encapsulated keys.

func (*Scheme) Decapsulate

func (a *Scheme) Decapsulate(myPrivkey kem.PrivateKey, ct []byte) ([]byte, error)

Returns the shared key encapsulated in ciphertext ct for the private key sk. Implements DECAPSULATE as described in NIKE to KEM adapter, see docs/specs/kemsphinx.rst

func (*Scheme) DeriveKeyPair

func (a *Scheme) DeriveKeyPair(seed []byte) (kem.PublicKey, kem.PrivateKey)

DeriveKeyPair deterministically derives a pair of keys from a seed. Panics if the length of seed is not equal to the value returned by SeedSize.

func (*Scheme) Encapsulate

func (a *Scheme) Encapsulate(pk kem.PublicKey) (ct, ss []byte, err error)

Encapsulate generates a shared key ss for the public key and encapsulates it into a ciphertext ct.

func (*Scheme) EncapsulateDeterministically

func (a *Scheme) EncapsulateDeterministically(pk kem.PublicKey, seed []byte) (
	ct, ss []byte, err error)

EncapsulateDeterministically generates a shared key ss for the public key deterministically from the given seed and encapsulates it into a ciphertext ct. If unsure, you're better off using Encapsulate(). Implements ENCAPSULATE as described in NIKE to KEM adapter, see docs/specs/kemsphinx.rst

func (*Scheme) GenerateKeyPair

func (a *Scheme) GenerateKeyPair() (kem.PublicKey, kem.PrivateKey, error)

GenerateKeyPair creates a new key pair.

func (*Scheme) Name

func (a *Scheme) Name() string

Name of the scheme

func (*Scheme) PrivateKeySize

func (a *Scheme) PrivateKeySize() int

Size of packed private keys.

func (*Scheme) PublicKeySize

func (a *Scheme) PublicKeySize() int

Size of packed public keys.

func (*Scheme) SeedSize

func (a *Scheme) SeedSize() int

Size of seed used in DeriveKey

func (*Scheme) SharedKeySize

func (a *Scheme) SharedKeySize() int

Size of established shared keys.

func (*Scheme) UnmarshalBinaryPrivateKey

func (a *Scheme) UnmarshalBinaryPrivateKey(b []byte) (kem.PrivateKey, error)

Unmarshals a PrivateKey from the provided buffer.

func (*Scheme) UnmarshalBinaryPublicKey

func (a *Scheme) UnmarshalBinaryPublicKey(b []byte) (kem.PublicKey, error)

Unmarshals a PublicKey from the provided buffer.

func (*Scheme) UnmarshalTextPrivateKey added in v0.0.4

func (a *Scheme) UnmarshalTextPrivateKey(text []byte) (kem.PrivateKey, error)

func (*Scheme) UnmarshalTextPublicKey added in v0.0.4

func (a *Scheme) UnmarshalTextPublicKey(text []byte) (kem.PublicKey, error)

Jump to

Keyboard shortcuts

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