2 releases
0.1.9 | Dec 29, 2021 |
---|---|
0.1.8 | Jun 27, 2021 |
#6 in #zero-net
Used in 2 crates
11KB
158 lines
ZeruCrypt
A rust cryptography interface for ZeroNet/zerunet.
This library is a part of the zerunet project. It has been split from the main project because it could be useful to build programs that have to sign data that ZN clients will consider valid.
Note
Due to bitcoin-rs not having been updated for secp256k1 v0.17.2, the dependency has been replaced with an updated crate in the cratez repository. When the dependencies on the bitcoin crate are resolved this change can be undone.
Benchmarks
Zerucrypt has not been benchmarked yet. If you'd like to help: contact Ansho Rei (anshorei@zeroid.bit) on ZeroMe or ZeroMail!
verify
use zerucrypt::verify;
let data = "Testmessage";
let address = "1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN";
let signature = "G+Hnv6dXxOAmtCj8MwQrOh5m5bV9QrmQi7DSGKiRGm9TWqWP3c5uYxUI/C/c+m9+LtYO26GbVnvuwu7hVPpUdow=";
match verify(data, address, signature) {
Ok(_) => println!("Signature is a valid."),
Err(_) => println!("Signature is invalid."),
}
sign
use zerucrypt::sign;
let data = "Testmessage";
let private_key = "5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss";
match sign(data, private_key) {
Ok(signature) => println!("The signature is {}", signature),
Err(_) => println!("An error occured during the signing process"),
}
create
use zerucrypt::create;
let (priv_key, pub_key) = create();
Dependencies
~9MB
~126K SLoC