# README
DH Functions
This package implements the DH functions, as specified in the noise specs.
Built-in Curves
The following curves are supported,
The protocol name is 25519
, e.g., Noise_XX_25519_AESGCM_SHA256.
The protocol name is 448
, e.g., Noise_XX_448_AESGCM_SHA256.
The protocol name is secp256k1
, e.g., Noise_XX_secp256k1_AESGCM_SHA256.
Customized DH function
To create your own DH function, you'll need to implement the interfaces specified in dh.go
, which requires a PublicKey
interface, a PrivateKey
interface and a Curve
interface. And you need to register it using Register(Name, Curve)
.
Check examples/newdh, which implements a dummy DH function for demonstration. Once implemented, it can be used via the protocol name,
// dumb implements the DH interface for DumbCurve.
dh.Register("Dumb", newDumbCurve)
// Now "Dumb" is a valid dh curve name, and it can be used in the protocol name as,
p, _ := babble.NewProtocol("Noise_NN_Dumb_ChaChaPoly_BLAKE2s", "Demo", true)
# Functions
FromString uses the provided curve name, s, to query a built-in curve.
Register updates the supported curves used in package dh.
SupportedCurves gives the names of all the curves registered.
# Interfaces
Curve represents DH functions specified in the noise specs.
PrivateKey is a key pair.
PublicKey represents a public key.
# Type aliases
NewCurve creates an Curve instance.