forge_signer

Crates.ioforge_signer
lib.rsforge_signer
version0.1.3
sourcesrc
created_at2019-10-12 02:21:20.129496
updated_at2019-10-21 00:20:30.946631
descriptionThe rust language implementation of forge_signer
homepagehttps://github.com/ArcBlock/forge-rust-sdk
repositoryhttps://github.com/ArcBlock/forge-rust-sdk
max_upload_size
id171821
size10,055
Pang Wei (qiangshou007)

documentation

https://docs.rs/forge-rust-sdk

README

Intro

forge_signer implement by Rust.

sign algorithms support ed25519,secp256k1 currently.

trait Signer

    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

    get_key_pair(sign_type: Option<SignType>) -> (Vec<u8>, Vec<u8>)
    get_pk_by_sk(sk: &[u8], sign_type: &Option<SignType>) -> Vec<u8>
    sign(sk: &[u8], message: &[u8], sign_type: Option<SignType>) -> Vec<u8>
    verify(pk: &[u8], message: &[u8], signature: &[u8], sign_type: Option<SignType>) -> bool

Usage

    let ed25519_key_pair = get_key_pair(Some(SignType::Ed25519));
    let expect_pk = get_pk_by_sk(&ed25519_key_pair.0, &Some(SignType::Ed25519));
    assert_eq!(ed25519_key_pair.1, expect_pk);

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

cargo fmt