A fast, low-overhead, Ed25519 signature verification library for the Solana SVM.
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).
- Verifies Ed25519 signatures within the program, at run-time
- Fully supports dynamically generated messages
- No extra lamports required
Signature verification roughly follows RFC 8032
- 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
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.
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.
This implementation is pulled from code-vm (MIT-licensed), which was written and maintained by the author of this crate.
- ✅ Reviewed as part of the code-vm audit by OtterSec
- ✅ Peer reviewed by @stegaBOB and @deanmlittle
Big thanks to both reviewers for helpful suggestions and CU reductions!
Contributions are welcome! Please open issues or PRs on the GitHub repo.