Skip to content

Commit

Permalink
chore: add two_plus_two Jolt zkVM puzzle wp
Browse files Browse the repository at this point in the history
  • Loading branch information
Xor0v0 authored and Xor0v0 committed Oct 1, 2024
1 parent 48d1313 commit 1fb95eb
Show file tree
Hide file tree
Showing 21 changed files with 4,084 additions and 10 deletions.
Binary file added docs/.DS_Store
Binary file not shown.
Binary file added docs/crypto/2+2=5/.DS_Store
Binary file not shown.
Binary file added docs/crypto/2+2=5/code/.DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions docs/crypto/2+2=5/code/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM rust:1.67

WORKDIR /usr/src/app

COPY ./jolt ./jolt
COPY ./server ./server

WORKDIR /usr/src/app/server

RUN cargo build --release

# run the server once just to download the toolchain, this will crash but we do not care
# god has already forgiven me for this
# (also this has nothing to do with the challenge itself)
RUN (echo "" | ./target/release/challenge); true

RUN apt update && apt install -y socat

ENTRYPOINT ["socat", "-t", "900", "-T", "120", "TCP4-LISTEN:5555,reuseaddr,fork", "EXEC:./target/release/challenge"]
19 changes: 19 additions & 0 deletions docs/crypto/2+2=5/code/diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/jolt-core/src/r1cs/jolt_constraints.rs b/jolt-core/src/r1cs/jolt_constraints.rs
index 5fb0d871..295dce32 100644
--- a/jolt-core/src/r1cs/jolt_constraints.rs
+++ b/jolt-core/src/r1cs/jolt_constraints.rs
@@ -289,13 +289,8 @@ impl<F: JoltField> R1CSConstraintBuilder<F> for UniformJoltConstraints {

// if (rd != 0 && update_rd_with_lookup_output == 1) constrain(rd_val == LookupOutput)
// if (rd != 0 && is_jump_instr == 1) constrain(rd_val == 4 * PC)
- let rd_nonzero_and_lookup_to_rd =
+ let _rd_nonzero_and_lookup_to_rd =
cs.allocate_prod(JoltIn::Bytecode_RD, JoltIn::OpFlags_LookupOutToRd);
- cs.constrain_eq_conditional(
- rd_nonzero_and_lookup_to_rd,
- JoltIn::RD_Write,
- JoltIn::LookupOutput,
- );
let rd_nonzero_and_jmp = cs.allocate_prod(JoltIn::Bytecode_RD, JoltIn::OpFlags_IsJmp);
let lhs = JoltIn::Bytecode_ELFAddress + (PC_START_ADDRESS - PC_NOOP_SHIFT);
let rhs = JoltIn::RD_Write;
1 change: 1 addition & 0 deletions docs/crypto/2+2=5/code/jolt
Submodule jolt added at 0cc7aa
9 changes: 9 additions & 0 deletions docs/crypto/2+2=5/code/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Author: @gio-d3141
# Dockerfile should build fine (will take a while) but the setup is kind of cursed, DM me if necessary

git clone git@github.com:a16z/jolt.git
cd jolt

# just the latest commit at time of writing
git checkout 0cc7aa31981ff8503fe256706d2aa9c320abd1cd
git apply ../diff.patch
1 change: 1 addition & 0 deletions docs/crypto/2+2=5/code/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
Loading

0 comments on commit 1fb95eb

Please sign in to comment.