RISC Zero

Demos

Proof of Account

Easily link web2 data with on-chain accounts via zk proofs over oauth-authenticated API data

👨‍💻 The zkVM Guest Code

The RISC Zero zkVM enables developers to write simple programs in vanilla Rust, instead of specialized languages for writing circuits. This gives developers the power of Rust crates, control flow, and other conveniences of general purpose languages as demonstrated in the simple example program below 👇. In just a few lines of code, a JWT is verified using the open source
oidc_validator
crate.
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 input
let mut input_str: String = String::new();
env::stdin()
.read_to_string(&mut input_str)
.expect("could not read input string");
// Deserialize user input
let input: Input = serde_json::from_str(&input_str).expect("could not deserialize input");
// Validate the JWT
let (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 jwks
let email = hex::encode(Sha256::digest(email.as_bytes()));
let jwks = hex::encode(Sha256::digest(jwks.as_bytes()));
// Commit the output to the public journal
env::commit(&Output {
email,
public_key,
expiration,
issued_at,
jwks,
});
}

💅 The Demo

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.

Built by RISC ZeroDocsGitHub