2020-09-20 15:17:02 +00:00
|
|
|
use anyhow::Result;
|
2020-05-31 16:20:08 +00:00
|
|
|
use ethers::prelude::*;
|
2020-05-24 16:14:27 +00:00
|
|
|
|
2020-09-20 15:17:02 +00:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<()> {
|
2020-05-24 16:14:27 +00:00
|
|
|
let message = "Some data";
|
2020-10-02 08:41:16 +00:00
|
|
|
let wallet = LocalWallet::new(&mut rand::thread_rng());
|
2020-05-24 16:14:27 +00:00
|
|
|
|
|
|
|
// sign a message
|
2020-09-20 15:17:02 +00:00
|
|
|
let signature = wallet.sign_message(message).await?;
|
2020-05-24 16:14:27 +00:00
|
|
|
println!("Produced signature {}", signature);
|
|
|
|
|
2020-06-17 06:45:15 +00:00
|
|
|
// verify the signature
|
|
|
|
signature.verify(message, wallet.address()).unwrap();
|
2020-05-24 16:14:27 +00:00
|
|
|
|
2020-06-17 06:38:04 +00:00
|
|
|
println!("Verified signature produced by {:?}!", wallet.address());
|
2020-09-20 15:17:02 +00:00
|
|
|
|
|
|
|
Ok(())
|
2020-05-24 16:14:27 +00:00
|
|
|
}
|