File syn_x25519.h¶
FileList > crypto > syn_x25519.h
Go to the source code of this file
X25519 Diffie-Hellman key exchange — RFC 7748, pure C99. More...
#include <stdint.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_x25519 (uint8_t shared_out, const uint8_t scalar, const uint8_t point) X25519 scalar multiplication. |
| void | syn_x25519_pubkey (uint8_t public_out, const uint8_t private_key) Derive a public key from a private key. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | syn_x25519_clamp (uint8_t key) Clamp a 32-byte private key per RFC 7748. |
Detailed Description¶
Elliptic-curve Diffie-Hellman on Curve25519 using the Montgomery ladder. Provides shared-secret computation and public-key derivation.
This is the most computationally expensive WireGuard operation (~1–2 seconds on Cortex-M4 @ 64 MHz) but only runs during handshake, not on every packet.
** **
uint8_t my_priv[32], my_pub[32], shared[32];
// Generate keypair (private key = 32 random bytes, then clamp):
fill_random(my_priv, 32);
syn_x25519_clamp(my_priv);
syn_x25519_pubkey(my_pub, my_priv);
// Compute shared secret with peer's public key:
syn_x25519(shared, my_priv, peer_pub);
Public Functions Documentation¶
function syn_x25519¶
X25519 scalar multiplication.
Computes shared = scalar * point on Curve25519.
Parameters:
shared_outOutput: 32-byte shared secret.scalar32-byte private scalar (should be clamped).point32-byte public point (peer's public key).
function syn_x25519_pubkey¶
Derive a public key from a private key.
Computes public = scalar * basepoint (the Curve25519 generator, u=9).
Parameters:
public_outOutput: 32-byte public key.private_key32-byte private key (should be clamped).
Public Static Functions Documentation¶
function syn_x25519_clamp¶
Clamp a 32-byte private key per RFC 7748.
Sets bits to ensure the scalar is a multiple of the cofactor (8) and has the high bit set for constant-time operation.
Parameters:
key32-byte key to clamp (modified in place).
The documentation for this class was generated from the following file src/syntropic/crypto/syn_x25519.h