sidh

package
v4.19.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: MIT, BSD-3-Clause, MIT Imports: 5 Imported by: 123

Documentation

Index

Constants

View Source
const (
	FP_503 uint8 = iota
	FP_751
	FP_964
)

Id's correspond to bitlength of the prime field characteristic Currently FP_751 is the only one supported by this implementation

View Source
const (

	// 001 - SIDH: corresponds to 2-torsion group
	KeyVariant_SIDH_A KeyVariant = 1 << 0
	// 010 - SIDH: corresponds to 3-torsion group
	KeyVariant_SIDH_B = 1 << 1
	// 110 - SIKE
	KeyVariant_SIKE = 1<<2 | KeyVariant_SIDH_B
)

Variables

This section is empty.

Functions

func DeriveSecret

func DeriveSecret(prv *PrivateKey, pub *PublicKey) ([]byte, error)

Computes a shared secret which is a j-invariant. Function requires that pub has different KeyVariant than prv. Length of returned output is 2*ceil(log_2 P)/8), where P is a prime defining finite field.

It's important to notice that each keypair must not be used more than once to calculate shared secret.

Function may return error. This happens only in case provided input is invalid. Constant time for properly initialized private and public key.

func Params

func Params(id uint8) *SidhParams

Params returns domain parameters corresponding to finite field and identified by `id` provieded by the caller. Function panics in case `id` wasn't registered earlier.

Types

type KeyVariant

type KeyVariant uint

I keep it bool in order to be able to apply logical NOT

type PrivateKey

type PrivateKey struct {

	// Secret key
	Scalar []byte
	// Used only by KEM
	S []byte
	// contains filtered or unexported fields
}

Defines operations on private key

func NewPrivateKey

func NewPrivateKey(id uint8, v KeyVariant) *PrivateKey

NewPrivateKey initializes private key. Usage of this function guarantees that the object is correctly initialized.

func (*PrivateKey) Export

func (prv *PrivateKey) Export() []byte

Exports currently stored key. In case structure hasn't been filled with key data returned byte string is filled with zeros.

func (*PrivateKey) Generate

func (prv *PrivateKey) Generate(rand io.Reader) error

Generates random private key for SIDH or SIKE. Generated value is formed as little-endian integer from key-space <2^(e2-1)..2^e2 - 1> for KeyVariant_A or <2^(s-1)..2^s - 1>, where s = floor(log_2(3^e3)), for KeyVariant_B.

Returns error in case user provided RNG fails.

func (*PrivateKey) GeneratePublicKey

func (prv *PrivateKey) GeneratePublicKey() *PublicKey

Generates public key.

Constant time.

func (*PrivateKey) Import

func (prv *PrivateKey) Import(input []byte) error

Import clears content of the private key currently stored in the structure and imports key from octet string. In case of SIKE, the random value 'S' must be prepended to the value of actual private key (see SIKE spec for details). Function doesn't import public key value to PrivateKey object.

func (*PrivateKey) Params

func (key *PrivateKey) Params() *SidhParams

Accessor to the domain parameters

func (*PrivateKey) Size

func (prv *PrivateKey) Size() int

Size returns size of the private key in bytes

func (*PrivateKey) Variant

func (key *PrivateKey) Variant() KeyVariant

Accessor to key variant

type PublicKey

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

Defines operations on public key

func NewPublicKey

func NewPublicKey(id uint8, v KeyVariant) *PublicKey

NewPublicKey initializes public key. Usage of this function guarantees that the object is correctly initialized.

func (*PublicKey) Export

func (pub *PublicKey) Export() []byte

Exports currently stored key. In case structure hasn't been filled with key data returned byte string is filled with zeros.

func (*PublicKey) Import

func (pub *PublicKey) Import(input []byte) error

Import clears content of the public key currently stored in the structure and imports key stored in the byte string. Returns error in case byte string size is wrong. Doesn't perform any validation.

func (*PublicKey) Params

func (key *PublicKey) Params() *SidhParams

Accessor to the domain parameters

func (*PublicKey) Size

func (pub *PublicKey) Size() int

Size returns size of the public key in bytes

func (*PublicKey) Variant

func (key *PublicKey) Variant() KeyVariant

Accessor to key variant

Jump to

Keyboard shortcuts

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