Home

Awesome

halo2-zkcert

Halo2 library to verify a chain of certificates which is used in TLS initial handshake, document signing and VPNs. Currently supports RSA signature scheme and SHA256 hash function. In the future, we can support more certificate chaining standards such as ECDSA, SHA3 etc i.e. here

Note: Doesn't verify the self-signed root certificate which uses SHA1. This is fine because root certificates are assumed to be trusted.

Screenshot 2023-09-07 at 5 48 04 PM

Installation

git clone https://github.com/zkpdf/halo2-zkcert/
cd halo2-zkcert
cargo build --release

Example Usage

// Import your own chain of x509 certificates and save them as PEM files in `certs` folder. Where 1 is root certificate and 3 is leaf certificate
// OR
cargo run --release download-tls-certs --domain axiom.xyz --certs-path ./certs/cert
// Generate RSA proving keys
cargo run --release -- gen-rsa-keys --k 17 --pk-path ./build/rsa.pk --verify-cert-path ./certs/cert_3.pem --issuer-cert-path ./certs/cert_2.pem
// Generate SHA256 proving keys
cargo run --release -- gen-zkevm-sha256-keys --k 19 --pk-path ./build/zkevm_sha256.pk --verify-cert-path ./certs/cert_3.pem
// Generate proving keys for X509AggregationCircuit
cargo run --release -- gen-x509-agg-keys --agg_k 22
// Prove RSA
cargo run --release -- prove-rsa --pk-path ./build/rsa.pk --verify-cert-path ./certs/cert_3.pem --issuer-cert-path ./certs/cert_2.pem
cargo run --release -- prove-rsa --pk-path ./build/rsa.pk --verify-cert-path ./certs/cert_2.pem --issuer-cert-path ./certs/cert_1.pem
// Prove SHA256
cargo run --release prove-zkevm-sha256 --pk-path ./build/zkevm_sha256.pk --verify-cert-path ./certs/cert_3.pem --proof-path ./build/zkevm_sha256_1.proof
cargo run --release prove-zkevm-sha256 --pk-path ./build/zkevm_sha256.pk --verify-cert-path ./certs/cert_2.pem --proof-path ./build/zkevm_sha256_2.proof
// Prove aggregation and verify in smart contract
cargo run --release -- gen-x509-agg-evm-proof

Test

cargo test

Benchmarks

TODO

CircuitkNum AdviceNum Lookup AdviceNum FixedProof Time (M1 16GB)Proof Time (EC2 c6a.48xlarge)
RSA1512111.783s1.245s
RSA166112.224s1.509s
RSA173113.144s1.813s

Dependencies

Issues

Current issues and todos with the library. We welcome any contributions!

  1. Doesn't support other certificate chaining standards, such as ECDSA and SHA3 yet
  2. Doesn't support CRL (certificate revocation lists yet)