Skip to content

Commit

Permalink
Add DIP 14 derivation and DIP 9 known derivation Paths. (#39)
Browse files Browse the repository at this point in the history
* small fmt

* added dip14 support

* more work

* more work

* added key type

* chore: clean x11 into feature

* update version

* fixes

* more fixes

* work on derivation

* update of version
  • Loading branch information
QuantumExplorer authored Oct 17, 2024
1 parent 003b1ae commit 6a0ec16
Show file tree
Hide file tree
Showing 15 changed files with 1,291 additions and 66 deletions.
300 changes: 282 additions & 18 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions dash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dashcore"
version = "0.30.0"
version = "0.32.0"
authors = [
"Samuel Westrich <[email protected]>",
"Anton Suprunchuk <[email protected]>",
Expand Down Expand Up @@ -28,6 +28,8 @@ secp-lowmemory = ["secp256k1/lowmemory"]
secp-recovery = ["secp256k1/recovery"]
signer = ["secp-recovery", "rand"]
core-block-hash-use-x11 = ["dashcore_hashes/x11"]
bls = ["bls-signatures"]
eddsa = ["ed25519-dalek"]

# At least one of std, no-std must be enabled.
#
Expand Down Expand Up @@ -58,14 +60,20 @@ hex_lit = "0.1.1"
anyhow = { version= "1.0" }
hex = { version= "0.4" }
bincode = { version= "2.0.0-rc.3", optional = true }
bitflags = "2.6.0"
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", tag = "1.3.3", optional = true }
serde_repr = "0.1.19"
strum = { version = "0.26", features = ["derive"] }
lazy_static = "1.5.0"
ed25519-dalek = { version = "2.1", features = ["rand_core"], optional = true }

[dev-dependencies]
serde_json = "1.0.96"
serde_test = "1.0.19"
serde_derive = "1.0.103"
secp256k1 = { features = [ "recovery", "rand", "hashes" ], version="0.30.0" }
bip39 = "2.0.0"
bincode = "1.3.1"
bincode_test = {package = "bincode", version= "1.3.3" }

[[example]]
name = "bip32"
Expand Down
2 changes: 1 addition & 1 deletion dash/examples/taproot-psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ fn sign_psbt_taproot(
hash_ty: TapSighashType,
secp: &Secp256k1<secp256k1::All>,
) {
let keypair = secp256k1::KeyPair::from_seckey_slice(secp, secret_key.as_ref()).unwrap();
let keypair = secp256k1::Keypair::from_seckey_slice(secp, secret_key.as_ref()).unwrap();
let keypair = match leaf_hash {
None => keypair.tap_tweak(secp, psbt_input.tap_merkle_root).to_inner(),
Some(_) => keypair, // no tweak for script spend
Expand Down
20 changes: 20 additions & 0 deletions dash/src/base58.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ pub enum Error {
/// Hex decoding error
// TODO: Remove this as part of crate-smashing, there should not be any key related errors in this module
Hex(hex::Error),

/// bls signatures related error
#[cfg(feature = "bls-signatures")]
BLSError(String),
/// edwards 25519 related error
#[cfg(feature = "ed25519-dalek")]
Ed25519Dalek(String),

/// A feature is not supported
NotSupported(String),
}

impl fmt::Display for Error {
Expand All @@ -70,6 +80,11 @@ impl fmt::Display for Error {
Error::TooShort(_) => write!(f, "base58ck data not even long enough for a checksum"),
Error::Secp256k1(ref e) => fmt::Display::fmt(&e, f),
Error::Hex(ref e) => write!(f, "Hexadecimal decoding error: {}", e),
#[cfg(feature = "bls-signatures")]
Error::BLSError(ref e) => write!(f, "BLS error: {}", e),
#[cfg(feature = "ed25519-dalek")]
Error::Ed25519Dalek(ref e) => write!(f, "Ed25519-Dalek error: {}", e),
Error::NotSupported(ref e) => write!(f, "Not supported: {}", e),
}
}
}
Expand Down Expand Up @@ -397,6 +412,11 @@ impl From<key::Error> for Error {
key::Error::InvalidKeyPrefix(_) => Error::Secp256k1(secp256k1::Error::InvalidPublicKey),
key::Error::Hex(e) => Error::Hex(e),
key::Error::InvalidHexLength(size) => Error::InvalidLength(size),
#[cfg(feature = "bls-signatures")]
key::Error::BLSError(e) => Error::BLSError(e),
#[cfg(feature = "ed25519-dalek")]
key::Error::Ed25519Dalek(e) => Error::Ed25519Dalek(e),
key::Error::NotSupported(e) => Error::NotSupported(e),
}
}
}
Expand Down
Loading

0 comments on commit 6a0ec16

Please sign in to comment.