...
Package curve4q
Package curve4q implements Diffie-Hellman operations using the FourQ curve
at the 128-bit security level.
References:
Constants
Size is the size in bytes of keys.
const Size = 32
func KeyGen(public, secret *Key)
KeyGen calculates a public key k from a secret key.
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.
Key represents a public or private key of FourQ.
type Key [Size]byte
▾ Example
Code:
var AliceSecret, BobSecret,
AlicePublic, BobPublic,
AliceShared, BobShared Key
_, _ = io.ReadFull(rand.Reader, AliceSecret[:])
KeyGen(&AlicePublic, &AliceSecret)
_, _ = io.ReadFull(rand.Reader, BobSecret[:])
KeyGen(&BobPublic, &BobSecret)
Shared(&AliceShared, &AliceSecret, &BobPublic)
Shared(&BobShared, &BobSecret, &AlicePublic)
fmt.Println(AliceShared == BobShared)
Output:
true