Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2aa79ba
use new query endpoint
ash-burnt Nov 16, 2024
9e8940f
lint
ash-burnt Nov 16, 2024
9937ad4
zkemail compiles
ash-burnt Nov 18, 2024
e131ba4
update zkemail to use one contract for storing vkey
ash-burnt Feb 2, 2025
b86f122
outline test
ash-burnt Feb 2, 2025
02d3b1a
limit import from zkemail contract
ash-burnt Feb 2, 2025
c61a3bd
disable random
ash-burnt Feb 2, 2025
446c021
older edition
ash-burnt Feb 2, 2025
b5b0b86
feat: query chain for proof verification
Peartes Jun 11, 2025
f6afe31
feat: verify proof on-chain
Peartes Jun 16, 2025
3d73228
Feat: Added Zkemail as an authenticator
Kushal7788 Sep 30, 2025
5551a90
Updated zkemail authenticator verify method with additional params
Kushal7788 Sep 30, 2025
c23385b
Merge branch 'main' into feat/gnark-zkemail
Peartes Sep 30, 2025
7960d13
Refactor: Remove AuthenticatorNotFound error and related validation i…
Kushal7788 Sep 30, 2025
a46bb54
Merge branch 'feat/gnark-zkemail' into feat/zkemail-authenticator
Kushal7788 Oct 1, 2025
c98e190
Merge branch 'feat/gnark-zkemail' into feat/zkemail-authenticator
Kushal7788 Oct 1, 2025
3576b39
Merge pull request #83 from burnt-labs/feat/zkemail-authenticator
Kushal7788 Oct 1, 2025
30d544c
Updated the zk-email interface to match the dkim module
Kushal7788 Oct 22, 2025
717bb12
Merge pull request #87 from burnt-labs/chore/update-zkemail-interface
Kushal7788 Oct 23, 2025
7244130
Updated the Imports for cosmos sdk proto for zk-email auth
Kushal7788 Oct 24, 2025
09ec3fa
Custom Coswasm Optimiser Docker Image for compiling the contracts
Kushal7788 Oct 29, 2025
2707151
use cosmwasm_std to get little endian email_hash
edjroz Nov 6, 2025
862fce3
Removed zkemail verifier from the contract and updated params for gRP…
Kushal7788 Nov 13, 2025
f5ef0a3
Added allowed-email-hosts field in zk-email auth to whitelist hosts a…
Kushal7788 Nov 20, 2025
9806723
Merge pull request #91 from burnt-labs/zk-email-whitelisted-email-hosts
Kushal7788 Nov 21, 2025
42e720d
Updated Query Types for zk-email verifier
Kushal7788 Nov 27, 2025
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
540 changes: 412 additions & 128 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ phf = { version = "0.11.2", features = ["macros"] }
rsa = { version = "0.9.2" }
getrandom = { version = "0.2.10", features = ["custom"] }
p256 = {version = "0.13.2", features = ["ecdsa-core", "arithmetic", "serde"]}
cosmos-sdk-proto = {package = "xion-cosmos-sdk-proto", version = "0.26.1", default-features = false, features = ["std", "cosmwasm", "xion", "serde"]}
ed25519-zebra = { version = "4.1.0", features = ["alloc"] }
cosmos-sdk-proto = {package = "cosmos-sdk-proto", git = "https://github.com/burnt-labs/cosmos-rust", branch = "feat/xion-zk", default-features = false, features = ["cosmwasm", "xion"]}
url = "2.5.2"
3 changes: 2 additions & 1 deletion contracts/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ base64 = { workspace = true }
rsa = { workspace = true }
getrandom = { workspace = true }
p256 = { workspace = true }
cosmos-sdk-proto = { workspace = true }
ed25519-zebra = { workspace = true }
cosmos-sdk-proto = { workspace = true }
46 changes: 40 additions & 6 deletions contracts/account/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod passkey;
mod secp256r1;
mod sign_arb;
pub mod util;
pub mod zkemail;

pub mod testing {
pub use super::sign_arb::wrap_message;
Expand Down Expand Up @@ -48,6 +49,12 @@ pub enum AddAuthenticator {
url: String,
credential: Binary,
},
ZKEmail {
id: u8,
email_salt: String,
allowed_email_hosts: Vec<String>,
signature: Binary,
},
}

impl AddAuthenticator {
Expand All @@ -59,18 +66,37 @@ impl AddAuthenticator {
AddAuthenticator::Jwt { id, .. } => *id,
AddAuthenticator::Secp256R1 { id, .. } => *id,
AddAuthenticator::Passkey { id, .. } => *id,
AddAuthenticator::ZKEmail { id, .. } => *id,
}
}
}

#[derive(Serialize, Deserialize, Clone, JsonSchema, PartialEq, Debug)]
pub enum Authenticator {
Secp256K1 { pubkey: Binary },
Ed25519 { pubkey: Binary },
EthWallet { address: String },
Jwt { aud: String, sub: String },
Secp256R1 { pubkey: Binary },
Passkey { url: String, passkey: Binary },
Secp256K1 {
pubkey: Binary,
},
Ed25519 {
pubkey: Binary,
},
EthWallet {
address: String,
},
Jwt {
aud: String,
sub: String,
},
Secp256R1 {
pubkey: Binary,
},
Passkey {
url: String,
passkey: Binary,
},
ZKEmail {
email_salt: String,
allowed_email_hosts: Vec<String>,
},
}

impl Authenticator {
Expand Down Expand Up @@ -144,6 +170,14 @@ impl Authenticator {

Ok(true)
}
Authenticator::ZKEmail {
email_salt,
allowed_email_hosts,
} => {
let tx_bytes_hash = util::base64url_encode(tx_bytes);
let verification = zkemail::verify(deps, tx_bytes_hash.as_bytes(), sig_bytes, email_salt, allowed_email_hosts)?;
Ok(verification)
}
}
}
}
37 changes: 37 additions & 0 deletions contracts/account/src/auth/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ use crate::error::ContractError;
use bech32::{ToBase32, Variant};
use ripemd::Ripemd160;
use sha2::{Digest, Sha256};
use base64::{Engine as _, engine::general_purpose};

pub fn sha256(msg: &[u8]) -> Vec<u8> {
let mut hasher = Sha256::new();
hasher.update(msg);
hasher.finalize().to_vec()
}

pub fn base64url_encode(msg: &[u8]) -> String {
general_purpose::URL_SAFE_NO_PAD.encode(msg)
}

fn ripemd160(bytes: &[u8]) -> Vec<u8> {
let mut hasher = Ripemd160::new();
hasher.update(bytes);
Expand All @@ -25,3 +30,35 @@ pub fn derive_addr(prefix: &str, pubkey_bytes: &[u8]) -> Result<String, Contract
Err(err) => Err(err.into()),
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_base64url_encode() {
// Test empty input
assert_eq!(base64url_encode(b""), "");

// Test simple string
assert_eq!(base64url_encode(b"hello"), "aGVsbG8");

// Test with special characters
assert_eq!(base64url_encode(b"hello world!"), "aGVsbG8gd29ybGQh");

// Test binary data
let binary_data = [0x00, 0x01, 0x02, 0x03, 0xFF];
assert_eq!(base64url_encode(&binary_data), "AAECA_8");

// Test longer binary data
let longer_binary = [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64];
assert_eq!(base64url_encode(&longer_binary), "SGVsbG8gV29ybGQ");

// Test that it produces URL-safe output (no + or / characters, no padding)
let test_data = b"test data with special chars: +/=";
let encoded = base64url_encode(test_data);
assert!(!encoded.contains('+'));
assert!(!encoded.contains('/'));
assert!(!encoded.ends_with('='));
}
}
Loading
Loading