Expand description
Koblitz secp256k1 Elliptic Curve Primitives
This module implements the secp256k1 elliptic curve operations in constant time. The curve equation is y² = x³ + 7 over the prime field F_p where:
- p = 2^256 - 2^32 - 977
- The curve order n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
All operations are implemented to be constant-time to prevent timing attacks.
Structs§
- Field
Element - secp256k1 field element representing values in F_p
- Point
- A point on the secp256k1 elliptic curve in affine coordinates
- Scalar
- secp256k1 scalar value for use in elliptic curve operations
Enums§
- Point
Format - Format of a serialized elliptic curve point
Constants§
- K256_
FIELD_ ELEMENT_ SIZE - Size of a secp256k1 field element in bytes (32 bytes = 256 bits)
- K256_
KEM_ SHARED_ SECRET_ KDF_ OUTPUT_ SIZE - Size of the KDF output for secp256k1 ECDH-KEM shared secret derivation
- K256_
POINT_ COMPRESSED_ SIZE - Size of a compressed secp256k1 point in bytes: format byte (0x02/0x03) + x-coordinate
- K256_
POINT_ UNCOMPRESSED_ SIZE - Size of an uncompressed secp256k1 point in bytes: format byte (0x04) + x-coordinate + y-coordinate
- K256_
SCALAR_ SIZE - Size of a secp256k1 scalar in bytes (32 bytes = 256 bits)
Functions§
- base_
point_ g - Get the standard base point G of the secp256k1 curve
- generate_
keypair - Generate a cryptographically secure ECDH keypair
- kdf_
hkdf_ sha256_ for_ ecdh_ kem - Key derivation function for ECDH shared secret using HKDF-SHA256
- scalar_
mult - General scalar multiplication: compute scalar * point
- scalar_
mult_ base_ g - Scalar multiplication with the base point: scalar * G