package core:crypto/ecdh
Overview
A generic interface to Elliptic Curve Diffie-Hellman key exchange.
Index
Types (3)
Constants (0)
This section is empty.
Variables (4)
Procedure Groups (0)
This section is empty.
Types
Curve ¶
Curve :: enum int { Invalid, SECP256R1, X25519, X448, }
Curve the curve identifier associated with a given Private_Key or Public_Key
Related Procedures With Parameters
Related Procedures With Returns
Private_Key ¶
Private_Key :: struct { // WARNING: All of the members are to be treated as internal (ie: // the Private_Key structure is intended to be opaque). _curve: Curve, _impl: union { field_scalarp256r1.Montgomery_Domain_Field_Element, [32]u8, [56]u8, }, _pub_key: Public_Key, }
Private_Key is an ECDH private key.
Related Procedures With Parameters
Public_Key ¶
Public_Key :: struct { // WARNING: All of the members are to be treated as internal (ie: // the Public_Key structure is intended to be opaque). _curve: Curve, _impl: union { _weierstrass.Point_p256r1, [32]u8, [56]u8, }, }
Public_Key is an ECDH public key.
Related Procedures With Parameters
Constants
This section is empty.
Variables
PRIVATE_KEY_SIZES ¶
PRIVATE_KEY_SIZES is the Curve to private key size in bytes.
PUBLIC_KEY_SIZES ¶
PUBLIC_KEY_SIZES is the Curve to public key size in bytes.
SHARED_SECRET_SIZES ¶
SHARED_SECRET_SIZES is the Curve to shared secret size in bytes.
Procedures
curve ¶
curve :: proc(k: ^$T) -> Curve {…}
curve returns the Curve used by a Private_Key or Public_Key instance.
ecdh ¶
ecdh :: proc(priv_key: ^Private_Key, pub_key: ^Public_Key, dst: []u8) -> bool {…}
ecdh performs an Elliptic Curve Diffie-Hellman key exchange betwween the Private_Key and Public_Key, writing the shared secret to dst.
The neutral element is rejected as an error.
key_size ¶
key_size :: proc(k: ^$T) -> int {…}
key_size returns the key size of a Private_Key or Public_Key in bytes.
private_key_bytes ¶
private_key_bytes :: proc(priv_key: ^Private_Key, dst: []u8) {…}
private_key_bytes sets dst to byte-encoding of priv_key.
private_key_clear ¶
private_key_clear :: proc "contextless" (priv_key: ^Private_Key) {…}
private_key_clear clears priv_key to the uninitialized state.
private_key_equal ¶
private_key_equal :: proc(p, q: ^Private_Key) -> bool {…}
private_key_equal returns true iff the private keys are equal, in constant time.
private_key_generate ¶
private_key_generate :: proc(priv_key: ^Private_Key, curve: Curve) -> bool {…}
private_key_generate uses the system entropy source to generate a new Private_Key. This will only fail iff the system entropy source is missing or broken.
private_key_set_bytes ¶
private_key_set_bytes :: proc(priv_key: ^Private_Key, curve: Curve, b: []u8) -> bool {…}
private_key_set_bytes decodes a byte-encoded private key, and returns true iff the operation was successful.
public_key_bytes ¶
public_key_bytes :: proc(pub_key: ^Public_Key, dst: []u8) {…}
public_key_bytes sets dst to byte-encoding of pub_key.
public_key_clear ¶
public_key_clear :: proc "contextless" (pub_key: ^Public_Key) {…}
public_key_clear clears pub_key to the uninitialized state.
public_key_equal ¶
public_key_equal :: proc(p, q: ^Public_Key) -> bool {…}
public_key_equal returns true iff the public keys are equal, in constant time.
public_key_set_bytes ¶
public_key_set_bytes :: proc(pub_key: ^Public_Key, curve: Curve, b: []u8) -> bool {…}
public_key_set_bytes decodes a byte-encoded public key, and returns true iff the operation was successful.
public_key_set_priv ¶
public_key_set_priv :: proc(pub_key: ^Public_Key, priv_key: ^Private_Key) {…}
public_key_set_priv sets pub_key to the public component of priv_key.
shared_secret_size ¶
shared_secret_size :: proc(k: ^$T) -> int {…}
shared_secret_size returns the shared secret size of a key exchange in bytes.
Procedure Groups
This section is empty.
Source Files
Generation Information
Generated with odin version dev-2026-01 (vendor "odin") Windows_amd64 @ 2026-01-29 22:15:40.303835600 +0000 UTC