Intro

forge_signer implement by Rust.

sign algorithms support ed25519,secp256k1 currently.

trait Signer

rust trait Signer { fn get_key_pair() -> Self; fn get_public_key(sk: &[u8]) -> Vec<u8>; fn sign(sk: &[u8], message: &[u8]) -> Vec<u8>; fn verify(pk: &[u8], message: &[u8], signature: &[u8]) -> bool; }

API

rust get_key_pair(sign_type: Option<SignType>) -> (Vec<u8>, Vec<u8>)

rust get_pk_by_sk(sk: &[u8], sign_type: &Option<SignType>) -> Vec<u8>

rust sign(sk: &[u8], message: &[u8], sign_type: Option<SignType>) -> Vec<u8>

rust verify(pk: &[u8], message: &[u8], signature: &[u8], sign_type: Option<SignType>) -> bool

Usage

```rust let ed25519keypair = getkeypair(Some(SignType::Ed25519)); let expectpk = getpkbysk(&ed25519keypair.0, &Some(SignType::Ed25519)); asserteq!(ed25519keypair.1, expectpk);

let message = b"hello rust";
let signature = sign(&ed25519_key_pair.0, message, Some(SignType::Ed25519));
assert!(verify(&ed25519_key_pair.1, message, &signature, Some(SignType::Ed25519)));

```