Expand description
§Ed25519 signing helpers
This module implements libsodium’s Ed25519 helper functions, including Ed25519 to Curve25519 conversion and secret-key extraction. You can use the conversion functions when you want to sign messages with the same keys used to encrypt messages (i.e., using a public-key box).
Generally speaking, you should avoid signing and encrypting with the same keypair. Additionally, an encrypted box doesn’t need to be separately signed as it already includes a message authentication code.
§Classic API example
use dryoc::classic::crypto_sign::{
crypto_sign_ed25519_sk_to_pk, crypto_sign_ed25519_sk_to_seed, crypto_sign_seed_keypair,
};
use dryoc::constants::{CRYPTO_SIGN_PUBLICKEYBYTES, CRYPTO_SIGN_SEEDBYTES};
let seed = [7u8; CRYPTO_SIGN_SEEDBYTES];
let (public_key, secret_key) = crypto_sign_seed_keypair(&seed);
let mut extracted_seed = [0u8; CRYPTO_SIGN_SEEDBYTES];
let mut extracted_public_key = [0u8; CRYPTO_SIGN_PUBLICKEYBYTES];
crypto_sign_ed25519_sk_to_seed(&mut extracted_seed, &secret_key);
crypto_sign_ed25519_sk_to_pk(&mut extracted_public_key, &secret_key);
assert_eq!(extracted_seed, seed);
assert_eq!(extracted_public_key, public_key);Functions§
- crypto_
sign_ ed25519_ pk_ to_ curve25519 - Converts an Ed25519 public key
ed25519_public_keyinto an X25519 public key, placing the result intox25519_public_keyupon success. - crypto_
sign_ ed25519_ sk_ to_ curve25519 - Converts an Ed25519 secret key
ed25519_secret_keyinto an X25519 secret key, placing the result intox25519_secret_key. - crypto_
sign_ ed25519_ sk_ to_ pk - Extracts the Ed25519 public key from
secret_key, placing the result intopublic_key. - crypto_
sign_ ed25519_ sk_ to_ seed - Extracts the Ed25519 seed from
secret_key, placing the result intoseed.