Hasty Briefsbeta

Bilingual

How to Use Hexadecimal Ed25519 Public Keys in Node.js

a day ago
  • Node.js does not natively support hexadecimal-encoded Ed25519 public keys, unlike many other cryptographic packages.
  • Keygen provides a DER-encoded Ed25519 public key in account settings to avoid conversion issues.
  • To use a hex Ed25519 key in Node, convert it to DER format using a function that includes the Ed25519 OID (06 03 2B 65 70).
  • The DER format for Ed25519 public keys always starts with a static byte sequence: 30 2a 30 05 06 03 2b 65 70 03 21 00.
  • You can simplify conversion by prepending this static prefix to the hex key.
  • To convert a DER key back to hex, remove the first 24 characters (12 bytes) of the DER prefix from its string representation.