Skip to content

Vivek/redirect #6

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f7124ee
add boilerplate
RiverRuby Jul 25, 2024
1011a87
fix folder
RiverRuby Jul 25, 2024
561eb37
integrate fruits
AndrewCLu Jul 26, 2024
ce86b87
Merge pull request #1 from cursive-team/alu/fruits
AndrewCLu Jul 26, 2024
939a9a2
added new rings
RiverRuby Jul 26, 2024
9481aec
fix deploy bug
RiverRuby Jul 26, 2024
e6d4d8b
Merge pull request #2 from cursive-team/vivek/verify-cmac
RiverRuby Jul 26, 2024
7ac2213
fix some displays
RiverRuby Jul 26, 2024
7619972
Update README.md
RiverRuby Jul 26, 2024
b0c615f
Update README.md
RiverRuby Jul 26, 2024
a41a7e6
fixed fruits
RiverRuby Jul 27, 2024
040b40f
Merge pull request #3 from cursive-team/vivek/fix-fruits
RiverRuby Jul 27, 2024
466f5b4
add tweet link
RiverRuby Jul 27, 2024
a1fabee
add speaker
RiverRuby Jul 27, 2024
7b19b19
add login link
RiverRuby Jul 27, 2024
3528978
add new rings
RiverRuby Jul 27, 2024
d628a89
add talk data
RiverRuby Jul 27, 2024
6238ad3
add back the new user key code
RiverRuby Jul 27, 2024
e54f882
Merge pull request #4 from cursive-team/vivek/add-talks
RiverRuby Jul 27, 2024
d3ab74c
add talk ratings
RiverRuby Jul 27, 2024
6159bbf
fix registration
RiverRuby Jul 27, 2024
adb2cae
added top 3
RiverRuby Jul 29, 2024
df15894
remove folding
AndrewCLu Aug 3, 2024
81f81c3
Merge pull request #5 from cursive-team/alu/cleanup
AndrewCLu Aug 3, 2024
f301d0d
remove nova wasm
AndrewCLu Aug 3, 2024
1fbd4e3
Merge pull request #6 from cursive-team/alu/remove-nova
AndrewCLu Aug 3, 2024
7106f38
implement karma calculator
RiverRuby Aug 8, 2024
35ec9f9
fix build errors
RiverRuby Aug 8, 2024
75c1987
Merge pull request #7 from cursive-team/vivek/karma
RiverRuby Aug 8, 2024
3486e82
fix psi
AndrewCLu Aug 29, 2024
e89283a
Merge pull request #9 from cursive-team/alu/fix-psi
AndrewCLu Aug 29, 2024
911d1ce
fixed loading size and added TG and Daimo
RiverRuby Aug 30, 2024
7d11c89
fix PSI bugs
RiverRuby Aug 30, 2024
7dd6857
add social sharing without login
RiverRuby Aug 30, 2024
588d1a5
Merge pull request #10 from cursive-team/vivek/demo-fixes
RiverRuby Aug 30, 2024
9e212db
redirect api
RiverRuby Nov 15, 2024
f9b5337
fix
RiverRuby Nov 15, 2024
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
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ ENABLE_SIG_CARDS="true"
NEXT_PUBLIC_SUPABASE_URL=""
NEXT_PUBLIC_SUPABASE_ANON_KEY=""
KEYGEN_PASSWORD="password"
NEXT_PUBLIC_NOVA_BUCKET_URL="https://bjj-ecdsa-nova.us-southeast-1.linodeobjects.com/depth_9"
NEXT_PUBLIC_NOVA_INDEXDB_NAME="zksummit_folded"
NEXT_PUBLIC_ENABLE_METRICS="false"
42 changes: 1 addition & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1 @@
# ZK Summit 11 x Cursive

This app is built for [ZK Summit 11](https://www.zksummit.com/) in Athens. Every attendee will get an NFC card alongside their badge, and additional NFC cards will be placed in front of rooms where talks and workshops are held. Tapping another attendee's card allows you to see their contact information, as well as receive a digital signature that verifiably represents the fact that you met them. Tapping a card associated with a talk gives you a digital signature proving you attended that talk. There are 3 main things you can do with these signatures: make zero knowledge proofs, privately compute the things you've done in common with someone else, and aggregate the signatures into one big proof of your entire event experience - ZK Summit Folded!

## Zero Knowledge Proofs

There are 3 types of zero knowledge proofs an attendee can make at ZK Summit 11:

1. Prove you met 10 other attendees at the event
2. Prove you attended 5 talks
3. Prove you met 3 speakers

These proofs serve as basic examples of what's possible from verifiably digitizing in-person interactions, but one can generalize to far more complicated statements! For each proof we generate a merkle tree of all the signature public keys corresponding to the set of people/talks that comprise a proof. When a user makes a proof, lets say for showing they attended 5 talks, they are demonstrating the statement "I have 5 distinct signatures originating from different public keys within the merkle tree of talks". Notably, it is never revealed **which** talks they attended, and the signatures themselves always remain private.

#### Proving stack

To go a bit deeper, the actual proof being generated is a combination of a ECDSA signature proof + a Merkle membership proof. We use the [Baby Jubjub](https://eips.ethereum.org/EIPS/eip-2494) elliptic curve for ECDSA - having a representation in Twisted Edwards form allows complete addition formulae which reduce the number of constraints in our circuit - the circuits and proving code can be found [here](https://github.com/cursive-team/babyjubjub-ecdsa/tree/main). To avoid wrong field arithmetic and greatly save constraints, we use the [efficient ECDSA representation](https://personaelabs.org/posts/efficient-ecdsa-1/) from Personae.

#### Nullifiers

To prevent signatures from being reused, we make use of [nullifiers](https://nmohnblatt.github.io/zk-jargon-decoder/definitions/nullifier.html). Each attendee and location requirement is associated with a random value. When a signature is fed into the circuit, it is hashed with this random value, and the resulting output is known as the nullifier. We store these nullifiers, and if someone tries to use the same signature for a given requirement, they will deterministically produce the same nullifier, and we can invalidate their proof.

## Private Set Intersection (PSI) with Fully Homomorphic Encryption (FHE)

After collecting a few signatures each, two attendees can privately see which people they've both met and talks they've both attended. This is known as computing the Private Set Intersection of their two collections of signatures. At a high level, both users generate bit vectors corresponding to the list of all possible public keys that can be collected. A 1 represents that the user has collected a signature corresponding to that public key, a 0 represents the fact that they have not. Both users engage in a two-party computation to encrypt their respective bit vectors. Then, they compute the Hadamard product of the two encrypted bit vectors. Finally, they perform another two-party computation to decrypt the overlap bit vector and are left with the indices of the public keys they have collected in common. PSI was implemented by our good friends at [Gauss](https://github.com/gausslabs), you can see the code [here](https://github.com/gausslabs/MP-PSI).

#### Ensuring integrity of FHE inputs

You might have noticed one flaw in the PSI computation above. Namely, a user can simply claim that they have collected a signature from every single public key, i.e. they have a bit vector of all 1's. After running PSI, they would then know exactly what public keys the other user has collected. The solution to this is to have each user additionally include a zero knowledge proof that their bit vector was computed correctly, i.e. with valid signatures! In addition, it is important to ensure that both users perform valid encryptions of their data, as the FHE ciphertext must be well formed. This is solved by a tool like [Greco](https://github.com/privacy-scaling-explorations/greco), which allows the user to generate a zero knowledge proof that encryption was performed correctly. Due to time limitations, we were not able to implement either of these improvements for ZK Summit 11 - but they will be fun explorations for the future!

## ZK Summit Folded

One of the more exciting additions to this activation is ZK Summit Folded - a play on Spotify Wrapped, but using folding schemes. Folding schemes are an efficient way to aggregate proofs about a particularly structured type of statement. In our case, the statement is about the signatures one collects - "I have a signature corresponding to a public key, and this public key represents one of the attendees of ZK Summit 11". Folding schemes allow a user to produce a single proof that represent the aggregate of multiple of these statements, i.e. "I have 100 signatures corresponding to different public keys, and these public keys all represent attendees of ZK Summit 11". The beauty of folding schemes compared to say, naive Groth 16 proofs, is 1. you can **incrementally** generate this folding proof - every time you get a new signature, you can build the next step of the proof, instead of requiring knowledge of all the signatures at one time, and 2. the proof size is constant **irrespective** of the number of signatures you are proving - showing you have 100 attendee signatures results in a proof of the same size as showing you have 1000.

#### Proving stack

We are using the [Nova](https://eprint.iacr.org/2021/370) folding scheme, which notably is not state of the art, but has the most robust tooling at the moment (we would love to experiment with implementations of more recent folding work). [Nova-Scotia](https://github.com/nalinbhardwaj/Nova-Scotia) allows us to take our existing circom circuits and express them in a format that [Nova](https://github.com/microsoft/Nova) understands. The implementation of folding schemes for this app was done by our friends at [Mach34](https://mach34.space/).

## Interested in more projects like this?

[Cursive](http://cursive.team) is a cryptography and design lab building human-first applications of signed data. The code for the web app is all [open-source](https://github.com/cursive-team/zk-summit). If you’re interested in practical applications of digital signatures or advanced cryptography and would like to chat and/or collaborate, please reach out!
# MPC Starter
25 changes: 11 additions & 14 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@ const nextConfig = {
reactStrictMode: true,
webpack: (config) => {
// Needed to make snarkJs work client side
config.resolve.fallback = { fs: false, readline: false };
config.resolve.fallback = {
net: false,
tls: false,
fs: false,
readline: false,
};
return config;
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'picsum.photos',
},
],
},
headers: async () => {
// needed to allow calls by wasm to remote resources
return [
{
source: '/(.*)',
source: "/(.*)",
headers: [
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin',
key: "Cross-Origin-Opener-Policy",
value: "same-origin",
},
{
key: 'Cross-Origin-Embedder-Policy',
value: 'require-corp',
key: "Cross-Origin-Embedder-Policy",
value: "require-corp",
},
],
},
Expand Down
Loading