Skip to content
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
6 changes: 3 additions & 3 deletions crates/bitvm2/src/committee/api.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::types::Bitvm2Graph;
use anyhow::{Result, bail};
use anyhow::{bail, Result};
use bitcoin::PublicKey;
use bitcoin::{TapSighashType, Witness, hex::FromHex, key::Keypair};
use bitcoin::{hex::FromHex, key::Keypair, TapSighashType, Witness};
use goat::connectors::{connector_0::Connector0, connector_5::Connector5, connector_d::ConnectorD};
use goat::contexts::base::generate_n_of_n_public_key;
use goat::transactions::signing_musig2::{
Expand All @@ -11,7 +11,7 @@ use goat::transactions::{
base::BaseTransaction, pre_signed::PreSignedTransaction, pre_signed_musig2::get_nonce_message,
signing_musig2::generate_taproot_partial_signature,
};
use musig2::{AggNonce, PartialSignature, PubNonce, SecNonce, secp256k1::schnorr::Signature};
use musig2::{secp256k1::schnorr::Signature, AggNonce, PartialSignature, PubNonce, SecNonce};
use sha2::{Digest, Sha256};

pub const COMMITTEE_PRE_SIGN_NUM: usize = 5;
Expand Down
6 changes: 3 additions & 3 deletions crates/bitvm2/src/committee/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod api;

pub use api::{
COMMITTEE_PRE_SIGN_NUM, committee_pre_sign, generate_keypair_from_seed,
generate_nonce_from_seed, key_aggregation, nonce_aggregation, nonces_aggregation,
push_committee_pre_signatures, signature_aggregation_and_push,
committee_pre_sign, generate_keypair_from_seed, generate_nonce_from_seed, key_aggregation,
nonce_aggregation, nonces_aggregation, push_committee_pre_signatures,
signature_aggregation_and_push, COMMITTEE_PRE_SIGN_NUM,
};
4 changes: 2 additions & 2 deletions crates/bitvm2/src/keys.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::{
committee::{COMMITTEE_PRE_SIGN_NUM, generate_keypair_from_seed, generate_nonce_from_seed},
committee::{generate_keypair_from_seed, generate_nonce_from_seed, COMMITTEE_PRE_SIGN_NUM},
operator::generate_wots_keys,
types::{WotsPublicKeys, WotsSecretKeys},
};
use bitcoin::key::Keypair;
use musig2::{PubNonce, SecNonce, secp256k1::schnorr::Signature};
use musig2::{secp256k1::schnorr::Signature, PubNonce, SecNonce};
use sha2::{Digest, Sha256};
use uuid::Uuid;

Expand Down
22 changes: 11 additions & 11 deletions crates/bitvm2/src/operator/api.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use crate::types::{
Bitvm2Graph, Bitvm2Parameters, CustomInputs, Groth16Proof, Groth16WotsPublicKeys,
Groth16WotsSignatures, PublicInputs, VerifyingKey, WotsPublicKeys, WotsSecretKeys,
get_magic_bytes,
get_magic_bytes, Bitvm2Graph, Bitvm2Parameters, CustomInputs, Groth16Proof,
Groth16WotsPublicKeys, Groth16WotsSignatures, PublicInputs, VerifyingKey, WotsPublicKeys,
WotsSecretKeys,
};
use anyhow::{Result, bail};
use anyhow::{bail, Result};
use bitcoin::Transaction;
use bitcoin::{Amount, OutPoint, Witness, XOnlyPublicKey, key::Keypair};
use bitcoin::{key::Keypair, Amount, OutPoint, Witness, XOnlyPublicKey};
use bitvm::chunk::api::{
NUM_HASH, NUM_PUBS, NUM_U256, api_generate_full_tapscripts, api_generate_partial_script,
generate_signatures_lit, type_conversion_utils::utils_raw_witnesses_from_signatures,
api_generate_full_tapscripts, api_generate_partial_script, generate_signatures_lit,
type_conversion_utils::utils_raw_witnesses_from_signatures, NUM_HASH, NUM_PUBS, NUM_U256,
};
use bitvm::signatures::{
signing_winternitz::{LOG_D, WinternitzPublicKey, WinternitzSecret, WinternitzSigningInputs},
signing_winternitz::{WinternitzPublicKey, WinternitzSecret, WinternitzSigningInputs, LOG_D},
winternitz::Parameters,
wots_api::{wots_hash, wots256},
wots_api::{wots256, wots_hash},
};
use bitvm::treepp::*;
use goat::commitments::{CommitmentMessageId, KICKOFF_MSG_SIZE, NUM_KICKOFF};
Expand All @@ -28,8 +28,8 @@ use goat::transactions::{
assert::assert_final::AssertFinalTransaction,
assert::assert_initial::AssertInitialTransaction,
assert::utils::{
AllCommitConnectorsE, AssertCommitConnectorsF, COMMIT_TX_NUM,
convert_to_connector_c_commits_public_key,
convert_to_connector_c_commits_public_key, AllCommitConnectorsE, AssertCommitConnectorsF,
COMMIT_TX_NUM,
},
base::Input,
challenge::ChallengeTransaction,
Expand Down
2 changes: 1 addition & 1 deletion crates/bitvm2/src/pegin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bitcoin::opcodes::all::OP_RETURN;
use bitcoin::script::Instruction;
use bitcoin::{Network, Script, script};
use bitcoin::{script, Network, Script};

use crate::types::get_magic_bytes;

Expand Down
22 changes: 11 additions & 11 deletions crates/bitvm2/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bitcoin::TapNodeHash;
use bitcoin::{Address, Amount, Network, PrivateKey, PublicKey, XOnlyPublicKey, key::Keypair};
use bitcoin::{key::Keypair, Address, Amount, Network, PrivateKey, PublicKey, XOnlyPublicKey};
use bitvm::chunk::api::{
NUM_HASH, NUM_PUBS, NUM_U256, PublicKeys as ApiWotsPublicKeys, Signatures as ApiWotsSignatures,
PublicKeys as ApiWotsPublicKeys, Signatures as ApiWotsSignatures, NUM_HASH, NUM_PUBS, NUM_U256,
};
use bitvm::signatures::signing_winternitz::{WinternitzPublicKey, WinternitzSecret};
use goat::commitments::NUM_KICKOFF;
Expand All @@ -15,7 +15,7 @@ use goat::transactions::{
kick_off::KickOffTransaction, peg_in::peg_in::PegInTransaction,
peg_out_confirm::PreKickoffTransaction, take_1::Take1Transaction, take_2::Take2Transaction,
};
use rand::{Rng, distributions::Alphanumeric};
use rand::{distributions::Alphanumeric, Rng};
use secp256k1::SECP256K1;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -172,7 +172,7 @@ pub fn get_magic_bytes(net: &Network) -> Vec<u8> {
}

pub mod node_serializer {
use serde::{self, Deserialize, Deserializer, Serializer, ser::Error};
use serde::{self, ser::Error, Deserialize, Deserializer, Serializer};
use std::str::FromStr;

pub mod address {
Expand Down Expand Up @@ -203,7 +203,7 @@ pub mod node_serializer {
use crate::types::WotsPublicKeys;
use bitvm::chunk::api::{NUM_HASH, NUM_PUBS, NUM_U256};
use bitvm::signatures::signing_winternitz::WinternitzPublicKey;
use bitvm::signatures::wots_api::{wots_hash, wots256};
use bitvm::signatures::wots_api::{wots256, wots_hash};
use goat::commitments::NUM_KICKOFF;
use std::collections::HashMap;

Expand All @@ -214,17 +214,17 @@ pub mod node_serializer {
let mut pubkeys_map: HashMap<u32, Vec<Vec<u8>>> = HashMap::new();
let mut index = 0;
// wots pk for groth16 proof
for pk in pubkeys.1.0 {
for pk in pubkeys.1 .0 {
let v: Vec<Vec<u8>> = pk.iter().map(|x| x.to_vec()).collect();
pubkeys_map.insert(index, v);
index += 1;
}
for pk in pubkeys.1.1 {
for pk in pubkeys.1 .1 {
let v: Vec<Vec<u8>> = pk.iter().map(|x| x.to_vec()).collect();
pubkeys_map.insert(index, v);
index += 1;
}
for pk in pubkeys.1.2 {
for pk in pubkeys.1 .2 {
let v: Vec<Vec<u8>> = pk.iter().map(|x| x.to_vec()).collect();
pubkeys_map.insert(index, v);
index += 1;
Expand Down Expand Up @@ -359,11 +359,11 @@ pub mod node_serializer {
pub mod wots_seckeys {
use serde::de::{SeqAccess, Visitor};
use serde::ser::SerializeTuple;
use serde::{Deserializer, Serializer, de::Error as DeError, ser::Error};
use serde::{de::Error as DeError, ser::Error, Deserializer, Serializer};
use std::fmt;

use crate::types::{
Groth16WotsSecretKeys, KickoffWotsSecretKeys, NUM_KICKOFF, NUM_SIGS, WotsSecretKeys,
Groth16WotsSecretKeys, KickoffWotsSecretKeys, WotsSecretKeys, NUM_KICKOFF, NUM_SIGS,
};

pub fn serialize<S>(keys: &WotsSecretKeys, serializer: S) -> Result<S::Ok, S::Error>
Expand Down Expand Up @@ -445,7 +445,7 @@ pub mod node_serializer {
#[cfg(test)]
mod tests {
use crate::operator::generate_wots_keys;
use crate::types::{WotsPublicKeys, WotsSecretKeys, node_serializer};
use crate::types::{node_serializer, WotsPublicKeys, WotsSecretKeys};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;

Expand Down
9 changes: 4 additions & 5 deletions crates/bitvm2/src/verifier/api.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use crate::types::{
Bitvm2Graph, Groth16WotsPublicKeys, Groth16WotsSignatures, VerifyingKey, WotsPublicKeys,
};
use anyhow::{Result, bail};
use anyhow::{bail, Result};
use bitcoin::{Address, Amount, Transaction};
use bitvm::chunk::api::{
NUM_TAPS,
type_conversion_utils::{RawWitness, script_to_witness, utils_signatures_from_raw_witnesses},
validate_assertions,
type_conversion_utils::{script_to_witness, utils_signatures_from_raw_witnesses, RawWitness},
validate_assertions, NUM_TAPS,
};
use bitvm::treepp::*;
use goat::connectors::connector_c::{ConnectorC, get_commit_from_assert_commit_tx};
use goat::connectors::connector_c::{get_commit_from_assert_commit_tx, ConnectorC};
use goat::transactions::assert::utils::*;
use goat::transactions::{base::BaseTransaction, pre_signed::PreSignedTransaction};

Expand Down
8 changes: 4 additions & 4 deletions crates/client/src/chain/goat_adaptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use crate::chain::goat_adaptor::IGateway::IGatewayInstance;
use alloy::primitives::TxHash;
use alloy::{
eips::BlockNumberOrTag,
network::{Ethereum, EthereumWallet, NetworkWallet, eip2718::Encodable2718},
network::{eip2718::Encodable2718, Ethereum, EthereumWallet, NetworkWallet},
primitives::{Address as EvmAddress, Bytes, ChainId, FixedBytes, U256},
providers::{Provider, ProviderBuilder, RootProvider},
rpc::types::TransactionRequest,
signers::{Signer, local::PrivateKeySigner},
signers::{local::PrivateKeySigner, Signer},
sol,
transports::http::{Client, Http, reqwest::Url},
transports::http::{reqwest::Url, Client, Http},
};
use anyhow::format_err;
use async_trait::async_trait;
Expand Down Expand Up @@ -282,7 +282,7 @@ impl ChainAdaptor for GoatAdaptor {
.await?;
Ok(WithdrawData {
pegin_txid: res._0.0,
operator_address: res._1.0.0,
operator_address: res._1.0 .0,
status: res._2.into(),
instance_id: Uuid::from_slice(res._3.as_slice())?,
lock_amount: res._4,
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::chain::chain::Chain;
use crate::chain::chain_adaptor::{
BitcoinTx, GoatNetwork, OperatorData, PeginData, get_chain_adaptor,
get_chain_adaptor, BitcoinTx, GoatNetwork, OperatorData, PeginData,
};
use crate::chain::goat_adaptor::GoatInitConfig;
use crate::esplora::get_esplora_url;
Expand Down
2 changes: 1 addition & 1 deletion crates/identity/src/musig2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use rand::RngCore;
use secp256k1::{Secp256k1, SecretKey};
use std::string::String;

use musig2::KeyAggContext;
use musig2::k256::PublicKey;
use musig2::KeyAggContext;
use musig2::{
CompactSignature, FirstRound, PartialSignature, PubNonce, SecNonceSpices, SecondRound,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/spv/src/header_chain.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bitcoin::{
BlockHash, CompactTarget, TxMerkleNode,
block::{Header, Version},
hashes::Hash,
BlockHash, CompactTarget, TxMerkleNode,
};
use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion crates/spv/src/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ pub fn verify_merkle_proof(
mod tests {

use crate::transaction::CircuitTransaction;
use bitcoin::Block;
use bitcoin::hashes::Hash;
use bitcoin::hex::FromHex;
use bitcoin::Block;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions crates/store/src/ipfs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{Result, bail};
use anyhow::{bail, Result};
use futures::TryStreamExt;
use reqwest::Client;
use reqwest::multipart::{Form, Part};
use reqwest::Client;
use serde::Deserialize;
use std::path::Path;
use tokio::fs::File;
Expand Down
6 changes: 3 additions & 3 deletions crates/store/src/localdb.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::schema::NODE_STATUS_OFFLINE;
use crate::schema::NODE_STATUS_ONLINE;
use crate::{
COMMITTEE_PRE_SIGN_NUM, GrapRpcQueryData, Graph, Instance, Message, Node, NodesOverview,
NonceCollect, NonceCollectMetaData, PubKeyCollect, PubKeyCollectMetaData,
GrapRpcQueryData, Graph, Instance, Message, Node, NodesOverview, NonceCollect,
NonceCollectMetaData, PubKeyCollect, PubKeyCollectMetaData, COMMITTEE_PRE_SIGN_NUM,
};
use sqlx::migrate::Migrator;
use sqlx::pool::PoolConnection;
use sqlx::types::Uuid;
use sqlx::{Row, Sqlite, SqliteConnection, SqlitePool, Transaction, migrate::MigrateDatabase};
use sqlx::{migrate::MigrateDatabase, Row, Sqlite, SqliteConnection, SqlitePool, Transaction};
use std::time::{SystemTime, UNIX_EPOCH};

#[derive(Clone)]
Expand Down
6 changes: 3 additions & 3 deletions node/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::middleware::AllBehaviours;
use crate::rpc_service::current_time_secs;
use anyhow::Result;
use bitcoin::PublicKey;
use bitcoin::{Amount, Network, OutPoint, Txid, key::Keypair};
use bitcoin::{key::Keypair, Amount, Network, OutPoint, Txid};
use bitvm2_lib::actors::Actor;
use bitvm2_lib::keys::*;
use bitvm2_lib::types::{
Expand All @@ -17,7 +17,7 @@ use goat::transactions::take_1::Take1Transaction;
use goat::transactions::take_2::Take2Transaction;
use goat::transactions::{assert::utils::COMMIT_TX_NUM, pre_signed::PreSignedTransaction};
use libp2p::gossipsub::MessageId;
use libp2p::{PeerId, Swarm, gossipsub};
use libp2p::{gossipsub, PeerId, Swarm};
use musig2::{AggNonce, PartialSignature, PubNonce, SecNonce};
use reqwest::Request;
use serde::de::DeserializeOwned;
Expand Down Expand Up @@ -223,7 +223,7 @@ pub mod todo_funcs {
use bitcoin::{
Address, EcdsaSighashType, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Witness,
};
use bitcoin_script::{Script, script};
use bitcoin_script::{script, Script};
use bitvm::chunk::api::NUM_TAPS;
use bitvm2_lib::types::WotsPublicKeys;
use client::chain::chain_adaptor::WithdrawStatus;
Expand Down
4 changes: 2 additions & 2 deletions node/src/bitcoin/checker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{Result, bail};
use anyhow::{bail, Result};
use bitcoin::hashes::Hash;
use bitcoin::{Amount, Block, Network, Transaction, Txid};
use esplora_client::AsyncClient;
Expand Down Expand Up @@ -139,7 +139,7 @@ pub async fn check_pegin_tx(
mod tests {
use super::*;
use esplora_client::Builder;
use futures::{StreamExt, stream};
use futures::{stream, StreamExt};
#[tokio::test]
async fn test_check_pegin_tx() {
// tx: https://mempool.space/testnet/tx/e413208c6644d51f4f3adf3a5aad425da817ac825e56352e7164de1e2a4d9394
Expand Down
2 changes: 1 addition & 1 deletion node/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use alloy::eips::BlockNumberOrTag;
use alloy::primitives::Address as EvmAddress;
use bitcoin::{Network, PublicKey, key::Keypair};
use bitcoin::{key::Keypair, Network, PublicKey};
use bitvm2_lib::keys::NodeMasterKey;
use client::chain::goat_adaptor::GoatInitConfig;
use reqwest::Url;
Expand Down
5 changes: 3 additions & 2 deletions node/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![feature(trivial_bounds)]
use base64::Engine;
use clap::{Parser, Subcommand, command};
use libp2p::PeerId;
use clap::{command, Parser, Subcommand};
use libp2p::futures::StreamExt;
use libp2p::PeerId;
use libp2p::{gossipsub, kad, mdns, multiaddr::Protocol, noise, swarm::SwarmEvent, tcp, yamux};
use libp2p_metrics::Registry;
use std::collections::HashMap;
Expand All @@ -20,6 +20,7 @@ mod bitcoin;
mod env;
mod metrics_service;
mod middleware;
mod relayer_action;
mod rpc_service;

use crate::action::GOATMessage;
Expand Down
6 changes: 3 additions & 3 deletions node/src/metrics_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use std::{
use crate::rpc_service::AppState;
use axum::middleware::Next;
use axum::{
Router, extract::Request, extract::State, http::StatusCode, response::IntoResponse,
routing::get,
extract::Request, extract::State, http::StatusCode, response::IntoResponse, routing::get,
Router,
};
use http::HeaderMap;
use libp2p_metrics::Registry;
use prometheus_client::encoding::text::encode;
use prometheus_client::metrics::counter::Counter;
use prometheus_client::metrics::family::Family;
use prometheus_client::metrics::histogram::{Histogram, exponential_buckets};
use prometheus_client::metrics::histogram::{exponential_buckets, Histogram};
use tokio::net::TcpListener;
use tokio::time::Instant;

Expand Down
Loading
Loading