Skip to content

Commit

Permalink
fix file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
orkunkilic committed Feb 2, 2024
1 parent f067293 commit 7ff9b60
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 41 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "toy-bitvm"
name = "bitvm"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bitcoin = { version = "0.31.0", features = ["rand"] }
bitcoincore-rpc = { version = "0.18.0" }
bitcoin = {version = "0.31.0", features = ["rand"]}
bitcoincore-rpc = {version = "0.18.0" }
hex = "0.4.3"
rand = "0.8.5"
tokio = { version = "1", features = ["full"] }
Expand Down
16 changes: 1 addition & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,4 @@ fix:

check:
cargo fmt -- --check
cargo clippy -- -D warnings

check-fuzz: ## Checks that fuzz member compiles
$(MAKE) -C fuzz check

lint:
cargo +nightly fmt --all --check
cargo check --all-targets --all-features
$(MAKE) check-fuzz
cargo clippy --all-targets --all-features

lint-fix:
cargo +nightly fmt --all
cargo fix --allow-dirty
cargo clippy --fix --allow-dirty
cargo clippy -- -D warnings
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BitVM.rs

Experimental toy BitVM implementation in Rust.
Experimental BitVM implementation in Rust.

It is recommended to always use [cargo-crev](https://github.com/crev-dev/cargo-crev)
to verify the trustworthiness of each of your dependencies, including this one.
Expand Down
2 changes: 1 addition & 1 deletion src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bitcoin::{
};
use rand::Rng;

use crate::circuit::wire::{HashValue, PreimageValue};
use crate::wire::{HashValue, PreimageValue};

pub struct Actor {
secp: Secp256k1<All>,
Expand Down
9 changes: 3 additions & 6 deletions src/circuit/mod.rs → src/circuit.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
pub mod gates;
pub mod wire;

use std::collections::BTreeMap;
use std::iter::zip;

use std::sync::{Arc, Mutex};

use gates::create_gate;
use wire::{HashTuple, Wire};
use crate::gates::create_gate;
use crate::wire::HashTuple;

use crate::{traits::gate::GateTrait, utils::read_lines};
use crate::{traits::gate::GateTrait, utils::read_lines, wire::Wire};

pub struct Circuit {
pub input_sizes: Vec<usize>,
Expand Down
10 changes: 7 additions & 3 deletions src/circuit/gates.rs → src/gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ use bitcoin::opcodes::all::{
use bitcoin::script::Builder;
use bitcoin::ScriptBuf;

use super::wire::{HashValue, Wire};
use crate::traits::gate::{GateTrait, Wires};
use crate::transactions::add_bit_commitment_script;
use crate::wire::HashValue;
use crate::{
traits::gate::{GateTrait, Wires},
wire::Wire,
};

use std::sync::{Arc, Mutex};

Expand Down Expand Up @@ -222,7 +225,8 @@ pub fn create_gate(

#[cfg(test)]
mod tests {
use super::super::wire::PreimageValue;
use crate::wire::PreimageValue;

use super::*;
use bitcoin::hashes::sha256;
use bitcoin::hashes::Hash;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub mod actor;
pub mod circuit;
pub mod communication;
pub mod gates;
pub mod traits;
pub mod transactions;
pub mod utils;
pub mod wire;
10 changes: 6 additions & 4 deletions src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ use bitcoin::{secp256k1::Secp256k1, Amount, Transaction, XOnlyPublicKey};
use bitcoin::{OutPoint, ScriptBuf, TapLeafHash, TxIn, TxOut, Witness};

use bitcoincore_rpc::{Auth, Client, RpcApi};
use toy_bitvm::transactions::{
use bitvm::transactions::{
generate_2_of_2_script, generate_equivoation_address_and_info, generate_gate_response_script,
generate_response_second_address_and_info, watch_transaction,
};

use toy_bitvm::circuit::wire::{HashTuple, HashValue, PreimageValue};
use toy_bitvm::utils::number_to_bool_array;
use toy_bitvm::{
use bitvm::utils::number_to_bool_array;
use bitvm::wire::PreimageValue;
// prover.rs
use bitvm::{
actor::Actor,
circuit::Circuit,
communication::{receive_message, send_message},
transactions::{generate_challenge_address_and_info, generate_response_address_and_info},
wire::{HashTuple, HashValue},
};

use tokio_tungstenite::connect_async;
Expand Down
2 changes: 1 addition & 1 deletion src/traits/gate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::circuit::wire::{HashValue, PreimageValue, Wire};
use crate::wire::{HashValue, PreimageValue, Wire};
use bitcoin::ScriptBuf;
use std::{
iter::zip,
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/mod.rs → src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use bitcoin::blockdata::script::Builder;
use bitcoin::opcodes::all::*;
use bitcoincore_rpc::{Client, RpcApi};

use crate::circuit::wire::{HashTuple, HashValue};
use crate::traits::gate::GateTrait;
use crate::wire::{HashTuple, HashValue};

use crate::circuit::Circuit;

Expand Down
13 changes: 7 additions & 6 deletions src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ use bitcoin::taproot::LeafVersion;
use bitcoin::{secp256k1::Secp256k1, Transaction, Txid, XOnlyPublicKey};
use bitcoin::{Amount, OutPoint, ScriptBuf, TapLeafHash, TxIn, TxOut, Witness};
use bitcoincore_rpc::{Auth, Client, RpcApi};
use toy_bitvm::circuit::wire::{HashTuple, HashValue, PreimageValue, Wire};
use toy_bitvm::transactions::{
use bitvm::transactions::{
generate_2_of_2_script, generate_anti_contradiction_script, generate_challenge_script,
generate_equivoation_address_and_info, generate_response_second_address_and_info,
watch_transaction,
};
use toy_bitvm::utils::take_stdin;
use bitvm::utils::take_stdin;
use bitvm::wire::{PreimageValue, Wire};
// verifier.rs
use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::accept_async;
use toy_bitvm::{
use bitvm::{
actor::Actor,
circuit::Circuit,
communication::{receive_message, send_message},
transactions::{generate_challenge_address_and_info, generate_response_address_and_info},
wire::{HashTuple, HashValue},
};
use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::accept_async;

#[tokio::main]
async fn main() {
Expand Down
File renamed without changes.

0 comments on commit 7ff9b60

Please sign in to comment.