Identifiers correspond to the bitlength of the prime field characteristic.
const ( Fp434 = common.Fp434 Fp503 = common.Fp503 Fp751 = common.Fp751 )
const ( // 001 - SIDH: corresponds to 2-torsion group KeyVariantSidhA KeyVariant = 1 << 0 // 010 - SIDH: corresponds to 3-torsion group KeyVariantSidhB = 1 << 1 // 110 - SIKE KeyVariantSike = 1<<2 | KeyVariantSidhB )
SIKE KEM interface.
Deprecated: not cryptographically secure.
type KEM struct {
// contains filtered or unexported fields
}
▹ Example
func NewSike434(rng io.Reader) *KEM
NewSike434 instantiates SIKE/p434 KEM.
Deprecated: not cryptographically secure.
func NewSike503(rng io.Reader) *KEM
NewSike503 instantiates SIKE/p503 KEM.
Deprecated: not cryptographically secure.
func NewSike751(rng io.Reader) *KEM
NewSike751 instantiates SIKE/p751 KEM.
Deprecated: not cryptographically secure.
func (c *KEM) Allocate(id uint8, rng io.Reader)
Allocate allocates KEM object for multiple SIKE operations. The rng must be cryptographically secure PRNG.
func (c *KEM) CiphertextSize() int
Returns size of resulting ciphertext.
func (c *KEM) Decapsulate(secret []byte, prv *PrivateKey, pub *PublicKey, ciphertext []byte) error
Decapsulate given the keypair and ciphertext as inputs, Decapsulate outputs a shared secret if plaintext verifies correctly, otherwise function outputs random value. Decapsulation may panic in case input is wrongly formatted, in particular, size of the 'ciphertext' must be exactly equal to c.CiphertextSize().
func (c *KEM) Encapsulate(ciphertext, secret []byte, pub *PublicKey) error
Encapsulate receives the public key and generates SIKE ciphertext and shared secret. The generated ciphertext is used for authentication. Error is returned in case PRNG fails. Function panics in case wrongly formatted input was provided.
func (c *KEM) PrivateKeySize() int
Size returns size of the private key in bytes.
func (c *KEM) PublicKeySize() int
PublicKeySize returns size of the public key in bytes.
func (c *KEM) Reset()
Resets internal state of KEM. Function should be used after Allocate and between subsequent calls to Encapsulate and/or Decapsulate.
func (c *KEM) SharedSecretSize() int
Returns size of resulting shared secret.
I keep it bool in order to be able to apply logical NOT.
Deprecated: not cryptographically secure.
type KeyVariant uint
Defines operations on private key
Deprecated: not cryptographically secure.
type PrivateKey struct { // Secret key Scalar []byte // Used only by KEM S []byte // contains filtered or unexported fields }
▹ Example
func NewPrivateKey(id uint8, v KeyVariant) *PrivateKey
NewPrivateKey initializes private key. Usage of this function guarantees that the object is correctly initialized.
Deprecated: not cryptographically secure.
func (prv *PrivateKey) DeriveSecret(ss []byte, pub *PublicKey)
Computes a SIDH shared secret. 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.
Caller must make sure key SIDH key pair is not used more than once.
func (prv *PrivateKey) Export(out []byte)
Exports currently stored key. In case structure hasn't been filled with key data returned byte string is filled with zeros.
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 (prv *PrivateKey) GeneratePublicKey(pub *PublicKey)
Generates public key.
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 (prv *PrivateKey) SharedSecretSize() int
Size returns size of the shared secret.
func (prv *PrivateKey) Size() int
Size returns size of the private key in bytes.
func (key *PrivateKey) Variant() KeyVariant
Accessor to key variant.
Defines operations on public key
Deprecated: not cryptographically secure.
type PublicKey struct {
// contains filtered or unexported fields
}
func NewPublicKey(id uint8, v KeyVariant) *PublicKey
NewPublicKey initializes public key. Usage of this function guarantees that the object is correctly initialized.
Deprecated: not cryptographically secure.
func (pub *PublicKey) Export(out []byte)
Exports currently stored key. In case structure hasn't been filled with key data returned byte string is filled with zeros.
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 (pub *PublicKey) Size() int
Size returns size of the public key in bytes.
func (key *PublicKey) Variant() KeyVariant
Accessor to key variant.
Name | Synopsis |
---|---|
.. |