Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(coinjoin): bump bls to dashpay bls 1.3.2 and rust 1.80.x adjustments #96

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 120 additions & 92 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion DashSharedCore.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'DashSharedCore'
s.version = '0.4.16'
s.version = '0.4.17'
s.summary = 'Dash Core SPV written in Rust'
s.author = 'Dash'
s.description = "C-bindings for Dash Core SPV that can be used in projects for Apple platform"
Expand Down
4 changes: 2 additions & 2 deletions dash-spv-apple-bindings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dash_spv_apple_bindings"
version = "0.4.16"
version = "0.4.17"
description = "C-bindings for using and interoperating with Dash SPV"
readme = "README.md"
edition = "2021"
Expand All @@ -13,7 +13,7 @@ tracing = "0.1.40"

[dependencies.dash-spv-masternode-processor]
path = "../dash-spv-masternode-processor"
features = ["default", "generate-dashj-tests"]
features = ["default", "generate-dashj-tests", "use_serde"]

[dependencies.dash-spv-coinjoin]
path = "../dash-spv-coinjoin"
Expand Down
15 changes: 9 additions & 6 deletions dash-spv-apple-bindings/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -ex

echo "Building Dash Shared Core..."
pwd

Expand All @@ -24,7 +26,8 @@ compare_version() {
fi
return 1
}
REQUIRED_VERSION=1.66.0
#REQUIRED_VERSION=1.66.0
REQUIRED_VERSION=1.80.1
CURRENT_VERSION=$(rustc -V | awk '{sub(/-.*/,"");print $2}')
echo "rustc -V: current ${CURRENT_VERSION} vs. required ${REQUIRED_VERSION}"
if compare_version "${REQUIRED_VERSION}" "${CURRENT_VERSION}"; then
Expand All @@ -34,11 +37,11 @@ fi

cargo install cargo-lipo

rm -r DashSharedCore/include
rm -r DashSharedCore/lib/macos
rm -r DashSharedCore/framework
rm -r DashSharedCore/lib/ios
rm -r DashSharedCore/lib/ios-simulator
rm -rf DashSharedCore/include
rm -rf DashSharedCore/lib/macos
rm -rf DashSharedCore/framework
rm -rf DashSharedCore/lib/ios
rm -rf DashSharedCore/lib/ios-simulator

rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
Expand Down
2 changes: 1 addition & 1 deletion dash-spv-coinjoin/src/fermented.rs

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions dash-spv-masternode-processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rand = ["secp256k1/rand-std"]
secp-lowmemory = ["secp256k1/lowmemory"]
secp-recovery = ["secp256k1/recovery"]
generate-dashj-tests = []
use_serde = ["serde"]
# At least one of std, no-std must be enabled.
#
# The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default.
Expand All @@ -28,19 +29,20 @@ bip38 = { git = "https://github.com/pankcuf/bip38", rev = "87abd21" }
bitcoin_hashes = { version = "0.11.0", default-features = false }
bitcoinconsensus = { version = "0.19.0-3", optional = true }
blake3 = "1.3.2"
bls-signatures = { git = "https://github.com/dashevo/bls-signatures", rev = "a5589e6", features = ["legacy", "bip32", "apple"] }
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "3ffa7fa2b62aecf3943c142508de4b7ec6005bb5", features = ["legacy", "bip32", "apple", "use_serde" ] }
byte = "0.2"
core2 = { version = "0.4.0", optional = true, default-features = false }
dirs-next = "2.0.0"
ed25519-dalek = "2.0.0-rc.3"
libc = "0.2.132"
libc = "0.2.158"
logging = { path = "../logging" }
rs-x11-hash = "0.1.8"
secp256k1 = { version = "0.26.0", features = [ "recovery", "rand-std", "bitcoin_hashes" ] }
serde = { version = "1.0.144", features = ["derive"] }
serde = { version = "1.0.209", features = ["derive"], optional = true }
serde_json = "1.0.85"
tracing = "0.1.40"
zeroize = "1.5.7"
bincode = "2.0.0-rc.3"

[dev-dependencies]
base64 = "0.21.0"
Expand Down
2 changes: 2 additions & 0 deletions dash-spv-masternode-processor/src/bindings/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use crate::processing::keys_cache::KeysCache;
use crate::types::opaque_key::{AsCStringPtr, AsOpaqueKey, OpaqueKey, KeyWithUniqueId, OpaqueKeys, OpaqueSerializedKeys};
use crate::util::address::address;
use crate::util::sec_vec::SecVec;
#[cfg(feature = "use_serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

/// Destroys
/// # Safety
Expand Down
2 changes: 0 additions & 2 deletions dash-spv-masternode-processor/src/blockdata/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#[cfg(feature = "serde")] use serde;

#[cfg(feature = "serde")] use prelude::*;

use core::{fmt, convert::From};

// Note: I am deliberately not implementing PartialOrd or Ord on the
Expand Down
18 changes: 9 additions & 9 deletions dash-spv-masternode-processor/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,16 +586,16 @@ macro_rules! user_enum {

#[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> $crate::serde::Deserialize<'de> for $name {
impl<'de> ::serde::Deserialize<'de> for $name {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: $crate::serde::Deserializer<'de>,
D: ::serde::Deserializer<'de>,
{
use ::core::fmt::{self, Formatter};

struct Visitor;
impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
impl<'de> ::serde::de::Visitor<'de> for Visitor {
type Value = $name;

fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
Expand All @@ -604,7 +604,7 @@ macro_rules! user_enum {

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
E: ::serde::de::Error,
{
static FIELDS: &'static [&'static str] = &[$(stringify!($txt)),*];

Expand All @@ -616,14 +616,14 @@ macro_rules! user_enum {

fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
E: ::serde::de::Error,
{
self.visit_str(v)
}

fn visit_string<E>(self, v: $crate::prelude::String) -> Result<Self::Value, E>
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
where
E: $crate::serde::de::Error,
E: ::serde::de::Error,
{
self.visit_str(&v)
}
Expand All @@ -636,10 +636,10 @@ macro_rules! user_enum {

#[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl $crate::serde::Serialize for $name {
impl ::serde::Serialize for $name {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: $crate::serde::Serializer,
S: ::serde::Serializer,
{
serializer.collect_str(&self)
}
Expand Down
12 changes: 7 additions & 5 deletions dash-spv-masternode-processor/src/keys/bls_key.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use bls_signatures::bip32::{ChainCode, ExtendedPrivateKey, ExtendedPublicKey};
use bls_signatures::{BasicSchemeMPL, BlsError, G1Element, G2Element, LegacySchemeMPL, PrivateKey, Scheme};
use hashes::{Hash, hex::FromHex, sha256, sha256d, hex};
use hashes::hex::ToHex;
use hashes::{Hash, hex::FromHex, sha256, sha256d};
use crate::chain::{derivation::IIndexPath, ScriptMap};
use crate::consensus::Encodable;
use crate::crypto::{UInt256, UInt384, UInt768, byte_util::{AsBytes, BytesDecodable, Zeroable}, UInt160};
use crate::keys::{IKey, KeyKind, dip14::{IChildKeyDerivation, SignKey}};
use crate::keys::crypto_data::{CryptoData, DHKey};
use crate::models::OperatorPublicKey;
use crate::util::{base58, data_ops::hex_with_data, sec_vec::SecVec};
#[cfg(feature = "use_serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[derive(Clone, Debug, Default)]
pub struct BLSKey {
Expand Down Expand Up @@ -178,7 +180,7 @@ impl BLSKey {
pub fn key_with_seed_data(seed: &[u8], use_legacy: bool) -> Self {
let bls_private_key = PrivateKey::from_bip32_seed(seed);
let bls_public_key = bls_private_key.g1_element().unwrap();
let seckey = UInt256::from(&*bls_private_key.serialize());
let seckey = UInt256::from(&*bls_private_key.to_bytes());
let pubkey = UInt384(g1_element_serialized(&bls_public_key, use_legacy));
Self { seckey, pubkey, use_legacy, ..Default::default() }
}
Expand Down Expand Up @@ -572,7 +574,7 @@ fn g1_element_from_bytes(use_legacy: bool, bytes: &[u8]) -> Result<G1Element, Bl
}
}

fn g1_element_serialized(public_key: &G1Element, use_legacy: bool) -> [u8; 48] {
pub(crate) fn g1_element_serialized(public_key: &G1Element, use_legacy: bool) -> [u8; 48] {
*if use_legacy {
public_key.serialize_legacy()
} else {
Expand Down Expand Up @@ -619,7 +621,7 @@ impl From<ChainCode> for UInt256 {

impl From<PrivateKey> for UInt256 {
fn from(value: PrivateKey) -> Self {
UInt256::from(value.serialize().as_slice())
UInt256::from(value.to_bytes().as_slice())
}
}

Expand All @@ -633,4 +635,4 @@ impl From<&ExtendedPrivateKey> for SecVec {
fn from(value: &ExtendedPrivateKey) -> Self {
SecVec::with_vec(value.serialize().to_vec())
}
}
}
2 changes: 2 additions & 0 deletions dash-spv-masternode-processor/src/keys/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use crate::crypto::{UInt256, UInt384, UInt768};
use crate::keys::{BLSKey, ECDSAKey, ED25519Key, IKey};
use crate::types::opaque_key::{AsOpaqueKey, OpaqueKey};
use crate::util::sec_vec::SecVec;
#[cfg(feature = "use_serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
Expand Down
2 changes: 2 additions & 0 deletions dash-spv-masternode-processor/src/tests/bindings/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use crate::crypto::{UInt256, UInt384};
use crate::ffi::IndexPathData;
use crate::keys::KeyKind;
use crate::types::opaque_key::OpaqueKey;
#[cfg(feature = "use_serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[test]
fn test_keys() {
Expand Down
10 changes: 4 additions & 6 deletions dash-spv-masternode-processor/src/tests/keys/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ fn test_bls_multiplication() {
#[test]
fn test_bls_from_bip32_short_seed() {
let private_key = PrivateKey::from_bip32_seed(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
println!("{:?}", &*private_key.serialize());
println!("{:?}", &*private_key.serialize().as_slice());
println!("{:?}", &*private_key.to_bytes().as_slice());
assert_eq!(
private_key.serialize().as_slice(),
private_key.to_bytes().as_slice(),
Vec::from_hex("46891c2cec49593c81921e473db7480029e0fc1eb933c6b93d81f5370eb19fbd").unwrap().as_slice(),
"----");
}
Expand All @@ -77,10 +76,9 @@ fn test_bls_from_bip32_long_seed() {
// let seed = [50, 67, 148, 112, 207, 6, 210, 118, 137, 125, 27, 144, 105, 189, 214, 228, 68, 83, 144, 205, 80, 105, 133, 222, 14, 26, 28, 136, 167, 111, 241, 118];
// let secret =
let private_key = PrivateKey::from_bip32_seed(&seed);
println!("{:?}", &*private_key.serialize());
println!("{:?}", &*private_key.serialize().as_slice());
println!("{:?}", &*private_key.to_bytes().as_slice());
assert_eq!(
private_key.serialize().as_slice(),
private_key.to_bytes().as_slice(),
private_key_test_data.as_slice(),
"----");
}
Expand Down
2 changes: 1 addition & 1 deletion reachability/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libc = "0.2.139"
libc = "0.2.158"
logging = { path = "../logging" }
tracing = "0.1.40"
system-configuration = "0.5.0"
Expand Down