package curve4q

import "github.com/cloudflare/circl/dh/curve4q"

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

References:

Index

Examples

Constants

const Size = 32

Size is the size in bytes of keys.

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

Code:

{
	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
}

Output:

true

Source Files

curve4Q.go doc.go

Version
v1.6.1 (latest)
Published
Apr 9, 2025
Platform
linux/amd64
Imports
1 packages
Last checked
5 hours ago

Tools for package owners.