Documentation ¶
Overview ¶
This package provide the Streamlined NTRU Prime KEM.
Index ¶
Constants ¶
const ( // PublicKeySize is the public key size in bytes. PublicKeySize = sntrup.PublicKeySize // PrivateKeySize is the private key size in bytes. PrivateKeySize = sntrup.PrivateKeySize SharedKeySize = sntrup.SharedKeySize // CiphertextSize is the size of the ciphertext in bytes. CiphertextSize = sntrup.CiphertextSize // KeySeedSize is currently set to 32 but should be adjusted // to our security bits. KeySeedSize = 32 // EncapsulationSeedSize is currently set to 32 but should be adjusted // to our security bits. EncapsulationSeedSize = 32 )
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPair(rng io.Reader) (*PublicKey, *PrivateKey, error)
GenerateKeyPair generates public and private keys using entropy from rand. If rand is nil, hpqc/rand.Reader will be used.
func NewKeyFromSeed ¶
func NewKeyFromSeed(seed []byte) (*PublicKey, *PrivateKey)
NewKeyFromSeed derives a public/private keypair deterministically from the given seed.
Panics if seed is not of length KeySeedSize.
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
Private key of a hybrid KEM.
func (*PrivateKey) DecapsulateTo ¶
func (sk *PrivateKey) DecapsulateTo(ss, ct []byte)
DecapsulateTo computes the shared key which is encapsulated in ct for the private key.
Panics if ct or ss are not of length CiphertextSize and SharedKeySize respectively.
func (*PrivateKey) Equal ¶
func (sk *PrivateKey) Equal(other kem.PrivateKey) bool
func (*PrivateKey) MarshalBinary ¶
func (sk *PrivateKey) MarshalBinary() (data []byte, err error)
func (*PrivateKey) Public ¶
func (sk *PrivateKey) Public() kem.PublicKey
func (*PrivateKey) Scheme ¶
func (sk *PrivateKey) Scheme() kem.Scheme
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
Public key of a hybrid KEM.
func (*PublicKey) EncapsulateTo ¶
EncapsulateTo generates a shared key and ciphertext that contains it for the public key using randomness from seed and writes the shared key to ss and ciphertext to ct.
Panics if ss, ct or seed are not of length SharedKeySize, CiphertextSize and EncapsulationSeedSize respectively.
seed may be nil, in which case hpqc/rand.Reader is used to generate one.