Skip to content

Sign

Ed25519 digital signatures using the detached form - the signature is separate from the message. Signs with a 64-byte secret key; verifies with the corresponding 32-byte public key. verify returns a boolean rather than erroring, so callers can branch without a pcall wrapper.

Sign . keypair ( )  -> Keypair

Generates a random Ed25519 keypair; public key is safe to share, secret key must be kept private. The secret key is 64 bytes (seed + public key); call secretKeyToPublicKey to recover the public key from it.

Returns

Keypair
Sign . secretKeyToPublicKey ( secretKey )  -> buffer

Derives the 32-byte public key from a 64-byte Ed25519 secretKey. Useful when only the secret key was persisted and the public key needs to be recovered.

Parameters

secretKey: buffer

Returns

buffer
Sign . sign ( message secretKey )  -> buffer

Signs message with secretKey (64 bytes) and returns the 64-byte detached signature. The message itself is not modified or included in the return value.

Parameters

message: buffer
secretKey: buffer

Returns

buffer
Sign . verify ( signature message publicKey )  -> boolean

Verifies signature (64 bytes) against message under publicKey (32 bytes). Returns true if valid, false otherwise - does not error on invalid signatures.

Parameters

signature: buffer
message: buffer
publicKey: buffer

Returns

boolean