Signing
Bindings for the crypto_sign API. See the libsodium crypto_sign docs for more information.
Constants
Buffer lengths (integer)
crypto_sign_PUBLICKEYBYTEScrypto_sign_SECRETKEYBYTEScrypto_sign_SEEDBYTEScrypto_sign_BYTEScrypto_box_PUBLICKEYBYTEScrypto_box_SECRETKEYBYTES
crypto_sign_seed25519_keypair
sodium.crypto_sign_seed25519_keypair(pk, sk, seed)
Creates a new keypair based on a seed.
pkshould be abufferof lengthcrypto_sign_PUBLICKEYBYTESskshould be abufferof lengthcrypto_sign_SECRETKEYBYTESseedshould be abufferof lengthcrypto_sign_SEEDBYTES
The generated public and secret key will be stored in buffers.
crypto_sign_keypair
sodium.crypto_sign_keypair(pk, sk)
Creates a new keypair.
pkshould be abufferof lengthcrypto_sign_PUBLICKEYBYTESskshould be abufferof lengthcrypto_sign_SECRETKEYBYTES
The generated public and secret key will be stored in buffers.
crypto_sign
sodium.crypto_sign(sm, m, sk)
Signs a message.
smshould be abufferof lengthcrypto_sign_BYTES + m.lengthmshould be abufferof any lengthskshould be a secret key
The generated signed message will be stored in sm.
crypto_sign_open
var bool = sodium.crypto_sign_open(m, sm, pk)
Verifies and opens a message.
mshould be abufferof lengthsm.length - crypto_sign_BYTESsmof length at leastcrypto_sign_BYTESpkshould be a public key
Will return true if the message could be verified. Otherwise false. If verified, the originally signed message is stored in the message buffer.
crypto_sign_detached
sodium.crypto_sign_detached(sig, m, sk)
Same as crypto_sign, except that it only stores the signature.
sigshould be abufferof lengthcrypto_sign_BYTESmshould be abufferof any lengthskshould be a secret key
The generated signature is stored in signature.
crypto_sign_verify_detached
var bool = sodium.crypto_sign_verify_detached(sig, m, pk)
Verifies a signature.
sigshould be abufferof lengthcrypto_sign_BYTESmshould be abufferof any lengthpkshould be a public key
Will return true if the message could be verified. Otherwise false.
crypto_sign_ed25519_pk_to_curve25519
sodium.crypto_sign_ed25519_pk_to_curve25519(x25519_pk, ed25519_pk)
Converts an ed25519 public key to curve25519 (which can be used with box and scalarmult).
x25519_pkshould be abufferof lengthcrypto_box_PUBLICKEYBYTESed25519_pkshould be abufferof lengthcrypto_sign_PUBLICKEYBYTES
crypto_sign_ed25519_sk_to_curve25519
sodium.crypto_sign_ed25519_sk_to_curve25519(x25519_sk, ed25519_sk)
Converts an ed25519 secret key to curve25519 (which can be used with box and scalarmult).
x25519_skshould be abufferof lengthcrypto_box_SECRETKEYBYTESed25519_skshould be abufferof lengthcrypto_sign_SECRETKEYBYTES
crypto_sign_ed25519_sk_to_pk
sodium.crypto_sign_ed25519_sk_to_pk(pk, sk)
Extracts an ed25519 public key from an ed25519 secret key.
pkmust be abufferof at leastcrypto_box_PUBLICKEYBYTESbytesskmust be abufferof at leastcrypto_sign_SECRETKEYBYTESbytes
