Skip to content

Commit

Permalink
A few issues remaining
Browse files Browse the repository at this point in the history
- secp256k1_zkp is missing BlockstreamResearch/rust-secp256k1-zkp#48
- bitcoin_hashes is missing rust-bitcoin/bitcoin_hashes@f1084bf
  • Loading branch information
justinmoon committed May 7, 2022
1 parent 12bd6a5 commit 51b3450
Show file tree
Hide file tree
Showing 20 changed files with 516 additions and 554 deletions.
914 changes: 440 additions & 474 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ members = [
]

[patch.crates-io]
bitcoin_hashes = { version = "0.10.0", git = 'https://github.com/fedimint/bitcoin_hashes', branch = 'minimint' }
secp256k1 = { git = "https://github.com/fedimint/rust-secp256k1/", branch = "minimint" }
# bitcoin_hashes = { git = 'https://github.com/rust-bitcoin/bitcoin_hashes', branch = 'master' }
bitcoin_hashes = { version = "0.10.0", git = 'https://github.com/rust-bitcoin/bitcoin_hashes', rev = 'b27002339186a836edb06a6cff8e5c133a2d5f5f' }
# bitcoin_hashes = { path = '../../code/bitcoin_hashes' }
2 changes: 1 addition & 1 deletion ln-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ minimint = { path = "../minimint" }
minimint-api = { path = "../minimint-api" }
mint-client = { path = "../mint-client" }
rand = "0.6"
secp256k1 = "0.20"
secp256k1 = "0.22"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.61"
sled = "0.34.6"
Expand Down
4 changes: 2 additions & 2 deletions minimint-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ edition = "2018"

[dependencies]
async-trait = "0.1"
bitcoin = { version = "0.27.0", features = [ "rand", "serde" ] }
bitcoin = { version = "0.28.0", features = [ "rand", "serde" ] }
bitcoin_hashes = { version = "0.10", features = ["serde"] }
hex = "0.4.3"
http-types = "2.12.0"
minimint-derive = { path = "../minimint-derive" }
rand = "0.6.0"
secp256k1-zkp = { git = "https://github.com/elsirion/rust-secp256k1-zkp", branch = "minimint", features = [ "use-serde", "bitcoin_hashes", "global-context" ] }
secp256k1-zkp = { version = "0.6", features = [ "use-serde", "bitcoin_hashes", "global-context" ] }
serde = { version = "1.0.118", features = [ "derive" ] }
serde_json = "1.0.79"
sled = "0.34"
Expand Down
4 changes: 2 additions & 2 deletions minimint-api/src/encoding/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Decodable for secp256k1_zkp::schnorrsig::Signature {

impl Encodable for secp256k1_zkp::schnorrsig::KeyPair {
fn consensus_encode<W: Write>(&self, writer: W) -> Result<usize, Error> {
self.serialize_secret().consensus_encode(writer)
self.secret_bytes().consensus_encode(writer)
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ mod tests {
let ctx = secp256k1_zkp::global::SECP256K1;
let mut rng = rand::rngs::OsRng::new().unwrap();
let sec_key = secp256k1_zkp::schnorrsig::KeyPair::new(&ctx, &mut rng);
let pub_key = secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&ctx, &sec_key);
let pub_key = secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&sec_key);
test_roundtrip(pub_key);

let sig = ctx.schnorrsig_sign(
Expand Down
2 changes: 1 addition & 1 deletion minimint-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate self as minimint_api;

use bitcoin_hashes::sha256::Hash as Sha256;
pub use bitcoin_hashes::Hash as BitcoinHash;
use bitcoin_hashes::{borrow_slice_impl, hash_newtype, hex_fmt_impl, index_impl, serde_impl};
use bitcoin_hashes::{borrow_slice_impl, hash_newtype, hex_fmt_impl, serde_impl};
pub use module::{FederationModule, InputMeta};
use serde::{Deserialize, Serialize};
use std::io::Error;
Expand Down
4 changes: 2 additions & 2 deletions minimint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
async-trait = "0.1.42"
bincode = "1.3.1"
bitcoin = "0.27.0"
bitcoin = "0.28.0"
futures = "0.3.9"
hbbft = { git = "https://github.com/fedimint/hbbft", branch = "minimint" }
hex = "0.4.2"
Expand All @@ -21,7 +21,7 @@ minimint-mint = { path = "../modules/minimint-mint" }
minimint-wallet = { path = "../modules/minimint-wallet" }
rand = "0.6.5"
rayon = "1.5.0"
secp256k1-zkp = { git = "https://github.com/elsirion/rust-secp256k1-zkp", branch = "minimint", features = [ "global-context", "bitcoin_hashes" ] }
secp256k1-zkp = { version = "0.6", features = [ "global-context", "bitcoin_hashes" ] }
serde = { version = "1.0.118", features = [ "derive" ] }
serde_json = "1.0.61"
sha3 = "0.9.1"
Expand Down
2 changes: 1 addition & 1 deletion minimint/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ where
let msg = msg.into();
let pub_keys = keys
.iter()
.map(|key| schnorrsig::PublicKey::from_keypair(ctx, key))
.map(|key| schnorrsig::PublicKey::from_keypair(key))
.collect::<Vec<_>>();
let pre_session = new_pre_session(&pub_keys, ctx);

Expand Down
7 changes: 4 additions & 3 deletions mint-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ edition = "2018"
async-trait = "0.1.52"
base64 = "0.13.0"
bincode = "1.3.1"
bitcoin = "0.27.0"
bitcoin = "0.28.0"
bitcoin_hashes = "0.10.0"
futures = "0.3.9"
hex = "0.4.3"
lightning-invoice = "0.14.0"
lightning = "0.0.106"
miniscript = "6.0.0"
miniscript = "7.0.0"
minimint = { path = "../minimint" }
minimint-api = { path = "../minimint-api" }
rand = "0.6.5"
reqwest = { version = "0.11.0", features = [ "json" ], default-features = false }
secp256k1-zkp = { git = "https://github.com/elsirion/rust-secp256k1-zkp", branch = "minimint", features = [ "serde", "bitcoin_hashes" ] }
# secp256k1-zkp = { git = "https://github.com/elsirion/rust-secp256k1-zkp", branch = "minimint", features = [ "serde", "bitcoin_hashes" ] }
secp256k1-zkp = { version = "0.6", features = [ "serde", "bitcoin_hashes" ] }
serde = { version = "1.0.118", features = [ "derive" ] }
sha3 = "0.9.1"
sled = "0.34.6"
Expand Down
13 changes: 5 additions & 8 deletions mint-client/src/mint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ impl<'c> MintClient<'c> {

// We check for coin validity in case we got it from an untrusted third party. We
// don't want to needlessly create invalid tx and bother the federation with them.
let spend_pub_key = secp256k1_zkp::schnorrsig::PublicKey::from_keypair(
self.context.secp,
&spend_key,
);
let spend_pub_key = secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&spend_key);
if &spend_pub_key == coin.coin.spend_key() {
Ok((spend_key, (amt, coin.coin)))
} else {
Expand Down Expand Up @@ -334,13 +331,13 @@ impl CoinRequest {
{
let spend_key = secp256k1_zkp::schnorrsig::KeyPair::new(ctx, &mut rng);
let nonce = CoinNonce(secp256k1_zkp::schnorrsig::PublicKey::from_keypair(
ctx, &spend_key,
&spend_key,
));

let (blinding_key, blinded_nonce) = blind_message(nonce.to_message());

let cr = CoinRequest {
spend_key: spend_key.serialize_secret(),
spend_key: spend_key.serialize_bytes(),
nonce,
blinding_key,
};
Expand Down Expand Up @@ -583,7 +580,7 @@ mod tests {
meta.keys,
spend_keys
.into_iter()
.map(|key| secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&ctx, &key))
.map(|key| secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&key))
.collect::<Vec<_>>()
);

Expand Down Expand Up @@ -611,7 +608,7 @@ mod tests {
meta.keys,
spend_keys
.into_iter()
.map(|key| secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&ctx, &key))
.map(|key| secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&key))
.collect::<Vec<_>>()
);

Expand Down
9 changes: 3 additions & 6 deletions mint-client/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ impl<'c> WalletClient<'c> {
mut rng: R,
) -> Address {
let peg_in_sec_key = secp256k1_zkp::schnorrsig::KeyPair::new(self.context.secp, &mut rng);
let peg_in_pub_key =
secp256k1_zkp::schnorrsig::PublicKey::from_keypair(self.context.secp, &peg_in_sec_key);
let peg_in_pub_key = secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&peg_in_sec_key);

// TODO: check at startup that no bare descriptor is used in config
// TODO: check if there are other failure cases
Expand Down Expand Up @@ -81,10 +80,8 @@ impl<'c> WalletClient<'c> {
&secret_tweak_key_bytes,
)
.expect("sec key was generated and saved by us");
let public_tweak_key = secp256k1_zkp::schnorrsig::PublicKey::from_keypair(
self.context.secp,
&secret_tweak_key,
);
let public_tweak_key =
secp256k1_zkp::schnorrsig::PublicKey::from_keypair(&secret_tweak_key);

let peg_in_proof = PegInProof::new(
txout_proof,
Expand Down
4 changes: 2 additions & 2 deletions modules/minimint-ln/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ edition = "2018"
[dependencies]
async-trait = "0.1"
bincode = "1"
bitcoin_hashes = "0.10"
bitcoin_hashes = "0.10.0"
futures = "0.3.21"
itertools = "0.10.1"
lightning = "0.0.106"
lightning-invoice = "0.14.0"
minimint-api = { path = "../../minimint-api" }
secp256k1 = "0.20"
secp256k1 = { version = "0.22", features = ["rand"] }
serde = {version = "1.0.130", features = [ "derive" ] }
threshold_crypto = "0.3"
thiserror = "1.0.23"
Expand Down
2 changes: 1 addition & 1 deletion modules/minimint-ln/src/contracts/incoming.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::contracts::{ContractId, IdentifyableContract};
use bitcoin_hashes::sha256::Hash as Sha256;
use bitcoin_hashes::Hash as BitcoinHash;
use bitcoin_hashes::{borrow_slice_impl, hash_newtype, hex_fmt_impl, index_impl, serde_impl};
use bitcoin_hashes::{borrow_slice_impl, hash_newtype, hex_fmt_impl, serde_impl};
use minimint_api::encoding::{Decodable, DecodeError, Encodable};
use minimint_api::OutPoint;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion modules/minimint-ln/src/contracts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod outgoing;
use crate::contracts::incoming::{DecryptedPreimage, FundedIncomingContract};
use bitcoin_hashes::sha256::Hash as Sha256;
use bitcoin_hashes::Hash as BitcoinHash;
use bitcoin_hashes::{borrow_slice_impl, hash_newtype, hex_fmt_impl, index_impl, serde_impl};
use bitcoin_hashes::{borrow_slice_impl, hash_newtype, hex_fmt_impl, serde_impl};
use minimint_api::encoding::{Decodable, DecodeError, Encodable};
use minimint_api::OutPoint;
use serde::{Deserialize, Serialize};
Expand Down
3 changes: 2 additions & 1 deletion modules/minimint-mint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ minimint-api = { path = "../../minimint-api" }
minimint-derive = { path = "../../minimint-derive" }
rand = "0.6"
rayon = "1.5.0"
secp256k1-zkp = { git = "https://github.com/elsirion/rust-secp256k1-zkp", branch = "minimint", features = [ ] }
# secp256k1-zkp = { git = "https://github.com/elsirion/rust-secp256k1-zkp", branch = "minimint", features = [ ] }
secp256k1-zkp = { version = "0.6" , features = [ ] }
serde = { version = "1.0.118", features = [ "derive" ] }
tbs = { path = "../../crypto/tbs" }
thiserror = "1.0.23"
Expand Down
4 changes: 2 additions & 2 deletions modules/minimint-mint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ impl Mint {
.iter()
.map(|(idx, _)| *idx)
.collect::<counter::Counter<_>>();
if let Some((peer, count)) = peer_contrib_counts.into_iter().find(|(_, cnt)| *cnt > 1) {
if let Some((peer, count)) = peer_contrib_counts.into_iter().find(|(_, cnt)| **cnt > 1) {
return (
Err(CombineError::MultiplePeerContributions(peer, count)),
Err(CombineError::MultiplePeerContributions(*peer, *count)),
MintShareErrors(vec![]),
);
}
Expand Down
8 changes: 4 additions & 4 deletions modules/minimint-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ edition = "2018"

[dependencies]
async-trait = "0.1"
bitcoin = { version = "0.27.0", features = [ "rand", "serde", "bitcoinconsensus" ] }
bitcoincore-rpc = "0.14.0"
bitcoin = { version = "0.28.0", features = [ "rand", "serde", "bitcoinconsensus" ] }
bitcoincore-rpc = "0.15.0"
hex = "0.4.3"
itertools = "0.10.0"
minimint-api = { path = "../../minimint-api" }
minimint-derive = { path = "../../minimint-derive" }
miniscript = { version = "6.0.0", features = [ "compiler", "use-serde" ] }
miniscript = { version = "7.0.0", features = [ "compiler", "use-serde" ] }
rand = "0.6.0"
secp256k1 = { version = "0.20", features = [ "serde" ] }
secp256k1 = { version = "0.22", features = [ "serde" ] }
serde = { version = "1.0.118", features = [ "derive" ] }
thiserror = "1.0.23"
tokio = { version = "1.0.1", features = ["full"] }
Expand Down
12 changes: 7 additions & 5 deletions modules/minimint-wallet/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ impl MiniscriptKey for CompressedPublicKey {
(*self).clone()
}

fn serialized_len(&self) -> usize {
secp256k1::constants::PUBLIC_KEY_SIZE
}
// TODO: is this x-only???

// fn serialized_len(&self) -> usize {
// secp256k1::constants::PUBLIC_KEY_SIZE
// }
}

impl ToPublicKey for CompressedPublicKey {
fn to_public_key(&self) -> PublicKey {
PublicKey {
compressed: true,
key: self.key,
inner: self.key,
}
}

Expand Down Expand Up @@ -74,7 +76,7 @@ impl From<CompressedPublicKey> for bitcoin::PublicKey {
fn from(key: CompressedPublicKey) -> Self {
bitcoin::PublicKey {
compressed: true,
key: key.key,
inner: key.key,
}
}
}
Loading

0 comments on commit 51b3450

Please sign in to comment.