Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into kapil/remove_self_pro…
Browse files Browse the repository at this point in the history
…g_id_cli
  • Loading branch information
codeblooded1729 committed May 21, 2024
1 parent 78da88c commit f35b5f8
Show file tree
Hide file tree
Showing 21 changed files with 196 additions and 96 deletions.
41 changes: 25 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ anyhow = { version = "1.0", default-features = false }
arrayvec = { version = "0.7", default-features = false }
bitfield = "0.15"
expr = { path = "../expr" }
itertools = "0.12"
itertools = "0.13"
log = "0.4"
mozak-circuits-derive = { path = "./derive" }
mozak-runner = { path = "../runner" }
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ clap-verbosity-flag = "2.2"
clap_derive = "4.5"
clio = { version = "0.3", features = ["clap-parse"] }
env_logger = "0.11"
itertools = "0.12"
itertools = "0.13"
log = "0.4"
mozak-examples = { path = "../examples-builder", features = ["mozak-sort"], optional = true}
plonky2 = { workspace = true, default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion examples/inputtape/main_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ fn main() {

mozak_sdk::call_send(token_program, MethodArgs::RawTapesTest, dispatch);

mozak_sdk::native::dump_proving_files("inputtape");
mozak_sdk::native::dump_proving_files();
}
2 changes: 1 addition & 1 deletion examples/token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ the native execution above to produce the system tape prior to running this.
MOZAK_STARK_DEBUG=true \
cargo run --bin mozak-cli -- prove-and-verify -vvv \
examples/target/riscv32im-mozak-mozakvm-elf/release/tokenbin \
--system-tape examples/token/out/token.tape.json \
--system-tape examples/token/out/tape.json \
--self-prog-id \
MZK-b10da48cea4c09676b8e0efcd806941465060736032bb898420d0863dca72538;
```
3 changes: 1 addition & 2 deletions examples/token/main_native.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(restricted_std)]
#![allow(unused_attributes)]
mod core_logic;
use mozak_sdk::common::types::{ProgramIdentifier, StateAddress, StateObject};
Expand Down Expand Up @@ -39,5 +38,5 @@ fn main() {
dispatch,
);

mozak_sdk::native::dump_proving_files("token");
mozak_sdk::native::dump_proving_files();
}
2 changes: 1 addition & 1 deletion examples/wallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ the native execution above to produce the system tape prior to running this.
MOZAK_STARK_DEBUG=true \
cargo run --bin mozak-cli -- prove-and-verify -vvv \
examples/target/riscv32im-mozak-mozakvm-elf/release/walletbin \
--system-tape examples/wallet/out/wallet.tape.json \
--system-tape examples/wallet/out/tape.json \
--self-prog-id \
MZK-b10da48cea4c09676b8e0efcd806941465060736032bb898420d0863dca72538;
```
3 changes: 1 addition & 2 deletions examples/wallet/main_native.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(restricted_std)]
#![allow(unused_attributes)]

mod core_logic;
Expand Down Expand Up @@ -31,5 +30,5 @@ fn main() {
dispatch,
);

mozak_sdk::native::dump_proving_files("wallet");
mozak_sdk::native::dump_proving_files();
}
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository = "https://github.com/0xmozak/mozak-node"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
itertools = "0.12"
itertools = "0.13"
mozak-recproofs = { path = '../recproofs' }
mozak-sdk = { path = '../sdk' }
plonky2 = { workspace = true, default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion recproofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version = "0.1.0"
anyhow = { version = "1.0", default-features = false }
enumflags2 = "0.7"
iter_fixed = "0.3"
itertools = "0.12"
itertools = "0.13"
plonky2 = { workspace = true, default-features = false }

[dev-dependencies]
Expand Down
52 changes: 35 additions & 17 deletions recproofs/src/circuits/build_event_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ where

pub fn prove(
&self,
event: Event<F>,
branch: &BranchCircuit<F, C, D>,
event: Event<F>,
) -> Result<LeafProof<F, C, D>> {
let mut inputs = PartialWitness::new();
self.unbounded.set_witness(&mut inputs, &branch.circuit);
Expand All @@ -193,10 +193,10 @@ where

pub fn prove_unsafe(
&self,
branch: &BranchCircuit<F, C, D>,
event: Event<F>,
hash: Option<HashOut<F>>,
vm_hash: Option<HashOut<F>>,
branch: &BranchCircuit<F, C, D>,
) -> Result<LeafProof<F, C, D>> {
let mut inputs = PartialWitness::new();
self.unbounded.set_witness(&mut inputs, &branch.circuit);
Expand Down Expand Up @@ -316,21 +316,39 @@ where
pub fn prove<L: IsLeaf, R: IsLeaf>(
&self,
left_proof: &Proof<L, F, C, D>,
right_proof: Option<&Proof<R, F, C, D>>,
right_proof: &Proof<R, F, C, D>,
) -> Result<BranchProof<F, C, D>> {
let mut inputs = PartialWitness::new();
let partial = right_proof.is_none();
let (right_is_leaf, right_proof) = if let Some(right_proof) = right_proof {
(R::VALUE, &right_proof.proof)
} else {
(L::VALUE, &left_proof.proof)
};
let partial = false;
self.unbounded.set_witness(
&mut inputs,
L::VALUE,
&left_proof.proof,
right_is_leaf,
right_proof,
R::VALUE,
&right_proof.proof,
);
self.hash.set_witness(&mut inputs, partial);
self.vm_hash.set_witness(&mut inputs, partial);
let proof = self.circuit.prove(inputs)?;
Ok(BranchProof {
proof,
tag: PhantomData,
indices: self.indices(),
})
}

pub fn prove_one<L: IsLeaf>(
&self,
left_proof: &Proof<L, F, C, D>,
) -> Result<BranchProof<F, C, D>> {
let mut inputs = PartialWitness::new();
let partial = true;
self.unbounded.set_witness(
&mut inputs,
L::VALUE,
&left_proof.proof,
L::VALUE,
&left_proof.proof,
);
self.hash.set_witness(&mut inputs, partial);
self.vm_hash.set_witness(&mut inputs, partial);
Expand Down Expand Up @@ -427,7 +445,7 @@ pub mod test {
}

fn test_leaf(event: Event<F>) -> Result<LeafProof<F, C, D>> {
let proof = LEAF.prove(event, &BRANCH)?;
let proof = LEAF.prove(&BRANCH, event)?;
assert_proof(&proof, event.hash(), event.byte_wise_hash(), event.owner);
LEAF.verify(proof.clone())?;
Ok(proof)
Expand All @@ -444,7 +462,7 @@ pub mod test {
"Test bug: tried to combine different event owners"
);

let proof = BRANCH.prove(left, Some(right))?;
let proof = BRANCH.prove(left, right)?;
let hash = hash_branch(&left.hash(), &right.hash());
let vm_hash = hash_branch_bytes(&left.vm_hash(), &right.vm_hash());
assert_proof(&proof, hash, vm_hash, left.event_owner());
Expand All @@ -464,7 +482,7 @@ pub mod test {
"Test bug: tried to combine different event owners"
);

let proof = BRANCH.prove(left, Some(right))?;
let proof = BRANCH.prove(left, right)?;
let hash = hash_branch(&left.hash(), &right.hash());
let vm_hash = hash_branch_bytes(&left.vm_hash(), &right.vm_hash());
assert_proof(&proof, hash, vm_hash, left.event_owner());
Expand Down Expand Up @@ -565,7 +583,7 @@ pub mod test {
.expect("shouldn't fail");

// Fail to prove with mismatched hashes
LEAF.prove_unsafe(read_1, Some(read_0_hash), Some(read_0_byte_hash), &BRANCH)
LEAF.prove_unsafe(&BRANCH, read_1, Some(read_0_hash), Some(read_0_byte_hash))
.unwrap();
}

Expand Down Expand Up @@ -599,10 +617,10 @@ pub mod test {
let read_1_byte_hash = read_1.byte_wise_hash();

// Read zero
let read_proof_1 = LEAF.prove(read_0, &BRANCH).unwrap();
let read_proof_1 = LEAF.prove(&BRANCH, read_0).unwrap();
LEAF.verify(read_proof_1.clone()).unwrap();

let read_proof_2 = LEAF.prove(read_1, &BRANCH).unwrap();
let read_proof_2 = LEAF.prove(&BRANCH, read_1).unwrap();
LEAF.verify(read_proof_2.clone()).unwrap();

// Combine reads
Expand Down
2 changes: 1 addition & 1 deletion recproofs/src/circuits/verify_block/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl SubCircuitInputs {
)
.common;

let dummy = dummy_circuit::<_, C, D>(&common, |builder| self.register_inputs(builder));
let dummy = dummy_circuit::<C, D>(&common, |builder| self.register_inputs(builder));

let prev_proof = builder.add_virtual_proof_with_pis(&common);

Expand Down
Loading

0 comments on commit f35b5f8

Please sign in to comment.