Skip to main content

Sign Ed25519

Ed25519 is a widely adopted digital signature algorithm known for its strong security and efficiency. Signing with Ed25519 ensures data integrityAssurance that the data stored in the ledger has not been tampered with or altered in any unauthorized way., authenticity, and non-repudiation. When signing with Ed25519, a private key generates a digital signature that can be verified with the corresponding public key. This process guarantees that the data has not been tampered with and originated from the private key's holder.

Example Code

  1. Create a StrongholdSecretManager with the STRONGHOLD_PASSWORD and MNEMONIC variables in your .env file.
sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs
loading...
  1. Use the SecretManager to sign the FOUNDRY_METADATA message as bytes using the StrongholdAdapter.sign_ed25519() function.
sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs
loading...
  1. Hash the public key to get the address using the hex_public_key_to_bech32_address() function.
sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs
loading...

Full Example Code

sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs
loading...

Expected Output

Public key: 0x67b7fc3f78763c9394fc4fcdb52cf3a973b6e064bdc3defb40a6cb2c880e6f5c
Signature: 0x5437ee671f182507103c6ae2f6649083475019f2cc372e674be164577dd123edd7a76291ba88732bbe1fae39688b50a3678bce05c9ef32c9494b3968f4f07a01
Address: rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy