near-seed-phrase

Crates.ionear-seed-phrase
lib.rsnear-seed-phrase
version0.3.3
sourcesrc
created_at2023-08-13 05:01:24.559808
updated_at2023-11-24 10:50:54.228409
descriptionConvert NEAR seed phrase to secret key
homepage
repository
max_upload_size
id943140
size14,577
coffee (hanakannzashi)

documentation

README

NEAR Seed Phrase

Similar to near-seed-phrase but in Rust version

Install

[dependencies]
near-seed-phrase = "*"

Usage

Basic

use near_seed_phrase::{derive_key, NearDerivationPath, NearSeedPhrase};
fn example() {
    let phrase = NearSeedPhrase::generate(12).unwrap();
    let secret_key = derive_key(&phrase, "", &NearDerivationPath::default()).unwrap();
    println!("{}", secret_key);
    println!("{}", secret_key.to_public_key());
}

Macro

use near_seed_phrase::{derive_key, ToEncodedKey};
fn example() {
    let phrase = "fortune conduct light unusual gloom process wrap spare season exact anchor devote";
    let secret_key = derive_key!(phrase);
    
    assert_eq!(
        secret_key.to_encoded_key(),
        "ed25519:G94YBVktAVUFZWvYBtYmfpvVMNCtSf2x73bMfTCM9CfzyrUyN5X6VpTqr8QTCHYBTdUfzufDsTy3cR9CfNf74Bv"
    );
    assert_eq!(
        secret_key.to_public_key().to_encoded_key(),
        "ed25519:2PQENDq3KABdr7cw1TH5B4AdXLqcyNXTTpWbdZh7k828"
    );
}
Commit count: 0

cargo fmt