crypto::x25519+x86_64 +linux

The crypto::x25519 module provides functions to generate key pairs and to derive shared keys between them, based on curve25519.

A key pair is created by generating a private key with newkey and deriving the public key with pubkey. A shared key can be found by using derive.

Do not use the same secret key for both key exchanges and signatures. The public keys are different and revealing both may leak information.

This is a low-level module which implements cryptographic primitives. Direct use of cryptographic primitives is not recommended for non-experts, as incorrect use of these primitives can easily lead to the introduction of security vulnerabilities. Non-experts are advised to use the high-level operations available in the top-level crypto:: module.

Be advised that Hare's cryptography implementations have not been audited.

Index

Types

type key = [KEYSZ]u8;

Constants

def KEYSZ: size = 32;
def SEEDSZ: size = 32;

Functions

fn derive(shared: []u8, priv: []u8, pub: []u8) void;
fn newkey(priv: []u8, seed: []u8) void;
fn pubkey(pub: []u8, priv: const []u8) void;

Types

type key[link]

type key = [KEYSZ]u8;

Type for private, public or shared keys.

Constants

def KEYSZ[link]

def KEYSZ: size = 32;

The size of a x25519 key.

def SEEDSZ[link]

def SEEDSZ: size = 32;

The size of a x25519 key seed.

Functions

fn derive[link]

fn derive(shared: []u8, priv: []u8, pub: []u8) void;

Derives a 32-byte shared key from the private key of one key-pair and the public key of a second key-pair.

fn newkey[link]

fn newkey(priv: []u8, seed: []u8) void;

Initializes a new x25519 private key from the provided 32-byte seed, which should be generated with crypto::random.

fn pubkey[link]

fn pubkey(pub: []u8, priv: const []u8) void;

Derives the public key from a private key prepared with newkey, writing it to the 'pub' parameter.