Use the ring or aws-lc-rs crates to generate signatures with sign and verify them with verify, as shown in the sqlx and actix-web source code using rustls.
use ring::signature::{self, Ed25519KeyPair, KeyPair};
fn main() {
let key_pair = Ed25519KeyPair::generate_pkcs8().unwrap();
let message = b"Hello, world!";
let signature = key_pair.sign(message);
let public_key = key_pair.public_key();
let is_valid = public_key.verify(message, &signature).is_ok();
println!("Signature valid: {}", is_valid);
}
Add ring = "0.17" to your Cargo.toml dependencies.