package x448
import "github.com/cloudflare/circl/dh/x448"
Package x448 provides Diffie-Hellman functions as specified in RFC-7748.
Validation of public keys.
The Diffie-Hellman function, as described in RFC-7748 [1], works for any public key. However, if a different protocol requires contributory behaviour [2,3], then the public keys must be validated against low-order points [3,4]. To do that, the Shared function performs this validation internally and returns false when the public key is invalid (i.e., it is a low-order point).
References:
- [1] RFC7748 by Langley, Hamburg, Turner (https://rfc-editor.org/rfc/rfc7748.txt)
- [2] Curve25519 by Bernstein (https://cr.yp.to/ecdh.html)
- [3] Bernstein (https://cr.yp.to/ecdh.html#validate)
- [4] Cremers&Jackson (https://eprint.iacr.org/2019/526)
Example (X448)¶
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 okA := Shared(&AliceShared, &AliceSecret, &BobPublic) // Deriving Bob's shared key okB := Shared(&BobShared, &BobSecret, &AlicePublic) fmt.Println(AliceShared == BobShared && okA && okB) // Output: true }
Output:
true
Index ¶
Examples ¶
Constants ¶
const Size = 56
Size is the length in bytes of a X448 key.
Functions ¶
func KeyGen ¶
func KeyGen(public, secret *Key)
KeyGen obtains a public key given a secret key.
func Shared ¶
Shared calculates Alice's shared key from Alice's secret key and Bob's public key returning true on success. A failure case happens when the public key is a low-order point, thus the shared key is all-zeros and the function returns false.
Types ¶
type Key ¶
type Key [Size]byte
Key represents a X448 key.
Source Files ¶
curve.go curve_amd64.go curve_generic.go doc.go key.go table.go
- Version
- v1.6.1 (latest)
- Published
- Apr 9, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 2 days ago –
Tools for package owners.