mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-27 06:43:19 +08:00
crypto.createECDH returns a native ECDH handle backed by mbedTLS for prime192v1, secp224r1, prime256v1, secp384r1, secp521r1, secp192k1, secp224k1, secp256k1, brainpoolP256r1, brainpoolP384r1 and brainpoolP512r1. generateKeys, computeSecret, getPublicKey, getPrivateKey, setPrivateKey, setPublicKey and ECDH.convertKey follow Node 24: compressed, uncompressed and hybrid points, input and output encodings, the private key range, key pair validation, and Node's error codes and messages. Curve names follow OpenSSL's short-name lookup: names of other curves from crypto.getCurves() are refused at compile time when literal and throw a coded SC2020 error when computed, other OpenSSL short names throw ERR_CRYPTO_OPERATION_FAILED, and unknown names throw ERR_CRYPTO_INVALID_CURVE. Calls whose arguments no @types/node overload accepts, and computeSecret(view, encoding), are refused at compile time. The runtime unit scr_ecdh.c links, with the mbedTLS archive, only into programs that use ECDH. wasm32-wasi builds refuse it.