Merge branch 'codex-storage:master' into hash_benchmark

This commit is contained in:
Manish Kumar 2023-12-13 19:19:35 +05:30 committed by GitHub
commit 8115ec38b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 23 additions and 24 deletions

8
base-image/Dockerfile Executable file → Normal file
View File

@ -4,7 +4,7 @@ SHELL ["/bin/bash", "--rcfile", "/root/.bashrc", "-lc"]
# === install some basic tools and libs ===
RUN apt-get -y update && \
apt-get -y install curl wget vim less build-essential git \
apt-get -y install curl wget vim less build-essential git \
libgmp-dev zlib1g zlib1g-dev pkg-config libffi-dev \
libdigest-sha3-perl
@ -85,12 +85,10 @@ RUN cd /tmp && \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh ./install_ghcup && \
source /root/.ghcup/env && \
echo -e "\nsource /root/.ghcup/env" >>$HOME/.bashrc && \
ghcup --version >/zk/versions/ghcup.txt
ghcup --version >/zk/versions/ghcup.txt && \
rm /tmp/install_ghcup
RUN source /root/.ghcup/env && \
ghc --version >/zk/versions/ghc.txt && \
cabal --version >/zk/versions/cabal.txt && \
rm /tmp/install_ghcup && \
ghcup upgrade && \
ghcup install cabal 2.4.1.0 && \
ghcup set cabal 2.4.1.0 && \

0
base-image/README.md Executable file → Normal file
View File

0
base-image/ptau/README.md Executable file → Normal file
View File

View File

@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
void generate(megabytes) {
void generate(int megabytes) {
unsigned char buffer[257];
for(int i=0;i<256;i++) { buffer[i] = 1+(i%255); }

View File

@ -6,6 +6,7 @@ ZIK_PATH="../../../external/zikkurat-algebra/"
mkdir -p build
gcc -O3 \
-I ${ZIK_PATH}/lib/cbits/ \
-I ${ZIK_PATH}/lib/cbits/bigint/ \
-I ${ZIK_PATH}/lib/cbits/curves/fields/std/ \
-I ${ZIK_PATH}/lib/cbits/curves/fields/mont/ \

View File

@ -6,6 +6,7 @@ Poseidon2 arithmetic hash function, specialized to the BN128 scalar field and t=
compile with:
gcc -O3 \
-I ../lib/cbits/ \
-I ../lib/cbits/bigint/ \
-I ../lib/cbits/curves/fields/std/ \
-I ../lib/cbits/curves/fields/mont/ \

View File

@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
void generate(megabytes) {
void generate(int megabytes) {
unsigned char buffer[257];
for(int i=0;i<256;i++) { buffer[i] = 1+(i%255); }

@ -1 +1 @@
Subproject commit e2b0fde371dad9a8be2085ca809d08e11bf4eba9
Subproject commit 96e349786bd004e64a9cf50e0122f89863b24e92

View File

@ -5,7 +5,7 @@ ZKBENCH_INPUT_SIZE=256
fi
if [ -z ${ZKBENCH_WHICH} ]; then
ZKBENCH_WHICH="hash_sponge"
ZKBENCH_WHICH="hash_sponge_rate1"
fi
ORIG=`pwd`
@ -16,7 +16,7 @@ gcc -O3 generate_input.c -o build/generate_input || { echo "gcc failed"; exit 10
#NAME=${ZKBENCH_WHICH}
NAME="hash"
echo ${NAME}.circom.template \
cat ${NAME}.circom.template \
| sed "s/ZKBENCH_INPUT_SIZE/${ZKBENCH_INPUT_SIZE}/g" \
| sed "s/ZKBENCH_WHICH/${ZKBENCH_WHICH}/g" \
>build/${NAME}.circom

View File

@ -33,7 +33,7 @@ function CeilLog2(n) {
return (n==0) ? 0 : (1 + FloorLog2(n-1));
}
template Bench_hash_merkle2(n) {
template Bench_hash_merkle(n) {
var log2n = CeilLog2(n);
assert( (1<<log2n) == n ); // for now this only works for power-of-two sized inputs

View File

@ -4,22 +4,21 @@ if [ -z ${ZKBENCH_PROVER} ]; then
ZKBENCH_PROVER="snarkjs"
fi
if [ -z ${ZKBENCH_WHICH} ]; then
ZKBENCH_WHICH="hash_sponge"
fi
# if [ -z ${ZKBENCH_WHICH} ]; then
# ZKBENCH_WHICH="hash_sponge_rate1"
# fi
ORIG=`pwd`
cd build
NAME="hash"
echo "generating proof with ${ZKBENCH_PROVER}"
case $ZKBENCH_PROVER in
snarkjs)
NAME="${ZKBENCH_WHICH}"
snarkjs groth16 prove ${NAME}_prover.zkey ${NAME}_witness.wtns ${NAME}_proof.json ${NAME}_public.json
;;
rapidsnark)
NAME="${ZKBENCH_WHICH}"
rapidsnark ${NAME}_prover.zkey ${NAME}_witness.wtns ${NAME}_proof.json ${NAME}_public.json
;;
*)

View File

@ -1,8 +1,8 @@
#!/bin/bash
if [ -z ${ZKBENCH_WHICH} ]; then
ZKBENCH_WHICH="hash_sponge"
fi
# if [ -z ${ZKBENCH_WHICH} ]; then
# ZKBENCH_WHICH="hash_sponge_rate1"
# fi
ORIG=`pwd`
ROOT="${ORIG}/../../../../"
@ -10,7 +10,7 @@ ROOT="${ORIG}/../../../../"
cd build
echo "circuit-specific ceremony..."
NAME="${ZKBENCH_WHICH}"
NAME="hash"
snarkjs groth16 setup ${NAME}.r1cs ${ROOT}/ceremony/ceremony.ptau ${NAME}_0000.zkey
echo "some_entropy" | snarkjs zkey contribute ${NAME}_0000.zkey ${NAME}_0001.zkey --name="1st Contributor Name"
rm ${NAME}_0000.zkey

View File

@ -4,9 +4,9 @@ if [ -z ${ZKBENCH_INPUT_SIZE} ]; then
ZKBENCH_INPUT_SIZE=256
fi
if [ -z ${ZKBENCH_WHICH} ]; then
ZKBENCH_WHICH="hash_sponge"
fi
# if [ -z ${ZKBENCH_WHICH} ]; then
# ZKBENCH_WHICH="hash_sponge_rate1"
# fi
ORIG=`pwd`
@ -16,7 +16,7 @@ echo "generating input..."
./generate_input $ZKBENCH_INPUT_SIZE >input.json
echo "generating witness... (WASM)"
NAME="${ZKBENCH_WHICH}"
NAME="hash"
cd ${NAME}_js
node generate_witness.js ${NAME}.wasm ../input.json ../${NAME}_witness.wtns || { echo "witness gen failed"; exit 101; }
cd ..