Skip to content

Ed25519 signature verification for Solana programs

License

Notifications You must be signed in to change notification settings

zfedoran/brine-ed25519

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Ed25519 signature verification for Solana programs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages