Generates a new ECC private key on a named curve and returns it as PEM.
Supported curve names: "secp224r1", "secp256r1" (default),
"prime256v1", "secp384r1", "secp521r1", and "secp256k1".
@eryx/crypto/hazmat/ecc ModuleElliptic-curve cryptography using interoperable named curves.
Provides named-curve key generation, PEM/DER conversion, ECDSA signing/verification, and ECDH shared-secret derivation.
The initial curve set focuses on standard interoperable curves:
secp224r1, secp256r1, secp384r1, secp521r1, and secp256k1.
local ecc = require("@eryx/crypto/hazmat/ecc")
local alicePriv = ecc.generateKey("secp256r1")
local alicePub = ecc.getPublicPem(alicePriv)
local bobPriv = ecc.generateKey("secp256r1")
local bobPub = ecc.getPublicPem(bobPriv)
local sig = ecc.sign(alicePriv, buffer.fromstring("hello"))
assert(ecc.verify(alicePub, buffer.fromstring("hello"), sig))
local aliceSecret = ecc.derive(alicePriv, bobPub)
local bobSecret = ecc.derive(bobPriv, alicePub)
assert(buffer.tostring(aliceSecret) == buffer.tostring(bobSecret))
Generates a new ECC private key on a named curve and returns it as PEM.
Supported curve names: "secp224r1", "secp256r1" (default),
"prime256v1", "secp384r1", "secp521r1", and "secp256k1".
Curve name. Defaults to "secp256r1".
PEM-encoded ECC private key.
Derives the public key from a PEM-encoded ECC private key.
PEM-encoded ECC private key.
PEM-encoded ECC public key.
Signs data using ECDSA on the private key's curve.
Supported hash values: "sha256" (default), "sha1", "sha384",
and "sha512".
PEM-encoded ECC private key.
Message to sign.
Hash algorithm.
ASN.1 DER-encoded ECDSA signature.
Verifies an ECDSA signature.
PEM-encoded ECC public key.
Original message.
ASN.1 DER-encoded signature.
Hash algorithm.
true if the signature is valid.
Derives a shared secret using ECDH.
Both keys must be on the same curve.
Your PEM-encoded ECC private key.
Peer's PEM-encoded ECC public key.
Raw shared secret bytes.
Encodes a PEM private key as raw DER bytes.
PEM-encoded ECC private key.
Raw DER-encoded private key.
Encodes a PEM public key as raw DER bytes.
PEM-encoded ECC public key.
Raw DER-encoded public key.
Parses a DER-encoded ECC private key and returns it as PEM.
Raw DER-encoded ECC private key.
PEM-encoded ECC private key.
Parses a DER-encoded ECC public key and returns it as PEM.
Raw DER-encoded ECC public key.
PEM-encoded ECC public key.
Returns the key size in bits for a PEM-encoded ECC key.
PEM-encoded ECC private or public key.
Curve size in bits.
Returns the canonical curve name for a PEM-encoded ECC key.
Known return values currently include "secp224r1", "secp256r1",
"secp384r1", "secp521r1", "secp256k1", and "unknown" if the
curve is not one of the canonical names recognised by this wrapper.
PEM-encoded ECC private or public key.
Canonical curve name.