Skip to content

Commit

Permalink
refactor: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ethicnology committed Nov 20, 2024
1 parent d820f10 commit e9194c7
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "bip85_fork"
name = "bip85_extended"
version = "0.1.1"
authors = [
"Rita Kitic <rikitau@protonmail.com>",
"Azad EMERY <ethicnology@pm.me>",
"Jules Azad EMERY <ethicnology@pm.me>",
]
description = "BIP-85 - deterministic entropy from bip32 keychains"
repository = "https://github.com/ethicnology/rust-bip85"
Expand Down
2 changes: 1 addition & 1 deletion bindings/dart-bip85/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"
crate-type = ["cdylib", "staticlib"]

[dependencies]
bip85_fork = { path = "../../../" }
bip85_extended = { path = "../../../" }
flutter_rust_bridge = "=2.6.0"
hex = "0.4.3"
14 changes: 7 additions & 7 deletions bindings/dart-bip85/rust/src/api/bip85.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
use std::str::FromStr;

use bip85_fork::bitcoin::bip32::{DerivationPath, Xpriv};
use bip85_fork::bitcoin::secp256k1::Secp256k1;
use bip85_extended::bitcoin::bip32::{DerivationPath, Xpriv};
use bip85_extended::bitcoin::secp256k1::Secp256k1;

#[flutter_rust_bridge::frb(sync)]
pub fn derive(xprv: String, path: String) -> Vec<u8> {
let root = Xpriv::from_str(&xprv).unwrap();
let derivation_path = DerivationPath::from_str(&path).unwrap();
let derived = bip85_fork::derive(&Secp256k1::new(), &root, &derivation_path).unwrap();
let derived = bip85_extended::derive(&Secp256k1::new(), &root, &derivation_path).unwrap();
return derived;
}

#[flutter_rust_bridge::frb(sync)]
pub fn to_wif(xprv: String, index: u32) -> String {
let root = Xpriv::from_str(&xprv).unwrap();
let derived = bip85_fork::to_wif(&Secp256k1::new(), &root, index).unwrap();
let derived = bip85_extended::to_wif(&Secp256k1::new(), &root, index).unwrap();
return derived.to_string();
}

#[flutter_rust_bridge::frb(sync)]
pub fn to_xprv(xprv: String, index: u32) -> String {
let root = Xpriv::from_str(&xprv).unwrap();
let derived = bip85_fork::to_xprv(&Secp256k1::new(), &root, index).unwrap();
let derived = bip85_extended::to_xprv(&Secp256k1::new(), &root, index).unwrap();
return derived.to_string();
}

#[flutter_rust_bridge::frb(sync)]
pub fn to_hex(xprv: String, length: u32, index: u32) -> String {
let root = Xpriv::from_str(&xprv).unwrap();
let derived = bip85_fork::to_hex(&Secp256k1::new(), &root, length, index).unwrap();
let derived = bip85_extended::to_hex(&Secp256k1::new(), &root, length, index).unwrap();
return derived;
}

#[flutter_rust_bridge::frb(sync)]
pub fn to_mnemonic(xprv: String, word_count: u32, index: u32) -> String {
let root = Xpriv::from_str(&xprv).unwrap();
let derived = bip85_fork::to_mnemonic(&Secp256k1::new(), &root, word_count, index).unwrap();
let derived = bip85_extended::to_mnemonic(&Secp256k1::new(), &root, word_count, index).unwrap();
return derived.to_string();
}
6 changes: 3 additions & 3 deletions examples/drng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ use bitcoin::{
};
use std::str::FromStr;

use bip85_fork::*;
use bip85_extended::*;

fn main() {
let xprv = Xpriv::from_str("xprv9s21ZrQH143K2LBWUUQRFXhucrQqBpKdRRxNVq2zBqsx8HVqFk2uYo8kmbaLLHRdqtQpUm98uKfu3vca1LqdGhUtyoFnCNkfmXRyPXLjbKb").unwrap();
let path = DerivationPath::from_str("m/0'/0'").unwrap();
let derived = bip85_fork::derive(&Secp256k1::new(), &xprv, &path).unwrap();
let derived = bip85_extended::derive(&Secp256k1::new(), &xprv, &path).unwrap();
let entropy: [u8; 64] = derived.try_into().unwrap();
println!("Entropy: {}", entropy.clone().to_lower_hex_string());

let mut drng_reader = bip85_fork::DRNG::new(entropy);
let mut drng_reader = bip85_extended::DRNG::new(entropy);
let mut drng_80_bytes = [0u8; 80];
drng_reader.read(&mut drng_80_bytes);
println!("DRNG: {}", drng_80_bytes.to_lower_hex_string());
Expand Down
8 changes: 4 additions & 4 deletions examples/mnemonic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate bip85_fork;
extern crate bip85_extended;

use std::str::FromStr;

Expand All @@ -14,12 +14,12 @@ fn main() {
.unwrap();
let secp = Secp256k1::new();

let mnemonic = bip85_fork::to_mnemonic(&secp, &root, 12, 0).unwrap();
let mnemonic = bip85_extended::to_mnemonic(&secp, &root, 12, 0).unwrap();
println!("12-word mnemonic:\n{}", mnemonic);

let mnemonic = bip85_fork::to_mnemonic(&secp, &root, 24, 0).unwrap();
let mnemonic = bip85_extended::to_mnemonic(&secp, &root, 24, 0).unwrap();
println!("24-word mnemonic:\n{}", mnemonic);

let mnemonic = bip85_fork::to_mnemonic_in(&secp, &root, Language::Japanese, 18, 0).unwrap();
let mnemonic = bip85_extended::to_mnemonic_in(&secp, &root, Language::Japanese, 18, 0).unwrap();
println!("18-word mnemonic in Japanese:\n{}", mnemonic);
}
8 changes: 4 additions & 4 deletions examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate bip85_fork;
extern crate bip85_extended;

use std::str::FromStr;

Expand All @@ -13,12 +13,12 @@ fn main() {
.unwrap();
let secp = Secp256k1::new();

let derived = bip85_fork::to_wif(&secp, &root, 0).unwrap();
let derived = bip85_extended::to_wif(&secp, &root, 0).unwrap();
println!("WIF key:\n{}", derived);

let data = bip85_fork::to_hex(&secp, &root, 35, 0).unwrap();
let data = bip85_extended::to_hex(&secp, &root, 35, 0).unwrap();
println!("35 bytes of hex entropy:\n{:x?}", data);

let xprv = bip85_fork::to_xprv(&secp, &root, 0).unwrap();
let xprv = bip85_extended::to_xprv(&secp, &root, 0).unwrap();
println!("Derived extended private key:\n{}", xprv);
}
2 changes: 1 addition & 1 deletion src/drng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use sha3::{
///
/// ### Example
/// ```rust
/// use bip85_fork::*;
/// use bip85_extended::*;
/// use std::str::FromStr;
/// use bitcoin::{
/// bip32::{DerivationPath, Xpriv},
Expand Down
2 changes: 1 addition & 1 deletion src/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use bitcoin::{bip32::Xpriv, key::Secp256k1, secp256k1};
///
/// ### Example
/// ```rust
/// use bip85_fork::*;
/// use bip85_extended::*;
/// use bitcoin::{bip32::Xpriv, key::Secp256k1};
/// use std::str::FromStr;
///
Expand Down
2 changes: 1 addition & 1 deletion src/mnemonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn to_mnemonic_in<C: secp256k1::Signing>(
///
/// ### Example
/// ```rust
/// use bip85_fork::*;
/// use bip85_extended::*;
/// use std::str::FromStr;
/// use bitcoin::{
/// bip32::Xpriv,
Expand Down
2 changes: 1 addition & 1 deletion src/pwd_base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use bitcoin::{bip32::Xpriv, key::Secp256k1, secp256k1};
///
/// ### Example
/// ```rust
/// use bip85_fork::*;
/// use bip85_extended::*;
/// use bitcoin::{bip32::Xpriv, key::Secp256k1};
/// use std::str::FromStr;
///
Expand Down
2 changes: 1 addition & 1 deletion src/pwd_base85.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bitcoin::{bip32::Xpriv, key::Secp256k1, secp256k1};
///
/// ### Example
/// ```rust
/// use bip85_fork::*;
/// use bip85_extended::*;
/// use bitcoin::{bip32::Xpriv, key::Secp256k1};
/// use std::str::FromStr;
///
Expand Down
2 changes: 1 addition & 1 deletion src/wif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bitcoin::{bip32::Xpriv, key::Secp256k1, secp256k1};
///
/// ### Example
/// ```rust
/// use bip85_fork::*;
/// use bip85_extended::*;
/// use bitcoin::{bip32::Xpriv, key::Secp256k1};
/// use std::str::FromStr;
///
Expand Down
2 changes: 1 addition & 1 deletion src/xprv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::Error;
///
/// ### Example
/// ```rust
/// use bip85_fork::*;
/// use bip85_extended::*;
/// use bitcoin::{bip32::Xpriv, key::Secp256k1};
/// use std::str::FromStr;
///
Expand Down
4 changes: 2 additions & 2 deletions tests/bip85_tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use ::bip85_fork::error::Error;
use ::bip85_extended::error::Error;

#[cfg(feature = "mnemonic")]
use bip39::Mnemonic;
use bip85_fork::*;
use bip85_extended::*;
use bitcoin::bip32::DerivationPath;
use bitcoin::bip32::Xpriv;
use bitcoin::secp256k1::Secp256k1;
Expand Down
4 changes: 2 additions & 2 deletions tests/drng_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

use bip85_fork::drng::DRNG;
use bip85_extended::drng::DRNG;
use bitcoin::{
bip32::{DerivationPath, Xpriv},
hex::DisplayHex,
Expand All @@ -15,7 +15,7 @@ fn test_drng_80() {
)
.unwrap();
let path = DerivationPath::from_str("m/0'/0'").unwrap();
let entropy = bip85_fork::derive(&Secp256k1::new(), &root, &path).unwrap();
let entropy = bip85_extended::derive(&Secp256k1::new(), &root, &path).unwrap();

let entropy_hex = entropy.to_lower_hex_string();
let expected = "efecfbccffea313214232d29e71563d941229afb4338c21f9517c41aaa0d16f00b83d2a09ef747e7a64e8e2bd5a14869e693da66ce94ac2da570ab7ee48618f7";
Expand Down
2 changes: 1 addition & 1 deletion tests/pwd_base64_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn test_pwd_base64() {
)
.unwrap();

let pwd_base64 = bip85_fork::to_pwd_base64(&Secp256k1::new(), &root, 21, 0).unwrap();
let pwd_base64 = bip85_extended::to_pwd_base64(&Secp256k1::new(), &root, 21, 0).unwrap();
let expected = "dKLoepugzdVJvdL56ogNV";
assert_eq!(expected, pwd_base64);
}
2 changes: 1 addition & 1 deletion tests/pwd_base85_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bip85_fork::*;
use bip85_extended::*;
use bitcoin::{bip32::Xpriv, key::Secp256k1};
use std::str::FromStr;

Expand Down

0 comments on commit e9194c7

Please sign in to comment.