Crates.io | elabs-crypto |
lib.rs | elabs-crypto |
version | 0.1.0 |
source | src |
created_at | 2022-02-09 18:15:24.584159 |
updated_at | 2022-02-09 18:15:24.584159 |
description | Elabs crypto package: crypto utilities |
homepage | |
repository | |
max_upload_size | |
id | 529830 |
size | 55,095 |
This crate provides a set of cryptographic helper functions.
It provide secp256k1
PublicKey, PrivateKey, signer, and hash
functions.
This crate is based on [secp256k1
] and [tiny-keccak
].
[dependencies]
elabs-crypto = "0.1"
use elabs_crypto::*;
fn main() {
let msg = b"hello world";
let hash = keccak256(msg);
let sk = PrivateKey::random();
let pk = sk.to_public().unwrap();
let sig = sign(msg, sk).unwrap();
let (recid, bsig) = sig.serialize_compact();
let pk2 = ecrecover(&hash, &bsig, recid.to_i32() as u8).unwrap();
assert_eq!(pk, pk2);
}