curve4q

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package curve4q implements Diffie-Hellman operations using the FourQ curve at the 128-bit security level.

References:

Index

Examples

Constants

View Source
const Size = 32

Size is the size in bytes of keys.

Variables

This section is empty.

Functions

func KeyGen

func KeyGen(public, secret *Key)

KeyGen calculates a public key k from a secret key.

func Shared

func Shared(shared, secret, public *Key) bool

Shared calculates a shared key k from Alice's secret and Bob's public key. Returns true on success.

Types

type Key

type Key [Size]byte

Key represents a public or private key of FourQ.

Example
var AliceSecret, BobSecret,
	AlicePublic, BobPublic,
	AliceShared, BobShared Key

// Generating Alice's secret and public keys
_, _ = io.ReadFull(rand.Reader, AliceSecret[:])
KeyGen(&AlicePublic, &AliceSecret)

// Generating Bob's secret and public keys
_, _ = io.ReadFull(rand.Reader, BobSecret[:])
KeyGen(&BobPublic, &BobSecret)

// Deriving Alice's shared key
Shared(&AliceShared, &AliceSecret, &BobPublic)

// Deriving Bob's shared key
Shared(&BobShared, &BobSecret, &AlicePublic)

fmt.Println(AliceShared == BobShared)
Output:

true

Jump to

Keyboard shortcuts

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