newhope

package module
v0.0.0-...-0c77ddc Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: CC0-1.0 Imports: 4 Imported by: 0

Documentation

Overview

Package newhope implements a key exchange based on the Ring Learning with Errors Problem. It is a mechanical port of the Public Domain implementation by Erdem Alkim, Léo Ducas, Thomas Pöppelmann, and Peter Schwabe.

For more information see: https://cryptojedi.org/papers/newhope-20161119.pdf https://cryptojedi.org/papers/newhopesimple-20161217.pdf

Index

Constants

View Source
const (
	// SharedSecretSize is the length of a Shared Secret in bytes.
	SharedSecretSize = 32

	// UpstreamVersion is the version of the upstream package this
	// implementation is compatible with.
	UpstreamVersion = "20160815"

	// RecBytes is the length of the reconciliation data in bytes.
	RecBytes = 256

	// SendASize is the length of Alice's public key in bytes.
	SendASize = PolyBytes + SeedBytes

	// SendBSize is the length of Bob's public key in bytes.
	SendBSize = PolyBytes + RecBytes
)
View Source
const (
	// HighBytes is the length of the encoded secret in bytes.
	HighBytes = 384

	// SendASimpleSize is the length of Alice's NewHope-Simple public key in
	// bytes.
	SendASimpleSize = PolyBytes + SeedBytes

	// SendBSimpleSize is the length of Bob's NewHope-Simple public key in
	// bytes.
	SendBSimpleSize = PolyBytes + HighBytes
)
View Source
const (
	// PolyBytes is the length of an encoded polynomial in bytes.
	PolyBytes = 1792
)
View Source
const (

	// SeedBytes is the size of the seed in bytes.
	SeedBytes = 32
)

Variables

View Source
var TorSampling = false

TorSampling enables the constant time generation of the `a` parameter, where every successful `a` generation will take the same amount of time. Most users will probably not want to enable this as it does come with a performance penalty. Alice and Bob *MUST* agree on the sampling method, or the key exchange will fail.

Functions

func GenerateKeyPairAlice

func GenerateKeyPairAlice(rand io.Reader) (*PrivateKeyAlice, *PublicKeyAlice, error)

GenerateKeyPairAlice returns a private/public key pair. The private key is generated using the given reader, which must return random data. The receiver side of the key exchange (aka "Bob") MUST use KeyExchangeBob() instead of this routine.

func GenerateKeyPairSimpleAlice

func GenerateKeyPairSimpleAlice(rand io.Reader) (*PrivateKeySimpleAlice, *PublicKeySimpleAlice, error)

GenerateKeyPairSimpleAlice returns a NewHope-Simple private/public key pair. The private key is generated using the given reader, which must return random data. The receiver side of the key exchange (aka "Bob") MUST use KeyExchangeSimpleBob() instead of this routine.

func KeyExchangeAlice

func KeyExchangeAlice(bobPk *PublicKeyBob, aliceSk *PrivateKeyAlice) ([]byte, error)

KeyExchangeAlice is the Initiaitor side of the NewHope key exchange. The provided private key is obliterated prior to returning.

func KeyExchangeSimpleAlice

func KeyExchangeSimpleAlice(bobPk *PublicKeySimpleBob, aliceSk *PrivateKeySimpleAlice) ([]byte, error)

KeyExchangeSimpleAlice is the Initiaitor side of the NewHope-Simple key exchange. The provided private key is obliterated prior to returning.

Types

type PrivateKeyAlice

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

PrivateKeyAlice is Alice's NewHope private key.

func (*PrivateKeyAlice) Reset

func (k *PrivateKeyAlice) Reset()

Reset clears all sensitive information such that it no longer appears in memory.

type PrivateKeySimpleAlice

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

PrivateKeySimpleAlice is Alice's NewHope-Simple private key.

func (*PrivateKeySimpleAlice) Reset

func (k *PrivateKeySimpleAlice) Reset()

Reset clears all sensitive information such that it no longer appears in memory.

type PublicKeyAlice

type PublicKeyAlice struct {
	Send [SendASize]byte
}

PublicKeyAlice is Alice's NewHope public key.

type PublicKeyBob

type PublicKeyBob struct {
	Send [SendBSize]byte
}

PublicKeyBob is Bob's NewHope public key.

func KeyExchangeBob

func KeyExchangeBob(rand io.Reader, alicePk *PublicKeyAlice) (*PublicKeyBob, []byte, error)

KeyExchangeBob is the Responder side of the NewHope key exchange. The shared secret and "public key" (key + reconciliation data) are generated using the given reader, which must return random data.

type PublicKeySimpleAlice

type PublicKeySimpleAlice struct {
	Send [SendASimpleSize]byte
}

PublicKeySimpleAlice is Alice's NewHope-Simple public key.

type PublicKeySimpleBob

type PublicKeySimpleBob struct {
	Send [SendBSimpleSize]byte
}

PublicKeySimpleBob is Bob's NewHope-Simple public key.

func KeyExchangeSimpleBob

func KeyExchangeSimpleBob(rand io.Reader, alicePk *PublicKeySimpleAlice) (*PublicKeySimpleBob, []byte, error)

KeyExchangeSimpleBob is the Responder side of the NewHope-Simple key exchange. The shared secret and "public key" are generated using the given reader, which must return random data.

Jump to

Keyboard shortcuts

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