This project aims to on-ramp off-chain identities.
This project is loosely based on a non-funded ZkIgnite proposal, which in turn is based on Bonsai Pay and zkLogin. We mostly leave the asset management things out and focus on the identity.
The project is divided into two phases: the first phase aims to implement the basic functionality, in a PoC style. The second phase adds required ZK privacy and succinctness.
The flow goes something like this:
- User authenticates with their web2 identity provider, such as Google. The authentication flow is just what the user is used to. The only difference is that we embed an on-chain address (public key) into the flow (in the nonce field).
- User gets a JWT authentication token that has the on-chain address embedded in it.
- The JWT token is sent on-chain
- On-chain smart contract verifies its signature (using a stored public key for the identity provider) and associates the web2 identity with the web3 address.
Note that this phase implements a very insecure an inefficient version, and can be considered a Proof of Concept.
Mainly it's not a good idea to upload a full functioning identity token to an on-chain contract. And it's not a good idea to upload the full token when only a portion of it is needed in reality.
This phase aims to bring the project beyond the PoC phase and to make it more realistic to use.
Add ZK proofs to:
- Add ZK privacy. Instead of uploading the real token, only generate a proof of the needed parts and send the proof.
- Related to the previous point: generating a proof makes the process also more succinct. Two birds with one stone.
- Some of the JWT token verification on-chain is expensive. Do some of it off-chain and just prove it.
There are a few open issues that don't have a good solution thought of, currently.
- The used tokens are signed by a private key from the identity provider. The identity provider changes their keys, making the old data obsolete. The cycle can be as fast as a week. This means the on-chain verification keys need to be updated as well. How to do this?
- How to handle timestamps in the tokens. Which time to use and how to handle token expiry.
- How to handle reuse of old JWT tokens. Maybe we need nullifiers?
For running this locally, you a Twitch account with API setup.
Go to the Twitch Console at https://dev.twitch.tv/console/apps . Register a new application:
- URL: http://localhost:3000
- Client type: confidential
Change the "audience" in index.tsx to use your Twitch client ID.
Run the frontend from the frontend
folder with npm run dev
, open the site and login with your Twitch account.