#solana #ed25519 #curve25519

no-std brine-ed25519

Ed25519 signature verification for Solana SVM programs using curve25519 syscalls

2 releases

new 0.1.1 Apr 12, 2025
0.1.0 Apr 10, 2025

#4 in Magic Beans

Download history 89/week @ 2025-04-05

89 downloads per month

MIT license

15KB
190 lines

brine-ed25519

license crates.io

image

A fast, low-overhead, Ed25519 signature verification library for the Solana SVM.


⚡ Performance

Operation CU (Approx.)
sig_verify ~30,000

These value was measured inside the Solana SVM (via test programs), it depends on the size of the data (32 bytes in this case).


✨ Features

  • Verifies Ed25519 signatures within the program, at run-time
  • Fully supports dynamically generated messages
  • No extra lamports required

Signature verification roughly follows RFC 8032


🧱 Use Cases

  • Signed content or metadata validation
  • Meta-transactions & gasless relays
  • Custom auth with off-chain signatures
  • Cross-chain validator proof verification
  • Oracle data integrity checks
  • Decentralized identity & DID claims

🚀 Quick Start

use brine_ed25519::sig_verify;

let pubkey: [u8; 32] = [...];
let sig: [u8; 64] = [...];
let message = b"hello world";

sig_verify(&pubkey, &sig, message)?;

Returns Ok(()) if valid, or Err(SignatureError) if the signature is invalid.


🧠 But why?

Q: Why not use the native Ed25519 program?

A: Solana does provide a Ed25519 pre-compile program for signature verification—but it comes with several downsides:

  • Charges an extra 5000 lamports per signature
  • Requires the instruction_sysvar to be passed into your program
  • Only verifies signatures on data hardcoded into the transaction
  • Cannot be used with dynamically generated data inside your program
  • Has cumbersome devex

This crate, brine-ed25519, solves all of that.


🔐 Security

This implementation is pulled from code-vm (MIT-licensed), which was written and maintained by the author of this crate.

Big thanks to both reviewers for helpful suggestions and CU reductions!


🙌 Contributing

Contributions are welcome! Please open issues or PRs on the GitHub repo.

Dependencies

~2.3–3.5MB
~79K SLoC