libsodium_crypto_sign_ed25519ph (libsodium v3.0.1)
View SourceStreaming Ed25519ph signatures (RFC 8032), where the message is pre-hashed with SHA-512 so it can be signed or verified in chunks.
init/0 returns an opaque state/0, which
update/2 threads through the message; each call returns a new state and
leaves its argument unchanged. Keys are the same as for
libsodium_crypto_sign_ed25519, but Ed25519ph signatures are not
interchangeable with plain Ed25519 signatures of the same message.
{PK, SK} = libsodium_crypto_sign_ed25519:keypair(),
State0 = libsodium_crypto_sign_ed25519ph:init(),
State1 = libsodium_crypto_sign_ed25519ph:update(State0, <<"hello ">>),
State2 = libsodium_crypto_sign_ed25519ph:update(State1, <<"world">>),
Sig = libsodium_crypto_sign_ed25519ph:final_create(State2, SK),
0 = libsodium_crypto_sign_ed25519ph:final_verify(State2, Sig, PK).
Summary
Types
A crypto_sign_ed25519_PUBLICKEYBYTES (32-byte) binary.
A crypto_sign_ed25519_BYTES (64-byte) binary.
A crypto_sign_ed25519_SECRETKEYBYTES (64-byte) binary.
An opaque native crypto_sign_ed25519ph_state.
Functions
Finish the streaming message in State and sign it with the Ed25519
secret key SK, returning a
libsodium_crypto_sign_ed25519:bytes/0 byte signature.
Finish the streaming message in State and verify its signature Sig
with the Ed25519 public key PK. Returns 0 when the signature is
valid and -1 otherwise.
Start a streaming Ed25519ph signature, returning a new state.
Return crypto_sign_ed25519ph_statebytes(), in bytes.
Absorb the message chunk M into State and return the updated state.
Types
-type pk() :: <<_:256>>.
A crypto_sign_ed25519_PUBLICKEYBYTES (32-byte) binary.
-type sig() :: <<_:512>>.
A crypto_sign_ed25519_BYTES (64-byte) binary.
-type sk() :: <<_:512>>.
A crypto_sign_ed25519_SECRETKEYBYTES (64-byte) binary.
-type state() :: libsodium_nif:crypto_sign_ed25519ph_state().
An opaque native crypto_sign_ed25519ph_state.
Operations never modify a state: each returns a new one, so earlier states remain valid and can be reused or shared between processes. States cannot be serialized; they exist only within the running VM.
Functions
Finish the streaming message in State and sign it with the Ed25519
secret key SK, returning a
libsodium_crypto_sign_ed25519:bytes/0 byte signature.
-spec final_verify(State, Sig, PK) -> Result when State :: state(), Sig :: sig(), PK :: pk(), Result :: 0 | -1.
Finish the streaming message in State and verify its signature Sig
with the Ed25519 public key PK. Returns 0 when the signature is
valid and -1 otherwise.
-spec init() -> Result when Result :: state() | -1.
Start a streaming Ed25519ph signature, returning a new state.
-spec statebytes() -> Result when Result :: 208.
Return crypto_sign_ed25519ph_statebytes(), in bytes.
Absorb the message chunk M into State and return the updated state.