Documentation ¶
Index ¶
- Constants
- func DeriveSecret(prv *PrivateKey, pub *PublicKey) ([]byte, error)
- func Params(id uint8) *SidhParams
- type KeyVariant
- type PrivateKey
- func (prv *PrivateKey) Export() []byte
- func (prv *PrivateKey) Generate(rand io.Reader) error
- func (prv *PrivateKey) GeneratePublicKey() *PublicKey
- func (prv *PrivateKey) Import(input []byte) error
- func (key *PrivateKey) Params() *SidhParams
- func (prv *PrivateKey) Size() int
- func (key *PrivateKey) Variant() KeyVariant
- type PublicKey
Constants ¶
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
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.
Types ¶
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
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 ¶
Exports currently stored key. In case structure hasn't been filled with key data returned byte string is filled with zeros.
func (*PublicKey) Import ¶
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