QShield QShield ← Back to Home

Gas Cost Benchmarks

Quantitative analysis of post-quantum signature costs on QShield L2

Key Finding
Session Key transactions (version 0x03) achieve 80-98% cost reduction compared to full hybrid PQC signatures, bringing per-transaction costs to parity with standard ECDSA-only L2 transactions.

Cost Comparison: Hybrid vs Session Key vs ECDSA

Metric Hybrid (0x01) Session Key (0x03) Standard ECDSA
Signature size 3,375 bytes 66 bytes 65 bytes
Signature components version(1) + ECDSA(65) + ML-DSA(3,309) version(1) + ECDSA(65) ECDSA(65)
L2 execution gas ~53,700 ~8,200 ~3,000
DA cost (EIP-4844 Blob) ~$0.04 ~$0.001 ~$0.001
DA cost (Celestia) ~$0.004 ~$0.0001 ~$0.0001
Total cost (Blob) ~$0.05 ~$0.002 ~$0.001
Total cost (Celestia) ~$0.005 ~$0.0003 ~$0.0001
Quantum resistance Full (ECDSA + ML-DSA) Inherited (via registration) None
Confirmation time 2 sec (L2 block) 2 sec 2 sec

Signature Size Comparison

Hybrid (0x01)
3,375 B
3,375 B
Session Key (0x03)
66 B
66 B
Standard ECDSA
65 B
65 B

L2 Execution Gas Comparison

Hybrid (0x01)
53,700
53,700
Session Key (0x03)
8,200
8,200
Standard ECDSA
3,000
3,000

Detailed Gas Breakdown

Hybrid Verification (version 0x01)

StepOperationGas
1Version byte parsing~200
2ECDSA.recover(userOpHash, ecdsaSig) — OZ ECDSA3,000
3EXTCODEHASH(keyBlob) == keyBlobHash2,600 (cold)
4EXTCODESIZE(keyBlob) == 1953100 (warm)
5EXTCODECOPY(keyBlob, offset=1, len=1952)2,783
6staticcall(0x0101, pubkey|hash|sig) — ML-DSA-6545,000
Total~53,700

Session Key Verification (version 0x03)

StepOperationGas
1Version byte parsing~200
2ECDSA.recover(userOpHash, ecdsaSig) — OZ ECDSA3,000
3sessionKeys[recovered] Slot 0 (time + maxValue)2,100 (cold)
4sessionKeys[recovered] Slot 1 (whitelistRoot)2,100 (cold)
5Whitelist hash comparison (calldata only)~500
Total~7,900–10,500
Why Session Keys are cheap
Session Key TX (0x03) skips the PQC precompile call entirely. The ML-DSA-65 verification (45,000 gas) and EXTCODECOPY (2,783 gas) are only needed during Session Key registration (a hybrid 0x01 TX). Daily transactions use only ECDSA + 2 storage reads.

Data Availability Cost Analysis

On L2, user cost is dominated by DA cost (posting signature data to L1 or alt-DA), not L2 execution gas. Signature size is the critical factor.

DA MethodCost per byteHybrid (3,375 B)Session Key (66 B)Reduction
L1 Calldata ~16 gas/byte ~$0.50 ~$0.01 -98%
EIP-4844 Blob ~1 gas/byte ~$0.04 ~$0.001 -97.5%
Celestia Alt-DA ~0.1 gas/byte ~$0.004 ~$0.0001 -97.5%

Public Key Storage: SSTORE2 vs Solidity Storage

ML-DSA-65 public keys are 1,952 bytes. Storing them in standard Solidity storage would require 61 slots. SSTORE2 deploys the key as contract bytecode instead.

MetricSolidity Storage (v3.3)SSTORE2/KeyBlob (v3.4+)Improvement
Init cost 1,220,000 gas (61 SSTORE) ~462,000 gas (CREATE2 + 2 slots) -62%
Read cost per TX 130,200 gas (62 SLOAD cold) ~5,800 gas (EXTCODECOPY) -96%
TX verification total ~178,000 gas ~54,000 gas -70%
Storage slots 64 (3 + 61 data) 3 (owner + keyBlob + keyBlobHash) -95%

ML-DSA-65 Precompile Performance

The ML-DSA-65 verification runs as a native Go precompile at address 0x0101, using Cloudflare CIRCL sign/mldsa/mldsa65.

ApproachGas CostSourceVerdict
Pure Solidity ML-DSA ~30,000,000 Tetration Lab / Quasar Block limit exceeded
ZKNOX FALCON NTT ~1,500,000 ZKNOX ETHFALCON Expensive
Go precompile ML-DSA-65 ~45,000 QShield (15x ecrecover) Practical

Precompile Input/Output Specification

ParameterValue
Address0x0101
Input formatpubkey[1952] || msgHash[32] || sig[3309]
Input size5,293 bytes (fixed)
Output (success)uint256(1) — 32 bytes
Output (failure)uint256(0) — 32 bytes
Gas cost45,000 (initial, adjustable post-benchmark)
StandardNIST FIPS 204 (ML-DSA-65, Security Level 3)
LibraryCloudflare CIRCL v1.6.3 (sign/mldsa/mldsa65)

Real-World User Cost Model

The typical QShield user flow minimizes high-cost PQC operations:

ActionFrequencySignatureCost (Blob)Cost (Celestia)
Account creation Once Hybrid (0x01) ~$0.50 ~$0.05
Session Key registration As needed Hybrid (0x01) ~$0.05 ~$0.005
Daily transactions Hundreds–thousands Session Key (0x03) ~$0.002 ~$0.0003
High-value transfers Rare Hybrid (0x01) ~$0.05 ~$0.005
Bottom line
For a user who creates 1 account, registers 1 session key, and executes 100 transactions per month: total monthly cost is ~$0.75 (Blob) or ~$0.08 (Celestia). Without session keys, the same user would pay ~$5.50 (Blob) or ~$0.55 (Celestia) — a 7x cost reduction.

Methodology

Test Environment

Gas Measurement Method

  1. L2 execution gas: Measured via forge test --gas-report and gasleft() checkpoints in Foundry tests. Cold storage access assumed for first reads (EIP-2929).
  2. DA cost: Calculated as signature_bytes × cost_per_byte. Blob cost uses EIP-4844 pricing model. Celestia cost uses published Celestia fee schedule.
  3. Precompile gas (45,000): Set at approximately 15× ecrecover (3,000 gas), with DoS safety margin. Adjustable after mainnet benchmarking.
  4. USD conversion: Based on ETH price of $2,500 and gas price of 0.01 gwei (typical L2 conditions). Actual costs vary with network conditions.

Reproducibility

All gas measurements can be reproduced using the QShield contracts test suite:

# Clone and build
git clone https://github.com/superlabs-x/qshield-l2
cd qshield-l2/contracts

# Install dependencies
forge install

# Run gas comparison tests
forge test --gas-report -vvv --match-test "testGas_"

# Run specific benchmarks
forge test --gas-report --match-test "testGas_SessionKey_vs_Hybrid"
forge test --gas-report --match-test "testGas_SSTORE2_vs_StorageRead"

Assumptions and Limitations

References