Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix twitter: contracts and frontend #39

Merged
merged 25 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cbf9422
wrote bad solidity test
Divide-By-0 Feb 27, 2023
7f7b9c1
fixed typo in old test, pairing check still fails
Divide-By-0 Feb 28, 2023
11ce6b9
Merge branch 'main' into fix/solidity
Divide-By-0 Mar 1, 2023
c6a5a77
verification passes after swapping proof b signal order
Divide-By-0 Mar 1, 2023
79ffc26
Merge branch 'main' into fix/solidity
Divide-By-0 Mar 1, 2023
ae19f76
added max message len as an arg to unpacking, added msg.sender pranki…
Divide-By-0 Mar 1, 2023
c4b4277
updated circuit to reveal less email info but still some
Divide-By-0 Mar 1, 2023
d6f5532
fix circuit names
Divide-By-0 Mar 1, 2023
58c0ca8
fixed array bound
Divide-By-0 Mar 2, 2023
f5d8518
fixed assert
Divide-By-0 Mar 2, 2023
cfefa36
add snarkjs forks changing and yarn.lock rewrite to both zkey script
Divide-By-0 Mar 3, 2023
845fa89
fix paths
Divide-By-0 Mar 3, 2023
b852b95
made entropy match between the two zkey generations
Divide-By-0 Mar 3, 2023
7476faa
pass tests
Divide-By-0 Mar 5, 2023
0621d97
removed hardcoded 7 for packed in contracts
Divide-By-0 Mar 6, 2023
c786141
midway thru editing stuff, revert this commit
Divide-By-0 Mar 7, 2023
2cb8549
local proofgen works, tests updated so test email works, upload typo …
Divide-By-0 Mar 7, 2023
319e4b1
got frontend wagmi working, but nft image doesnt show up
Divide-By-0 Mar 8, 2023
b7c7f40
fix small style nits and phrasings on frontend
Divide-By-0 Mar 8, 2023
1a3d0bd
add more wordy phrasings
Divide-By-0 Mar 8, 2023
e35efae
added svg files, tests pass and print an svg
Divide-By-0 Mar 8, 2023
b95b60b
minor contract comments
Divide-By-0 Mar 8, 2023
4f8778f
reduced conrtact size and deployed and updated frontend pointer
Divide-By-0 Mar 8, 2023
1d07079
punt email circuit change to later
Divide-By-0 Mar 8, 2023
c7a44aa
Merge branch 'main' into fix/twitter
Divide-By-0 Mar 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ cd dizkus-scripts/
# optional: ./6_gen_proof_rapidsnark.sh

# This part is to upload the zkeys, not critical
# Remember to change bucket_name in upload_to_s3.py
aws configure # Only needs to be run once
pip3 install boto3
python3 upload_to_s3.py
Expand Down Expand Up @@ -371,10 +372,10 @@ Since circom is GPL, we are forced to use the GPL license, which is still a high

## To-Do

- Make the frontend Solidity calls work
- Make a general method to get formatted signatures and bodies from all email clients
- Make versions for different size RSA keys
- Add ENS DNSSEC code (possibly SNARKed), so anyone can add a website's RSA key via DNS record
- Design the NFT/POAP to have the user's domain/verified identity on it
- Make a testnet faucet as a PoC for Sybil resistance and to get developers interested
- Dynamically tradeoff between gzip (2x faster decompression) and xz (30% smaller file size): https://www.rootusers.com/gzip-vs-bzip2-vs-xz-performance-comparison/ based on internet speed (i.e. minimize download time + unzip time)
- Make the frontend Solidity calls work
- Make a general method to get formatted signatures and bodies from all email clients
- Make versions for different size RSA keys
- Add ENS DNSSEC code (possibly SNARKed), so anyone can add a website's RSA key via DNS record
- Design the NFT/POAP to have the user's domain/verified identity on it
- Make a testnet faucet as a PoC for Sybil resistance and to get developers interested
- Dynamically tradeoff between gzip (2x faster decompression) and xz (30% smaller file size): https://www.rootusers.com/gzip-vs-bzip2-vs-xz-performance-comparison/ based on internet speed (i.e. minimize download time + unzip time)
165 changes: 0 additions & 165 deletions circuits/email_public.json

This file was deleted.

26 changes: 20 additions & 6 deletions dizkus-scripts/3_gen_both_zkeys.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ fi

# First, chunked snarkjs
yarn remove snarkjs
mv ../yarn.lock ../yarn.lock_old
rm -rf ../node_modules_old
mv ../node_modules ../node_modules_old
yarn add snarkjs@git+https://github.com/vb7401/snarkjs.git#24981febe8826b6ab76ae4d76cf7f9142919d2b8
yarn

echo "****GENERATING ZKEY 0****"
start=$(date +%s)
set -x
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs groth16 setup "$R1CS_FILE" "$PHASE1" "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_0.zkey -e $ENTROPY1
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs groth16 setup "$R1CS_FILE" "$PHASE1" "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_0.zkey -e=$ENTROPY1
{ set +x; } 2>/dev/null
end=$(date +%s)
echo "DONE ($((end - start))s)"
Expand All @@ -30,7 +34,7 @@ echo
echo "****GENERATING ZKEY 1****"
start=$(date +%s)
set -x
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs zkey contribute "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_0.zkey "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_1.zkey --name="1st Contributor Name" -v $ENTROPY2
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs zkey contribute "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_0.zkey "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_1.zkey --name="1st Contributor Name" -e=$ENTROPY2
{ set +x; } 2>/dev/null
end=$(date +%s)
echo "DONE ($((end - start))s)"
Expand All @@ -40,20 +44,23 @@ echo "****GENERATING FINAL ZKEY****"
start=$(date +%s)
set -x
# hashlib.sha256(b"sampritiaayush").hexdigest().upper()
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs zkey beacon "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_1.zkey "$BUILD_DIR"/"$CIRCUIT_NAME".zkey AFAE5390CE7790A5EFA03DD74189A4C56DDA1AB8D3D322142C4AE3A14858D6E0 10 -n="Final Beacon phase2"
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs zkey beacon "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_1.zkey "$BUILD_DIR"/"$CIRCUIT_NAME".zkey $BEACON 10 -n="Final Beacon phase2"
{ set +x; } 2>/dev/null
end=$(date +%s)
echo "DONE ($((end - start))s)"
echo

# Then, nonchunked snarkjs
yarn remove snarkjs
mv ../yarn.lock ../yarn.lock_old2
rm -rf ../node_modules_old2
mv ../node_modules ../node_modules_old2
yarn add snarkjs@latest

echo "****GENERATING ZKEY NONCHUNKED 0****"
start=$(date +%s)
set -x
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs groth16 setup "$R1CS_FILE" "$PHASE1" "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_0.zkey -e $ENTROPY1
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs groth16 setup "$R1CS_FILE" "$PHASE1" "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_0.zkey -e=$ENTROPY1
{ set +x; } 2>/dev/null
end=$(date +%s)
echo "DONE ($((end - start))s)"
Expand All @@ -62,7 +69,7 @@ echo
echo "****GENERATING ZKEY NONCHUNKED 1****"
start=$(date +%s)
set -x
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs zkey contribute "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_0.zkey "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_1.zkey --name="1st Contributor Name" -v -e $ENTROPY2
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs zkey contribute "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_0.zkey "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_1.zkey --name="1st Contributor Name" -v -e=$ENTROPY2
{ set +x; } 2>/dev/null
end=$(date +%s)
echo "DONE ($((end - start))s)"
Expand All @@ -71,8 +78,15 @@ echo
echo "****GENERATING ZKEY NONCHUNKED FINAL****"
start=$(date +%s)
set -x
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs zkey beacon "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_1.zkey "$BUILD_DIR"/"$CIRCUIT_NAME"_nonchunked.zkey AFAE5390CE7790A5EFA03DD74189A4C56DDA1AB8D3D322142C4AE3A14858D6E0 10 -n="Final Beacon phase2"
NODE_OPTIONS='--max-old-space-size=56000' node ../node_modules/.bin/snarkjs zkey beacon "$PARTIAL_ZKEYS"/"$CIRCUIT_NAME"_1.zkey "$BUILD_DIR"/"$CIRCUIT_NAME"_nonchunked.zkey $BEACON 10 -n="Final Beacon phase2"
{ set +x; } 2>/dev/null
end=$(date +%s)
echo "DONE ($((end - start))s)"
echo

yarn remove snarkjs
mv ../yarn.lock ../yarn.lock_old3
rm -rf ../node_modules_old3
mv ../node_modules ../node_modules_old3
yarn add snarkjs@git+https://github.com/vb7401/snarkjs.git#24981febe8826b6ab76ae4d76cf7f9142919d2b8
yarn
67 changes: 0 additions & 67 deletions dizkus-scripts/email.circom

This file was deleted.

1 change: 1 addition & 0 deletions dizkus-scripts/entropy.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ENTROPY1=
ENTROPY2=
BEACON=
2 changes: 1 addition & 1 deletion dizkus-scripts/upload_to_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def upload_to_s3(filename, dir=""):
with open(d ir + filename, 'rb') as file:
with open(dir + filename, 'rb') as file:
print("Starting upload...")
s3.upload_fileobj(file, bucket_name, filename, ExtraArgs={
'ACL': 'public-read', 'ContentType': 'binary/octet-stream'})
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ZK Email

ZK Email is an app for you to anonymously verifiy email signatures yet mask whatever
ZK Email is an app for you to anonymously verify email signatures yet mask whatever
data you would like. Each email can either be verified to be to/from specific domains
or subsets of domains, or have some specific text in the body. These can be used for
web2 interoperability, decentralized anonymous KYC, or interesting on-chain anonymity
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"test:e2e-zkp": "CI=true react-scripts test --runInBand --testPathPattern='e2e-dl-zkp' --reporters=default --reporters=jest-junit",
"eject": "react-scripts eject",
"compile": "node circuits/scripts/compile.js",
"compile-all": "npx tsx src/scripts/generate_input.ts && yarn compile email true"
"gen-input": "npx tsx src/scripts/generate_input.ts",
"compile-all": "yarn gen-input && yarn compile email true"
},
"eslintConfig": {
"extends": [
Expand Down
1 change: 0 additions & 1 deletion regex_to_circom/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Incoming Nodes
rev_graph = [[] for i in range(N)]
accept_nodes = set()

for i in range(N):
for k in graph_json[i]['edges']:
# assert len(k) == 1
Expand Down
1 change: 1 addition & 0 deletions src/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ src = 'src'
out = 'out'
libs = ['lib'] # See more config options https://github.com/foundry-rs/foundry/tree/master/config
remappings = ['ds-test=lib/ds-test/', 'forge-std/=lib/forge-std/']
libraries = ["src/NFTSVG.sol:NFTSVG:0xC2610931017f044EC88F6867842D5cD6a4A31B20", "src/hexStrings.sol:HexStrings:0xaA8989aFfba4D72B14959E92a132587C3FD4977F"]
Loading