8 releases

0.3.1 Jan 29, 2020
0.3.0 Sep 4, 2019
0.2.5 Mar 7, 2019

#16 in #random-key

Download history 16/week @ 2024-02-05 28/week @ 2024-02-19 19/week @ 2024-02-26 4/week @ 2024-03-04 25/week @ 2024-03-11 5/week @ 2024-03-18 156/week @ 2024-04-01

187 downloads per month
Used in 2 crates

GPL-3.0 license

19KB
360 lines

EthKey

Ethereum keys management supporting keystores in formats used by geth, parity and pyethereum.

Features

  • random key pair generation
  • key serialization/deserialization
  • keystore password change
  • signing and verification

Usage

Add this to your Cargo.toml:

[dependencies]
ethkey = "0.3"

Example

(Rust edition 2018)

use ethkey::prelude::*;

fn main() {
    let key = EthAccount::load_or_generate("/tmp/path/to/keystore", "passwd")
        .expect("should load or generate new eth key");

    println!("{:?}", key.address());

    let message = [7_u8; 32];

    // sign the message
    let signature = key.sign(&message).unwrap();

    // verify the signature
    let result = key.verify(&signature, &message).unwrap();
    println!("{}", if result {"verification ok"} else {"wrong signature"});
}

lib.rs:

Ethereum keys management supporting keystores in formats used by geth (soon), parity and pyethereum.

Features

  • random key pair generation
  • key serialization/deserialization
  • keystore password change
  • signing and verification

Usage

[dependencies]
ethkey = "0.3"

Example

use ethkey::prelude::*;

fn main() {
    let key = EthAccount::load_or_generate("/tmp/path/to/keystore", "passwd")
        .expect("should load or generate new eth key");

    println!("{:?}", key.address());

    let message = [7_u8; 32];

    // sign the message
    let signature = key.sign(&message).unwrap();

    // verify the signature
    let result = key.verify(&signature, &message).unwrap();
    println!("{}", if result {"verification ok"} else {"wrong signature"});
}

A "prelude" for users of the ethkey crate.

use ethkey::prelude::*;

The prelude may grow over time.

Dependencies

~14MB
~345K SLoC