-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from zk-passport/prover-sha1
Add sha1 proof generation to modal prover
- Loading branch information
Showing
26 changed files
with
2,581 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
contracts/contracts/RegisterASCII.txt | ||
sdk/.env | ||
dist | ||
dist | ||
**/node_modules | ||
**/node_modules/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.