libdecaf_curve448 (libdecaf v3.0.0)

View Source

Ed448 signatures, native streaming Ed448ph, and X448 key agreement.

keypair_random/0 and keypair_derive/1 return native keypair resources. keypair_extract_private_key/1 returns the 57-byte secret seed. In contrast, eddsa_keypair/0,1 returns {PublicKey, SigningKey}, where the 114-byte signing key is <<Seed/binary, PublicKey/binary>>.

Sign and verify a binary message using a native keypair:

Keypair = libdecaf_curve448:keypair_random(),
PublicKey = libdecaf_curve448:keypair_extract_public_key(Keypair),
Signature = libdecaf_curve448:ed448_keypair_sign(<<"message">>, Keypair),
true = libdecaf_curve448:ed448_verify(Signature, <<"message">>, PublicKey).

ed448ph prehashes the original message using SHAKE256 with a 64-byte output. Do not prehash the message yourself. Streaming prehash signing keeps the keypair, context, and prehash in native resources and accepts iodata chunks:

{PublicKey, SigningKey} = libdecaf_curve448:eddsa_keypair(),
S0 = libdecaf_curve448:ed448ph_sign_init(SigningKey, <<"example">>),
S1 = libdecaf_curve448:ed448ph_sign_update(S0, [<<"first ">>, <<"chunk">>]),
S2 = libdecaf_curve448:ed448ph_sign_update(S1, <<"second chunk">>),
Signature = libdecaf_curve448:ed448ph_sign_final(S2),
V0 = libdecaf_curve448:ed448ph_verify_init(Signature, PublicKey, <<"example">>),
V1 = libdecaf_curve448:ed448ph_verify_update(V0, <<"first chunksecond chunk">>),
true = libdecaf_curve448:ed448ph_verify_final(V1).

Use ed448ph_keypair_sign_init/1,2 when you already have a native keypair. Both initializers produce the same signing state. Each update returns a new immutable state; finalization leaves its input reusable. Signing and verification states are distinct, and states from the other curve are rejected. Large updates yield to the scheduler, and message chunks are not retained after an update.

Contexts are binaries of at most 255 bytes and default to <<>> where supported.

X448 uses 56-byte secret scalars and public keys. The scalar is the first argument to x448/2; a rejected peer key returns error.

{AlicePublic, AliceSecret} = libdecaf_curve448:x448_keypair(),
{BobPublic, BobSecret} = libdecaf_curve448:x448_keypair(),
Shared = libdecaf_curve448:x448(AliceSecret, BobPublic),
Shared = libdecaf_curve448:x448(BobSecret, AlicePublic).

Signature encodings follow RFC 8032; key agreement follows RFC 7748.

Summary

Types

A signature context of at most 255 bytes. The empty context is <<>>.

An integer or a 56-byte little-endian X448 coordinate.

An immutable native Ed448ph signing state retaining its keypair and context.

An immutable native Ed448ph verification state retaining its signature, public key, and context.

A public key paired with the encoded signing key <<Seed/binary, PublicKey/binary>>.

A native Ed448 keypair resource, distinct from an encoded signing key.

An original message for one-shot signing or verification. Streaming updates accept iodata instead.

A 57-byte Ed448 public key.

An integer or a 56-byte X448 secret scalar.

A 114-byte signing key: the 57-byte secret seed followed by its matching public key.

A 57-byte secret seed used to derive an Ed448 keypair.

A 114-byte Ed448 signature encoding.

An X448 public key paired with its secret scalar.

A 56-byte X448 public key.

A 56-byte X448 secret scalar, distinct from an Ed448 secret seed.

A 56-byte X448 shared secret.

Functions

Derive an X448 public coordinate and return it as a little-endian integer. Integer scalars are encoded using their low 448 bits before the X448 operation. Use x448/1 for the binary-returning interface.

Compute X448 with an integer or binary scalar and peer coordinate. Integers are encoded using their low 448 bits; the result is decoded as a little-endian integer. A rejected peer key raises {badmatch, error}. Use x448/2 for a binary result or the atom error.

Sign a binary message using a native keypair and Ed448. The message is signed directly without the prehash variant. Use an empty context, equivalent to passing <<>> to the next arity.

Sign a binary message using a native keypair and Ed448. The message is signed directly without the prehash variant. The context must be a binary of at most 255 bytes and must match between signing and verification.

Sign a binary message using an encoded signing key and Ed448. The NIF verifies that its seed and public key match; a mismatch raises an error. The message is signed directly without the prehash variant. Use an empty context, equivalent to passing <<>> to the next arity.

Sign a binary message using an encoded signing key and Ed448. The NIF verifies that its seed and public key match; a mismatch raises an error. The message is signed directly without the prehash variant. The context must be a binary of at most 255 bytes and must match between signing and verification.

Verify a Ed448 signature over a binary message. Return false for a correctly sized signature that does not verify. The message is signed directly without the prehash variant. Use an empty context, equivalent to passing <<>> to the next arity.

Verify a Ed448 signature over a binary message. Return false for a correctly sized signature that does not verify. The message is signed directly without the prehash variant. The context must be a binary of at most 255 bytes and must match between signing and verification.

Sign a binary message using a native keypair and Ed448ph. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. Use an empty context, equivalent to passing <<>> to the next arity.

Sign a binary message using a native keypair and Ed448ph. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. The context must be a binary of at most 255 bytes and must match between signing and verification.

Start native Ed448ph signing using a keypair resource. The state retains the keypair, so the caller does not need to keep another reference. Continue with ed448ph_sign_update/2 and ed448ph_sign_final/1. The context defaults to <<>>.

Start native Ed448ph signing using a keypair resource. The state retains the keypair, so the caller does not need to keep another reference. Continue with ed448ph_sign_update/2 and ed448ph_sign_final/1. The context must contain at most 255 bytes. For example

Sign a binary message using an encoded signing key and Ed448ph. The NIF verifies that its seed and public key match; a mismatch raises an error. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. Use an empty context, equivalent to passing <<>> to the next arity.

Sign a binary message using an encoded signing key and Ed448ph. The NIF verifies that its seed and public key match; a mismatch raises an error. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. The context must be a binary of at most 255 bytes and must match between signing and verification.

Sign the accumulated message with the retained keypair and context. The result matches ed448ph_keypair_sign/3 for the same message, keypair, and context. Finalization leaves the state reusable and produces the same signature when repeated; it does not sign a caller-supplied digest.

Start native Ed448ph signing using <<Seed/binary, PublicKey/binary>>. The NIF validates that both parts match and creates a retained native keypair; a mismatch raises an error. Continue with ed448ph_sign_update/2 and ed448ph_sign_final/1. The context defaults to <<>>.

Start native Ed448ph signing using <<Seed/binary, PublicKey/binary>>. The NIF validates that both parts match and creates a retained native keypair; a mismatch raises an error. Continue with ed448ph_sign_update/2 and ed448ph_sign_final/1. The context must contain at most 255 bytes. For example

Prehash another chunk of the original message and return the next signing state. Both signing initializers use this function. The input state is unchanged, so it can be reused or branched. Large inputs yield; the chunk is released after the update.

Verify a Ed448ph signature over a binary message. Return false for a correctly sized signature that does not verify. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. Use an empty context, equivalent to passing <<>> to the next arity.

Verify a Ed448ph signature over a binary message. Return false for a correctly sized signature that does not verify. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. The context must be a binary of at most 255 bytes and must match between signing and verification.

Verify the accumulated message against the retained signature, public key, and context. Return false if verification fails. The state remains reusable, so repeated finalization returns the same result.

Start native Ed448ph verification, retaining the signature and public key. The signature and public key must have 114 and 57 bytes respectively. Cryptographic verification happens in ed448ph_verify_final/1. The context defaults to <<>>.

Start native Ed448ph verification, retaining the signature and public key. The signature and public key must have 114 and 57 bytes respectively. Cryptographic verification happens in ed448ph_verify_final/1. The context must match the signing context and contain at most 255 bytes.

Prehash another chunk of the original message and return the next verification state. The input state is unchanged. Large updates yield; a signing state or state from another algorithm is rejected.

Generate a random encoded keypair {PublicKey, <<Seed/binary, PublicKey/binary>>}. Use the second element with ed448_sign/2 or ed448ph_sign_init/1.

Derive an encoded keypair from a 57-byte secret seed. The returned signing key is the seed followed by its public key.

Convert an encoded Ed448 keypair to a X448 keypair. The supplied public key must match the public-key bytes in the signing key; the converted public and private parts must also agree.

Convert a Ed448 public-key encoding to a X448 public key. This conversion alone does not establish ownership of the corresponding secret key.

Derive the Ed448 public key from a secret seed.

Derive an X448 keypair from an Ed448 secret seed. This applies the upstream private-key conversion before deriving the X448 public key.

Convert a 57-byte Ed448 secret seed to a 56-byte X448 secret scalar.

Extract the public-key bytes from an encoded signing key. This only splits the encoding; it does not check that the seed and public key match.

Extract the secret-seed bytes from an encoded signing key. This only splits the encoding; it does not validate the public-key bytes.

Convert an encoded Ed448 signing key to a X448 keypair. Raise {badarg, [SigningKey]} if the converted public key differs from the public key derived from the converted seed.

Derive a native Ed448 keypair from a 57-byte secret seed. The resource retains the seed and its derived public key.

Extract the 57-byte secret seed from a native keypair. This returns the seed alone, rather than the encoded seed/public key signing key.

Extract the 57-byte public key from a native Ed448 keypair.

Generate a native Ed448 keypair using crypto:strong_rand_bytes/1. Use this resource with ed448_keypair_sign/2 or ed448ph_keypair_sign_init/1.

Derive a 56-byte X448 public key from a secret scalar. The scalar is clamped by the native X448 operation.

Compute an X448 shared secret with the secret scalar first and peer public key second. Return error when the native operation rejects a peer key, including low-order inputs producing an all-zero shared secret. Both keys must have 56 bytes.

Generate a random X448 keypair {PublicKey, SecretScalar}. The secret scalar contains 56 random bytes from crypto:strong_rand_bytes/1.

Derive an X448 keypair {PublicKey, SecretScalar} from the supplied scalar. The returned scalar bytes are the supplied bytes; clamping happens inside X448.

Types

context()

-type context() :: binary().

A signature context of at most 255 bytes. The empty context is <<>>.

coordinate()

-type coordinate() :: integer() | x448_public_key().

An integer or a 56-byte little-endian X448 coordinate.

ed448ph_sign_state()

-type ed448ph_sign_state() :: libdecaf_nif:ed448ph_sign_state().

An immutable native Ed448ph signing state retaining its keypair and context.

ed448ph_verify_state()

-type ed448ph_verify_state() :: libdecaf_nif:ed448ph_verify_state().

An immutable native Ed448ph verification state retaining its signature, public key, and context.

eddsa_keypair()

-type eddsa_keypair() :: {public_key(), secret_key()}.

A public key paired with the encoded signing key <<Seed/binary, PublicKey/binary>>.

keypair()

-type keypair() :: libdecaf_nif:ed448_keypair().

A native Ed448 keypair resource, distinct from an encoded signing key.

message()

-type message() :: binary().

An original message for one-shot signing or verification. Streaming updates accept iodata instead.

public_key()

-type public_key() :: libdecaf_nif:ed448_public_key().

A 57-byte Ed448 public key.

scalar()

-type scalar() :: integer() | x448_secret_key().

An integer or a 56-byte X448 secret scalar.

secret_key()

-type secret_key() :: libdecaf_nif:ed448_signing_key().

A 114-byte signing key: the 57-byte secret seed followed by its matching public key.

seed()

-type seed() :: libdecaf_nif:ed448_secret_key().

A 57-byte secret seed used to derive an Ed448 keypair.

signature()

-type signature() :: libdecaf_nif:ed448_signature().

A 114-byte Ed448 signature encoding.

x448_keypair()

-type x448_keypair() :: {x448_public_key(), x448_secret_key()}.

An X448 public key paired with its secret scalar.

x448_public_key()

-type x448_public_key() :: libdecaf_nif:x448_public_key().

A 56-byte X448 public key.

x448_secret_key()

-type x448_secret_key() :: libdecaf_nif:x448_scalar().

A 56-byte X448 secret scalar, distinct from an Ed448 secret seed.

x448_shared_secret()

-type x448_shared_secret() :: libdecaf_nif:x448_shared_secret().

A 56-byte X448 shared secret.

Functions

curve448(Scalar)

-spec curve448(Scalar) -> Coordinate when Scalar :: scalar(), Coordinate :: non_neg_integer().

Derive an X448 public coordinate and return it as a little-endian integer. Integer scalars are encoded using their low 448 bits before the X448 operation. Use x448/1 for the binary-returning interface.

curve448(Scalar, Coordinate)

-spec curve448(Scalar, Coordinate) -> SharedCoordinate
                  when
                      Scalar :: scalar(),
                      Coordinate :: coordinate(),
                      SharedCoordinate :: non_neg_integer().

Compute X448 with an integer or binary scalar and peer coordinate. Integers are encoded using their low 448 bits; the result is decoded as a little-endian integer. A rejected peer key raises {badmatch, error}. Use x448/2 for a binary result or the atom error.

ed448_keypair_sign(Message, Keypair)

-spec ed448_keypair_sign(Message, Keypair) -> Signature
                            when Message :: message(), Keypair :: keypair(), Signature :: signature().

Sign a binary message using a native keypair and Ed448. The message is signed directly without the prehash variant. Use an empty context, equivalent to passing <<>> to the next arity.

ed448_keypair_sign(Message, Keypair, Context)

-spec ed448_keypair_sign(Message, Keypair, Context) -> Signature
                            when
                                Message :: message(),
                                Keypair :: keypair(),
                                Context :: context(),
                                Signature :: signature().

Sign a binary message using a native keypair and Ed448. The message is signed directly without the prehash variant. The context must be a binary of at most 255 bytes and must match between signing and verification.

ed448_sign(Message, SigningKey)

-spec ed448_sign(Message, SigningKey) -> Signature
                    when Message :: message(), SigningKey :: secret_key(), Signature :: signature().

Sign a binary message using an encoded signing key and Ed448. The NIF verifies that its seed and public key match; a mismatch raises an error. The message is signed directly without the prehash variant. Use an empty context, equivalent to passing <<>> to the next arity.

ed448_sign(Message, SigningKey, Context)

-spec ed448_sign(Message, SigningKey, Context) -> Signature
                    when
                        Message :: message(),
                        SigningKey :: secret_key(),
                        Context :: context(),
                        Signature :: signature().

Sign a binary message using an encoded signing key and Ed448. The NIF verifies that its seed and public key match; a mismatch raises an error. The message is signed directly without the prehash variant. The context must be a binary of at most 255 bytes and must match between signing and verification.

ed448_verify(Signature, Message, PublicKey)

-spec ed448_verify(Signature, Message, PublicKey) -> Valid
                      when
                          Signature :: signature(),
                          Message :: message(),
                          PublicKey :: public_key(),
                          Valid :: boolean().

Verify a Ed448 signature over a binary message. Return false for a correctly sized signature that does not verify. The message is signed directly without the prehash variant. Use an empty context, equivalent to passing <<>> to the next arity.

ed448_verify(Signature, Message, PublicKey, Context)

-spec ed448_verify(Signature, Message, PublicKey, Context) -> Valid
                      when
                          Signature :: signature(),
                          Message :: message(),
                          PublicKey :: public_key(),
                          Context :: context(),
                          Valid :: boolean().

Verify a Ed448 signature over a binary message. Return false for a correctly sized signature that does not verify. The message is signed directly without the prehash variant. The context must be a binary of at most 255 bytes and must match between signing and verification.

ed448ph_keypair_sign(Message, Keypair)

-spec ed448ph_keypair_sign(Message, Keypair) -> Signature
                              when Message :: message(), Keypair :: keypair(), Signature :: signature().

Sign a binary message using a native keypair and Ed448ph. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. Use an empty context, equivalent to passing <<>> to the next arity.

ed448ph_keypair_sign(Message, Keypair, Context)

-spec ed448ph_keypair_sign(Message, Keypair, Context) -> Signature
                              when
                                  Message :: message(),
                                  Keypair :: keypair(),
                                  Context :: context(),
                                  Signature :: signature().

Sign a binary message using a native keypair and Ed448ph. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. The context must be a binary of at most 255 bytes and must match between signing and verification.

ed448ph_keypair_sign_init(Keypair)

-spec ed448ph_keypair_sign_init(Keypair) -> State
                                   when Keypair :: keypair(), State :: ed448ph_sign_state().

Start native Ed448ph signing using a keypair resource. The state retains the keypair, so the caller does not need to keep another reference. Continue with ed448ph_sign_update/2 and ed448ph_sign_final/1. The context defaults to <<>>.

ed448ph_keypair_sign_init(Keypair, Context)

-spec ed448ph_keypair_sign_init(Keypair, Context) -> State
                                   when
                                       Keypair :: keypair(),
                                       Context :: context(),
                                       State :: ed448ph_sign_state().

Start native Ed448ph signing using a keypair resource. The state retains the keypair, so the caller does not need to keep another reference. Continue with ed448ph_sign_update/2 and ed448ph_sign_final/1. The context must contain at most 255 bytes. For example:

Keypair = libdecaf_curve448:keypair_random(),
S0 = libdecaf_curve448:ed448ph_keypair_sign_init(Keypair, <<"example">>),
S1 = libdecaf_curve448:ed448ph_sign_update(S0, [<<"hello ">>, <<"world">>]),
Signature = libdecaf_curve448:ed448ph_sign_final(S1).

ed448ph_sign(Message, SigningKey)

-spec ed448ph_sign(Message, SigningKey) -> Signature
                      when Message :: message(), SigningKey :: secret_key(), Signature :: signature().

Sign a binary message using an encoded signing key and Ed448ph. The NIF verifies that its seed and public key match; a mismatch raises an error. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. Use an empty context, equivalent to passing <<>> to the next arity.

ed448ph_sign(Message, SigningKey, Context)

-spec ed448ph_sign(Message, SigningKey, Context) -> Signature
                      when
                          Message :: message(),
                          SigningKey :: secret_key(),
                          Context :: context(),
                          Signature :: signature().

Sign a binary message using an encoded signing key and Ed448ph. The NIF verifies that its seed and public key match; a mismatch raises an error. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. The context must be a binary of at most 255 bytes and must match between signing and verification.

ed448ph_sign_final(State)

-spec ed448ph_sign_final(State) -> Signature
                            when State :: ed448ph_sign_state(), Signature :: signature().

Sign the accumulated message with the retained keypair and context. The result matches ed448ph_keypair_sign/3 for the same message, keypair, and context. Finalization leaves the state reusable and produces the same signature when repeated; it does not sign a caller-supplied digest.

ed448ph_sign_init(SigningKey)

-spec ed448ph_sign_init(SigningKey) -> State
                           when SigningKey :: secret_key(), State :: ed448ph_sign_state().

Start native Ed448ph signing using <<Seed/binary, PublicKey/binary>>. The NIF validates that both parts match and creates a retained native keypair; a mismatch raises an error. Continue with ed448ph_sign_update/2 and ed448ph_sign_final/1. The context defaults to <<>>.

ed448ph_sign_init(SigningKey, Context)

-spec ed448ph_sign_init(SigningKey, Context) -> State
                           when
                               SigningKey :: secret_key(),
                               Context :: context(),
                               State :: ed448ph_sign_state().

Start native Ed448ph signing using <<Seed/binary, PublicKey/binary>>. The NIF validates that both parts match and creates a retained native keypair; a mismatch raises an error. Continue with ed448ph_sign_update/2 and ed448ph_sign_final/1. The context must contain at most 255 bytes. For example:

{_PublicKey, SigningKey} = libdecaf_curve448:eddsa_keypair(),
S0 = libdecaf_curve448:ed448ph_sign_init(SigningKey, <<"example">>),
S1 = libdecaf_curve448:ed448ph_sign_update(S0, [<<"hello ">>, <<"world">>]),
Signature = libdecaf_curve448:ed448ph_sign_final(S1).

ed448ph_sign_update(State, Input)

-spec ed448ph_sign_update(State, Input) -> NextState
                             when
                                 State :: ed448ph_sign_state(),
                                 Input :: iodata(),
                                 NextState :: ed448ph_sign_state().

Prehash another chunk of the original message and return the next signing state. Both signing initializers use this function. The input state is unchanged, so it can be reused or branched. Large inputs yield; the chunk is released after the update.

ed448ph_verify(Signature, Message, PublicKey)

-spec ed448ph_verify(Signature, Message, PublicKey) -> Valid
                        when
                            Signature :: signature(),
                            Message :: message(),
                            PublicKey :: public_key(),
                            Valid :: boolean().

Verify a Ed448ph signature over a binary message. Return false for a correctly sized signature that does not verify. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. Use an empty context, equivalent to passing <<>> to the next arity.

ed448ph_verify(Signature, Message, PublicKey, Context)

-spec ed448ph_verify(Signature, Message, PublicKey, Context) -> Valid
                        when
                            Signature :: signature(),
                            Message :: message(),
                            PublicKey :: public_key(),
                            Context :: context(),
                            Valid :: boolean().

Verify a Ed448ph signature over a binary message. Return false for a correctly sized signature that does not verify. Pass the original message; Ed448ph computes its 64-byte SHAKE256 prehash internally. The context must be a binary of at most 255 bytes and must match between signing and verification.

ed448ph_verify_final(State)

-spec ed448ph_verify_final(State) -> Valid when State :: ed448ph_verify_state(), Valid :: boolean().

Verify the accumulated message against the retained signature, public key, and context. Return false if verification fails. The state remains reusable, so repeated finalization returns the same result.

ed448ph_verify_init(Signature, PublicKey)

-spec ed448ph_verify_init(Signature, PublicKey) -> State
                             when
                                 Signature :: signature(),
                                 PublicKey :: public_key(),
                                 State :: ed448ph_verify_state().

Start native Ed448ph verification, retaining the signature and public key. The signature and public key must have 114 and 57 bytes respectively. Cryptographic verification happens in ed448ph_verify_final/1. The context defaults to <<>>.

ed448ph_verify_init(Signature, PublicKey, Context)

-spec ed448ph_verify_init(Signature, PublicKey, Context) -> State
                             when
                                 Signature :: signature(),
                                 PublicKey :: public_key(),
                                 Context :: context(),
                                 State :: ed448ph_verify_state().

Start native Ed448ph verification, retaining the signature and public key. The signature and public key must have 114 and 57 bytes respectively. Cryptographic verification happens in ed448ph_verify_final/1. The context must match the signing context and contain at most 255 bytes.

Keypair = libdecaf_curve448:keypair_random(),
PublicKey = libdecaf_curve448:keypair_extract_public_key(Keypair),
Signature = libdecaf_curve448:ed448ph_keypair_sign(<<"hello world">>, Keypair, <<"example">>),
V0 = libdecaf_curve448:ed448ph_verify_init(Signature, PublicKey, <<"example">>),
V1 = libdecaf_curve448:ed448ph_verify_update(V0, [<<"hello ">>, <<"world">>]),
true = libdecaf_curve448:ed448ph_verify_final(V1).

ed448ph_verify_update(State, Input)

-spec ed448ph_verify_update(State, Input) -> NextState
                               when
                                   State :: ed448ph_verify_state(),
                                   Input :: iodata(),
                                   NextState :: ed448ph_verify_state().

Prehash another chunk of the original message and return the next verification state. The input state is unchanged. Large updates yield; a signing state or state from another algorithm is rejected.

eddsa_keypair()

-spec eddsa_keypair() -> Keypair when Keypair :: eddsa_keypair().

Generate a random encoded keypair {PublicKey, <<Seed/binary, PublicKey/binary>>}. Use the second element with ed448_sign/2 or ed448ph_sign_init/1.

eddsa_keypair(Seed)

-spec eddsa_keypair(Seed) -> Keypair when Seed :: seed(), Keypair :: eddsa_keypair().

Derive an encoded keypair from a 57-byte secret seed. The returned signing key is the seed followed by its public key.

eddsa_keypair_to_x448_keypair(Keypair)

-spec eddsa_keypair_to_x448_keypair(Keypair) -> KeypairX
                                       when Keypair :: eddsa_keypair(), KeypairX :: x448_keypair().

Convert an encoded Ed448 keypair to a X448 keypair. The supplied public key must match the public-key bytes in the signing key; the converted public and private parts must also agree.

eddsa_pk_to_x448_pk(PublicKey)

-spec eddsa_pk_to_x448_pk(PublicKey) -> PublicKeyX
                             when PublicKey :: public_key(), PublicKeyX :: x448_public_key().

Convert a Ed448 public-key encoding to a X448 public key. This conversion alone does not establish ownership of the corresponding secret key.

eddsa_secret_to_pk(Seed)

-spec eddsa_secret_to_pk(Seed) -> PublicKey when Seed :: seed(), PublicKey :: public_key().

Derive the Ed448 public key from a secret seed.

eddsa_secret_to_x448_keypair(Seed)

-spec eddsa_secret_to_x448_keypair(Seed) -> KeypairX when Seed :: seed(), KeypairX :: x448_keypair().

Derive an X448 keypair from an Ed448 secret seed. This applies the upstream private-key conversion before deriving the X448 public key.

eddsa_secret_to_x448_secret(Seed)

-spec eddsa_secret_to_x448_secret(Seed) -> SecretX when Seed :: seed(), SecretX :: x448_secret_key().

Convert a 57-byte Ed448 secret seed to a 56-byte X448 secret scalar.

eddsa_sk_to_pk(SigningKey)

-spec eddsa_sk_to_pk(SigningKey) -> PublicKey when SigningKey :: secret_key(), PublicKey :: public_key().

Extract the public-key bytes from an encoded signing key. This only splits the encoding; it does not check that the seed and public key match.

eddsa_sk_to_secret(SigningKey)

-spec eddsa_sk_to_secret(SigningKey) -> Seed when SigningKey :: secret_key(), Seed :: seed().

Extract the secret-seed bytes from an encoded signing key. This only splits the encoding; it does not validate the public-key bytes.

eddsa_sk_to_x448_keypair(SigningKey)

-spec eddsa_sk_to_x448_keypair(SigningKey) -> KeypairX
                                  when SigningKey :: secret_key(), KeypairX :: x448_keypair().

Convert an encoded Ed448 signing key to a X448 keypair. Raise {badarg, [SigningKey]} if the converted public key differs from the public key derived from the converted seed.

keypair_derive(Seed)

-spec keypair_derive(Seed) -> Keypair when Seed :: seed(), Keypair :: keypair().

Derive a native Ed448 keypair from a 57-byte secret seed. The resource retains the seed and its derived public key.

keypair_extract_private_key(Keypair)

-spec keypair_extract_private_key(Keypair) -> Seed when Keypair :: keypair(), Seed :: seed().

Extract the 57-byte secret seed from a native keypair. This returns the seed alone, rather than the encoded seed/public key signing key.

keypair_extract_public_key(Keypair)

-spec keypair_extract_public_key(Keypair) -> PublicKey
                                    when Keypair :: keypair(), PublicKey :: public_key().

Extract the 57-byte public key from a native Ed448 keypair.

keypair_random()

-spec keypair_random() -> Keypair when Keypair :: keypair().

Generate a native Ed448 keypair using crypto:strong_rand_bytes/1. Use this resource with ed448_keypair_sign/2 or ed448ph_keypair_sign_init/1.

x448(Secret)

-spec x448(Secret) -> PublicKey when Secret :: x448_secret_key(), PublicKey :: x448_public_key().

Derive a 56-byte X448 public key from a secret scalar. The scalar is clamped by the native X448 operation.

x448(Secret, PeerPublicKey)

-spec x448(Secret, PeerPublicKey) -> SharedSecret
              when
                  Secret :: x448_secret_key(),
                  PeerPublicKey :: x448_public_key(),
                  SharedSecret :: x448_shared_secret() | error.

Compute an X448 shared secret with the secret scalar first and peer public key second. Return error when the native operation rejects a peer key, including low-order inputs producing an all-zero shared secret. Both keys must have 56 bytes.

x448_keypair()

-spec x448_keypair() -> Keypair when Keypair :: x448_keypair().

Generate a random X448 keypair {PublicKey, SecretScalar}. The secret scalar contains 56 random bytes from crypto:strong_rand_bytes/1.

x448_keypair(Secret)

-spec x448_keypair(Secret) -> Keypair when Secret :: x448_secret_key(), Keypair :: x448_keypair().

Derive an X448 keypair {PublicKey, SecretScalar} from the supplied scalar. The returned scalar bytes are the supplied bytes; clamping happens inside X448.