mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
Merge pull request #153 from zk-passport/prover-sha1
Add sha1 proof generation to modal prover
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../../dsc.circom";
|
||||
|
||||
component main { public [ merkle_root ] } = DSC(1664,121 ,17 ,121, 34, 256, 12);
|
||||
@@ -1,5 +1,5 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../../dsc_sha1WithRSAEncryption.circom";
|
||||
include "../../dsc/dsc_sha1_rsa.circom";
|
||||
|
||||
component main { public [ merkle_root ] } = DSC_sha1WithRSAEncryption(1664,121 ,17 ,121, 34, 256, 12);
|
||||
component main { public [ merkle_root ] } = DSC_SHA1_RSA(1664,121 ,17 ,121, 34, 256, 12);
|
||||
5
circuits/circuits/tests/dsc/dsc_sha256_rsa_4096.circom
Normal file
5
circuits/circuits/tests/dsc/dsc_sha256_rsa_4096.circom
Normal file
@@ -0,0 +1,5 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../../dsc/dsc_sha256_rsa.circom";
|
||||
|
||||
component main { public [ merkle_root ] } = DSC_SHA256_RSA(1664,121 ,17 ,121, 34, 256, 12);
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Record the start time
|
||||
START_TIME=$(date +%s)
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
if [ ! -f powersOfTau28_hez_final_22.ptau ]; then
|
||||
echo "Download power of tau...."
|
||||
wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_22.ptau
|
||||
echo "Finished download!"
|
||||
else
|
||||
echo "Powers of tau file already downloaded... Skip download action!"
|
||||
fi
|
||||
cd ..
|
||||
|
||||
echo "compiling circuit"
|
||||
circom circuits/tests/certificates/dsc_4096.circom -l node_modules -l ./node_modules/@zk-kit/binary-merkle-root.circom/src -l ./node_modules/circomlib/circuits --r1cs --O1 --wasm -c --output build
|
||||
|
||||
echo "building zkey"
|
||||
yarn snarkjs groth16 setup build/dsc_4096.r1cs build/powersOfTau28_hez_final_22.ptau build/dsc_4096.zkey
|
||||
|
||||
if command -v openssl &> /dev/null
|
||||
then
|
||||
RAND_STR=$(openssl rand -hex 64)
|
||||
else
|
||||
RAND_STR="random text"
|
||||
fi
|
||||
|
||||
echo "building vkey"
|
||||
echo $RAND_STR | yarn snarkjs zkey contribute build/dsc_4096.zkey build/dsc_4096_final.zkey
|
||||
yarn snarkjs zkey export verificationkey build/dsc_4096_final.zkey build/dsc_4096_vkey.json
|
||||
|
||||
yarn snarkjs zkey export solidityverifier build/dsc_4096_final.zkey build/Verifier_dsc_4096.sol
|
||||
sed -i '' 's/Groth16Verifier/Verifier_dsc_4096/g' build/Verifier_dsc_4096.sol
|
||||
cp build/Verifier_dsc_4096.sol ../contracts/contracts/Verifier_dsc_4096.sol
|
||||
echo "copied Verifier_dsc_4096.sol to contracts"
|
||||
|
||||
echo "Build completed in $(($(date +%s) - $START_TIME)) seconds"
|
||||
|
||||
echo "file sizes:"
|
||||
echo "Size of dsc_4096.r1cs: $(wc -c <build/dsc_4096.r1cs) bytes"
|
||||
echo "Size of dsc_4096.wasm: $(wc -c <build/dsc_4096_js/dsc_4096.wasm) bytes"
|
||||
echo "Size of dsc_4096_final.zkey: $(wc -c <build/dsc_4096_final.zkey) bytes"
|
||||
69
circuits/scripts/build_dsc_circuit_2048.sh
Executable file
69
circuits/scripts/build_dsc_circuit_2048.sh
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Record the start time
|
||||
TOTAL_START_TIME=$(date +%s)
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
if [ ! -f powersOfTau28_hez_final_20.ptau ]; then
|
||||
echo -e "\033[34mDownload power of tau....\033[0m"
|
||||
wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_20.ptau
|
||||
echo -e "\033[32mFinished download!\033[0m"
|
||||
else
|
||||
echo -e "\033[90mPowers of tau file already downloaded\033[0m"
|
||||
fi
|
||||
cd ..
|
||||
|
||||
build_circuit() {
|
||||
local CIRCUIT_NAME=$1
|
||||
local START_TIME=$(date +%s)
|
||||
|
||||
echo -e "\033[34mcompiling circuit: $CIRCUIT_NAME\033[0m"
|
||||
circom circuits/tests/dsc/${CIRCUIT_NAME}.circom -l node_modules -l ./node_modules/@zk-kit/binary-merkle-root.circom/src -l ./node_modules/circomlib/circuits --r1cs --O1 --wasm -c --output build
|
||||
|
||||
echo -e "\033[34mbuilding zkey\033[0m"
|
||||
yarn snarkjs groth16 setup build/${CIRCUIT_NAME}.r1cs build/powersOfTau28_hez_final_20.ptau build/${CIRCUIT_NAME}.zkey
|
||||
|
||||
if command -v openssl &> /dev/null
|
||||
then
|
||||
RAND_STR=$(openssl rand -hex 64)
|
||||
else
|
||||
RAND_STR="random text"
|
||||
fi
|
||||
|
||||
echo -e "\033[34mbuilding vkey\033[0m"
|
||||
echo $RAND_STR | yarn snarkjs zkey contribute build/${CIRCUIT_NAME}.zkey build/${CIRCUIT_NAME}_final.zkey
|
||||
yarn snarkjs zkey export verificationkey build/${CIRCUIT_NAME}_final.zkey build/${CIRCUIT_NAME}_vkey.json
|
||||
|
||||
yarn snarkjs zkey export solidityverifier build/${CIRCUIT_NAME}_final.zkey build/Verifier_${CIRCUIT_NAME}.sol
|
||||
sed -i '' "s/Groth16Verifier/Verifier_${CIRCUIT_NAME}/g" build/Verifier_${CIRCUIT_NAME}.sol
|
||||
cp build/Verifier_${CIRCUIT_NAME}.sol ../contracts/contracts/Verifier_${CIRCUIT_NAME}.sol
|
||||
echo -e "\033[34mcopied Verifier_${CIRCUIT_NAME}.sol to contracts\033[0m"
|
||||
|
||||
echo -e "\033[32mBuild of $CIRCUIT_NAME completed in $(($(date +%s) - START_TIME)) seconds\033[0m"
|
||||
|
||||
echo "file sizes:"
|
||||
echo -e "\033[34mSize of ${CIRCUIT_NAME}.r1cs: $(wc -c <build/${CIRCUIT_NAME}.r1cs) bytes\033[0m"
|
||||
echo -e "\033[34mSize of ${CIRCUIT_NAME}.wasm: $(wc -c <build/${CIRCUIT_NAME}_js/${CIRCUIT_NAME}.wasm) bytes\033[0m"
|
||||
echo -e "\033[34mSize of ${CIRCUIT_NAME}_final.zkey: $(wc -c <build/${CIRCUIT_NAME}_final.zkey) bytes\033[0m"
|
||||
}
|
||||
|
||||
# Define circuits and their deployment flags
|
||||
# name:deploy_flag
|
||||
CIRCUITS=(
|
||||
"dsc_sha256_rsapss_2048:true"
|
||||
"dsc_sha256_rsa_2048:true"
|
||||
"dsc_sha1_rsa_2048:true"
|
||||
)
|
||||
|
||||
for circuit in "${CIRCUITS[@]}"; do
|
||||
IFS=':' read -r CIRCUIT_NAME DEPLOY_FLAG <<< "$circuit"
|
||||
if [ "$DEPLOY_FLAG" = "true" ]; then
|
||||
echo -e "\033[34mBuilding circuit $CIRCUIT_NAME\033[0m"
|
||||
build_circuit "$CIRCUIT_NAME"
|
||||
else
|
||||
echo -e "\033[90mSkipping build for $CIRCUIT_NAME\033[0m"
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "\033[32mTotal build completed in $(($(date +%s) - TOTAL_START_TIME)) seconds\033[0m"
|
||||
68
circuits/scripts/build_dsc_circuit_4096.sh
Executable file
68
circuits/scripts/build_dsc_circuit_4096.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Record the start time
|
||||
TOTAL_START_TIME=$(date +%s)
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
if [ ! -f powersOfTau28_hez_final_22.ptau ]; then
|
||||
echo -e "\033[34mDownload power of tau....\033[0m"
|
||||
wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_22.ptau
|
||||
echo -e "\033[32mFinished download!\033[0m"
|
||||
else
|
||||
echo -e "\033[90mPowers of tau file already downloaded\033[0m"
|
||||
fi
|
||||
cd ..
|
||||
|
||||
build_circuit() {
|
||||
local CIRCUIT_NAME=$1
|
||||
local START_TIME=$(date +%s)
|
||||
|
||||
echo -e "\033[34mcompiling circuit: $CIRCUIT_NAME\033[0m"
|
||||
circom circuits/tests/dsc/${CIRCUIT_NAME}.circom -l node_modules -l ./node_modules/@zk-kit/binary-merkle-root.circom/src -l ./node_modules/circomlib/circuits --r1cs --O1 --wasm -c --output build
|
||||
|
||||
echo -e "\033[34mbuilding zkey\033[0m"
|
||||
yarn snarkjs groth16 setup build/${CIRCUIT_NAME}.r1cs build/powersOfTau28_hez_final_22.ptau build/${CIRCUIT_NAME}.zkey
|
||||
|
||||
if command -v openssl &> /dev/null
|
||||
then
|
||||
RAND_STR=$(openssl rand -hex 64)
|
||||
else
|
||||
RAND_STR="random text"
|
||||
fi
|
||||
|
||||
echo -e "\033[34mbuilding vkey\033[0m"
|
||||
echo $RAND_STR | yarn snarkjs zkey contribute build/${CIRCUIT_NAME}.zkey build/${CIRCUIT_NAME}_final.zkey
|
||||
yarn snarkjs zkey export verificationkey build/${CIRCUIT_NAME}_final.zkey build/${CIRCUIT_NAME}_vkey.json
|
||||
|
||||
yarn snarkjs zkey export solidityverifier build/${CIRCUIT_NAME}_final.zkey build/Verifier_${CIRCUIT_NAME}.sol
|
||||
sed -i '' "s/Groth16Verifier/Verifier_${CIRCUIT_NAME}/g" build/Verifier_${CIRCUIT_NAME}.sol
|
||||
cp build/Verifier_${CIRCUIT_NAME}.sol ../contracts/contracts/Verifier_${CIRCUIT_NAME}.sol
|
||||
echo -e "\033[34mcopied Verifier_${CIRCUIT_NAME}.sol to contracts\033[0m"
|
||||
|
||||
echo -e "\033[32mBuild of $CIRCUIT_NAME completed in $(($(date +%s) - START_TIME)) seconds\033[0m"
|
||||
|
||||
echo "file sizes:"
|
||||
echo -e "\033[34mSize of ${CIRCUIT_NAME}.r1cs: $(wc -c <build/${CIRCUIT_NAME}.r1cs) bytes\033[0m"
|
||||
echo -e "\033[34mSize of ${CIRCUIT_NAME}.wasm: $(wc -c <build/${CIRCUIT_NAME}_js/${CIRCUIT_NAME}.wasm) bytes\033[0m"
|
||||
echo -e "\033[34mSize of ${CIRCUIT_NAME}_final.zkey: $(wc -c <build/${CIRCUIT_NAME}_final.zkey) bytes\033[0m"
|
||||
}
|
||||
|
||||
# Define circuits and their deployment flags
|
||||
# name:deploy_flag
|
||||
CIRCUITS=(
|
||||
"dsc_sha256_rsa_4096:false"
|
||||
"dsc_sha1_rsa_4096:false"
|
||||
)
|
||||
|
||||
for circuit in "${CIRCUITS[@]}"; do
|
||||
IFS=':' read -r CIRCUIT_NAME DEPLOY_FLAG <<< "$circuit"
|
||||
if [ "$DEPLOY_FLAG" = "true" ]; then
|
||||
echo -e "\033[34mBuilding circuit $CIRCUIT_NAME\033[0m"
|
||||
build_circuit "$CIRCUIT_NAME"
|
||||
else
|
||||
echo -e "\033[90mSkipping build for $CIRCUIT_NAME\033[0m"
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "\033[32mTotal build completed in $(($(date +%s) - TOTAL_START_TIME)) seconds\033[0m"
|
||||
Reference in New Issue
Block a user