const X25519_KEY_SIZE
pub const X25519_KEY_SIZE = 32Purpose
Constant X25519_KEY_SIZE, defining protocol or algorithm parameters.
#crypto/ecdh`crypto/ecdh`: Curve, PrivateKey, PublicKey, X25519. Implements RFC 7748 Curve25519 / X25519 Montgomery ladder scalar multiplication. XU-CT-CLASS: variable-time XU-CT-USE: fixed-shape-only Curve arithmetic uses math/big; operations are variable-time with fixed sizes.
const X25519_KEY_SIZEpub const X25519_KEY_SIZE = 32Constant X25519_KEY_SIZE, defining protocol or algorithm parameters.
struct Curvepub struct Curve {
pub name string
}Structure encapsulating name.
name stringx25519pub fn x25519() CurveExecute x25519.
No arguments are required.
Curve — a value of this type
struct PublicKeypub struct PublicKey {
pub curve Curve
pub raw string
}Structure encapsulating curve, raw.
curve Curveraw string(&PublicKey) bytespub fn (k &PublicKey) bytes() stringOperation on &PublicKey: return the buffered bytes.
k &PublicKeyPublicKey instance used by this call (borrow).string — result string
(&PublicKey) equalpub fn (k &PublicKey) equal(other &PublicKey) boolOperation on &PublicKey: report whether the two values are equal.
k &PublicKeyPublicKey instance used by this call (borrow).other &PublicKeybool — true or false
struct PrivateKeypub struct PrivateKey {
pub curve Curve
pub raw string
pub pub_key PublicKey
}Structure encapsulating curve, raw, pub_key.
curve Curveraw stringpub_key PublicKey(&PrivateKey) bytespub fn (k &PrivateKey) bytes() stringOperation on &PrivateKey: return the buffered bytes.
k &PrivateKeyPrivateKey instance used by this call (borrow).string — result string
(&PrivateKey) public_keypub fn (k &PrivateKey) public_key() PublicKeyOperation on &PrivateKey: public key.
k &PrivateKeyPrivateKey instance used by this call (borrow).PublicKey — a value of this type
(&PrivateKey) equalpub fn (k &PrivateKey) equal(other &PrivateKey) boolOperation on &PrivateKey: report whether the two values are equal.
k &PrivateKeyPrivateKey instance used by this call (borrow).other &PrivateKeybool — true or false
base_pointpub fn base_point() stringBase name point.
No arguments are required.
string — result string
scalar_multpub fn scalar_mult(scalar &string, point &string) stringscalar_mult computes the X25519 scalar multiplication of point u by scalar k using the Montgomery ladder per RFC 7748 §5. Throws on failure; handle the error or propagate it to the caller.
scalar &stringpoint &stringstring — result string
new_public_keypub fn new_public_key(c Curve, key &string) PublicKeyConstruct public key. Throws on failure; handle the error or propagate it to the caller.
c Curvekey &stringPublicKey — a value of this type
new_private_keypub fn new_private_key(c Curve, key &string) PrivateKeyConstruct private key. Throws on failure; handle the error or propagate it to the caller.
c Curvekey &stringPrivateKey — a value of this type
generate_keypub fn generate_key(c Curve) PrivateKeyGenerate key. Throws on failure; handle the error or propagate it to the caller.
c CurvePrivateKey — a value of this type
(&PrivateKey) ecdhpub fn (k &PrivateKey) ecdh(remote &PublicKey) stringecdh performs the Diffie-Hellman key exchange per RFC 7748. Throws on failure; handle the error or propagate it to the caller.
k &PrivateKeyPrivateKey instance used by this call (borrow).remote &PublicKeystring — result string