elabs-crypto

Crates.ioelabs-crypto
lib.rselabs-crypto
version0.1.0
sourcesrc
created_at2022-02-09 18:15:24.584159
updated_at2022-02-09 18:15:24.584159
descriptionElabs crypto package: crypto utilities
homepage
repository
max_upload_size
id529830
size55,095
Core dev (github:pentalabs:core-dev)

documentation

README

Elabs Crypto.

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].

Usage

[dependencies]
elabs-crypto = "0.1"

Example

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);
}
Commit count: 0

cargo fmt