Skip to content

Commit

Permalink
Revert "fix file structure"
Browse files Browse the repository at this point in the history
This reverts commit 7ff9b60.
  • Loading branch information
orkunkilic committed Feb 2, 2024
1 parent 7ff9b60 commit 96fd5b6
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 33 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 = "bitvm"
name = "toy-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: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,18 @@ fix:

check:
cargo fmt -- --check
cargo clippy -- -D warnings
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
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 BitVM implementation in Rust.
Experimental toy 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::wire::{HashValue, PreimageValue};
use crate::circuit::wire::{HashValue, PreimageValue};

pub struct Actor {
secp: Secp256k1<All>,
Expand Down
10 changes: 3 additions & 7 deletions src/gates.rs → src/circuit/gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ 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 @@ -225,8 +222,7 @@ pub fn create_gate(

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

use super::super::wire::PreimageValue;
use super::*;
use bitcoin::hashes::sha256;
use bitcoin::hashes::Hash;
Expand Down
9 changes: 6 additions & 3 deletions src/circuit.rs → src/circuit/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
pub mod gates;
pub mod wire;

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

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

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

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

pub struct Circuit {
pub input_sizes: Vec<usize>,
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
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: 4 additions & 6 deletions src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ use bitcoin::{secp256k1::Secp256k1, Amount, Transaction, XOnlyPublicKey};
use bitcoin::{OutPoint, ScriptBuf, TapLeafHash, TxIn, TxOut, Witness};

use bitcoincore_rpc::{Auth, Client, RpcApi};
use bitvm::transactions::{
use toy_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 bitvm::utils::number_to_bool_array;
use bitvm::wire::PreimageValue;
// prover.rs
use bitvm::{
use toy_bitvm::circuit::wire::{HashTuple, HashValue, PreimageValue};
use toy_bitvm::utils::number_to_bool_array;
use toy_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::wire::{HashValue, PreimageValue, Wire};
use crate::circuit::wire::{HashValue, PreimageValue, Wire};
use bitcoin::ScriptBuf;
use std::{
iter::zip,
Expand Down
2 changes: 1 addition & 1 deletion src/transactions.rs → src/transactions/mod.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: 6 additions & 7 deletions src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ 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 bitvm::transactions::{
use toy_bitvm::circuit::wire::{HashTuple, HashValue, PreimageValue, Wire};
use toy_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 bitvm::utils::take_stdin;
use bitvm::wire::{PreimageValue, Wire};
use toy_bitvm::utils::take_stdin;
// verifier.rs
use bitvm::{
use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::accept_async;
use toy_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

0 comments on commit 96fd5b6

Please sign in to comment.