Easily link web2 data with on-chain accounts via zk proofs over oauth-authenticated API data
use oidc_validator::IdentityProvider;use risc0_zkvm::{guest::env,sha::rust_crypto::{Digest as _, Sha256},};use serde::{Deserialize, Serialize};use std::io::Read;risc0_zkvm::guest::entry!(main);#[derive(Deserialize)]struct Input {iss: IdentityProvider,jwks: String,jwt: String,}#[derive(Serialize)]struct Output {email: String,public_key: String,expiration: String,issued_at: String,jwks: String,}fn main() {// Read user inputlet mut input_str: String = String::new();env::stdin().read_to_string(&mut input_str).expect("could not read input string");// Deserialize user inputlet input: Input = serde_json::from_str(&input_str).expect("could not deserialize input");// Validate the JWTlet (email, public_key, expiration, issued_at, jwks) = input.iss.validate(&input.jwt, &input.jwks).expect("failed to validate and decode");// Hash the email and issuer jwkslet email = hex::encode(Sha256::digest(email.as_bytes()));let jwks = hex::encode(Sha256::digest(jwks.as_bytes()));// Commit the output to the public journalenv::commit(&Output {email,public_key,expiration,issued_at,jwks,});}
Try out the program and generate an example proof that links your Ethereum address or passkey public key to your Google account.
By utilizing this app, you agree to our Terms of Service and Privacy Policy.