ZK interaction with frames with FID replay protection #145
Replies: 2 comments
-
A few variations that can be debated:
|
Beta Was this translation helpful? Give feedback.
-
Copied here the comments from the discussion on Farcaster. Sergey Potekhin - Can you provide more details about how the Semaphore is used here? Also, there is only one key for each FID which may become a problem considering that we have a decentralized protocol with a variety of clients. What if we associate a new key with a signer instead of an FID?
Sergey Potekhin - Awesome, thank you for the explanation! I was thinking is there a way to use existing keys instead of adding a new one? By somehow deriving all the properties from the signer Ed key. As I see in the current scheme each user needs to add a new key (=send a transaction), which seems like a lot of friction to me.
avi- although replay protection is important but this restriction (one key per fid) would mean user cannot use multiple privacy clients at the same time? also app developers would have to compete for users in a zero sum way which kinda sucks
|
Beta Was this translation helpful? Give feedback.
-
ZK frame interaction with FID replay protection
Motivation
[EulerLagrange on Warpcast](https://warpcast.com/eulerlagrange.eth/0xea60f72d)
ZK interaction with frames with become increasingly important as the protocol scales. Anonymous frame use is also a potential way the like/comment/recast to use frame phenomenon can be broken. Some existing frames may be broken if the user is anonymous, but this can be easily corrected for.
Dan hinted on the Bankless podcast that Merkle with add payments into Warpcast frames at some point. Payments through frames can enable malicious pricing since the frame can lookup a user’s wallet activity on-chain. They can also use an LLM to look for statements like “I have lots of warps” or “I just sold my OG Legacy NFT”.
Overview of problem
ZKPs for Farcaster signers is a lot more difficult than writing a circuit for Eddsa. Altogether, you may need:
The totality of all these things is actually quite difficult to implement. Without the constraint of fast proving times, there are many ways to approach this problem. EVM state/storage proofs can be considered, as well as hubs indexing signers into a more zk-friendly structure.
We may also want to minimize the changes to the hubs that is required, as it will require a lot more thinking/debate to make sure the tradeoffs are worth it.
Here are the goals that this FIP is optimizing around:
Changes to the Farcaster contract
In order to get FID replay protection, we propose adding a new key type and key type validator to the KeyRegistry contract. The validator’s job is to enforce that there is only one key for that type for each FID. This rule allows us to get fid replay protection in a fairly simple way.
Note that this new key type is purely for off-hub use. The hubs will NOT need to verify and store messages of this type.
As for details of the actual key type, we propose to use the Semaphore system designed and developed by the PSE team of the Ethereum Foundation ([What Is Semaphore? | Semaphore](https://docs.semaphore.pse.dev/)).
The semaphore system has done a lot of good work around anonymous voting that can be repurposed for this use case. It’s also a simple enough system where client-side proofs are very fast relative to things like a ZK eddsa verification.
Remaining problem
There is still an issue here that derives from the KeyRegistry contract not calling the validator when a key is revoked. As such, as the proposal is now there is no way to know if a semaphore identity has been revoked in the KeyRegistry contract.
How to solve the key revocation issue
We can have an off-chain system index revoked keys of this new type into a sparse merkle tree. Sparse Merkle trees are the best choice because:
To connect everything together, when you want to use a zkFid identity (semaphore) into interact with a frame, you provide two things:
A non-inclusion proof for a Merkle tree is better explained with a 1D analogy. Imagine you had a sorted array of integers, and you wanted to check if 5 is in the array. If I prove to you 4 and 6 are right next to each other, then it is a proof of the same. So a non-inclusion proof is simply two inclusion proofs. You need some kind of ordering in your Merkle-tree to support non-inclusion proofs. A sparse merkle tree is just a clever construction that makes it fast to update.
This gets us all the properties we set out to achieve in the earlier sections.
If this FIP is adopted, then the sparse merkle tree can be added to hubs to index. Although this is not a requirement to getting started. Potentially a frame can index the revocation tree instead of trusting someone else.
Beta Was this translation helpful? Give feedback.
All reactions