惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
Security Latest
Security Latest
P
Proofpoint News Feed
GbyAI
GbyAI
PCI Perspectives
PCI Perspectives
博客园 - Franky
N
Netflix TechBlog - Medium
博客园_首页
WordPress大学
WordPress大学
K
Kaspersky official blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
T
Threatpost
The Hacker News
The Hacker News
H
Help Net Security
S
Securelist
Recent Announcements
Recent Announcements
腾讯CDC
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Engineering at Meta
Engineering at Meta
C
Cisco Blogs
V
V2EX
C
Check Point Blog
S
Schneier on Security
Cyberwarzone
Cyberwarzone
C
Cybersecurity and Infrastructure Security Agency CISA
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Jina AI
Jina AI
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
博客园 - 叶小钗
A
Arctic Wolf
AWS News Blog
AWS News Blog
Latest news
Latest news
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
Last Week in AI
Last Week in AI
The GitHub Blog
The GitHub Blog
小众软件
小众软件
B
Blog
aimingoo的专栏
aimingoo的专栏
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog
P
Palo Alto Networks Blog
Spread Privacy
Spread Privacy

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything BFF模式详解:构建前后端协同的中间层 I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
What If a Supplier Could Prove They Qualify For a Deal Without Showing You Their Cards?
Niomi Langal · 2026-05-24 · via DEV Community

Let me tell you about a weird negotiation problem I stumbled into.

Picture this: a corporate energy buyer needs to confirm that a hydrogen supplier holds at least 3,000 MWh of certified green credits before they'll sign a procurement contract. Fair enough. The supplier has the credits. They want the deal. So they share their actual inventory number.

And the moment they do, something shifts in the room.

Because now the buyer knows the supplier is sitting on 8,500 MWh. Suddenly the buyer has a very clear picture of how desperate that supplier is not. The leverage just moved. The deal terms are about to get worse for the supplier, and there is nothing they can do about it, because they already showed their hand.

I kept thinking about this problem. And I realised it was not really a negotiation problem. It was an information architecture problem. The supplier needed a way to say "yes, I qualify" without saying "and here is exactly how much I have."

That is what I built with H2Ledger: a decentralised marketplace for green hydrogen credits where suppliers can prove actualAmount >= threshold to a smart contract, with full cryptographic certainty, without the actual number ever appearing anywhere. Not on-chain. Not in the proof. Not in transit. Nowhere.

The tool that makes this possible is called a zero-knowledge proof. Let me show you how it works, what the code looks like, and honestly, what I wish I had done differently.


Before We Dive In: What Even Is a Zero-Knowledge Proof?

I promise this is not as scary as it sounds.

Think of it like this. Imagine your friend dares you to prove you know the combination to a safe, but you refuse to say the numbers out loud. A zero-knowledge proof is essentially a mathematical protocol that lets you win that dare. You convince the other party that a statement is true, without revealing the secret behind it.

More precisely, three things have to hold:

  • Completeness: If you are telling the truth and you have the right secret, you can always produce a valid proof.
  • Soundness: If you are lying, you cannot fake a valid proof. The math makes cheating computationally infeasible.
  • Zero-knowledge: The person checking the proof learns only whether the statement is true or false. Nothing else leaks.

In H2Ledger, the statement is actualAmount >= threshold. The secret (called the "witness") is actualAmount. And the party checking the proof is not a human; it is a Solidity smart contract sitting on an EVM-compatible blockchain.

No trust required. No intermediary needed. Just math.


The Real Problem: Green Hydrogen Credit Markets Are Kind of a Disaster

Okay, "disaster" is strong. But the current state of things is genuinely fragile.

Right now, hydrogen credit markets deal with:

  • Paper-based certification chains that have no on-chain anchor. The same certified credit can be quietly presented to multiple buyers across different negotiations. Nobody has a shared ledger to catch it.
  • Siloed registries running under incompatible regulatory frameworks, with no interoperability. A buyer in Germany and a supplier in Chile might be working from entirely different certification standards with no way to verify across the gap.
  • A forced choice between transparency and opacity. Put your credit balances on a public blockchain and every competitor can see your inventory in real time. Keep it off-chain and there is no trustless settlement mechanism. You have to pick your poison.

Zero-knowledge proofs let you step off that seesaw entirely. You get a shared ledger for settlement and privacy for the underlying figures. Both at the same time.


How H2Ledger Actually Works: The Three-Layer Picture

At a high level, the system has three layers that talk to each other:

[ Supplier (off-chain) ]
        |
        | Private: actualAmount (stays here, never transmitted)
        v
[ Circom Circuit + Groth16 Prover ]
        |
        | Outputs: proof.json (256 bytes) + public.json (threshold only)
        v
[ GreenHydrogenMarketplace.sol ]
        |
        | Delegates the heavy cryptographic check to:
        v
[ Verifier.sol ]  -->  true / false

Enter fullscreen mode Exit fullscreen mode

The supplier's actual inventory figure never leaves their machine. What travels on-chain is a 256-byte proof and the public threshold value. The smart contract checks the proof, confirms it is valid, and flips the order status to fulfilled. That is the entire settlement flow.


The ZK Circuit: Where the Magic Gets Boring (in a Good Way)

Circuits are the programs that ZK proof systems evaluate. I wrote mine in Circom 2.0, which is essentially a domain-specific language for expressing computations as systems of arithmetic constraints. Here is the core template:

template ThresholdVerification(n) {
    signal input actualAmount;    // Private: never leaves the prover's machine
    signal input threshold;       // Public: the buyer's stated minimum
    signal output isValid;        // 1 if actualAmount >= threshold, else 0

    // Uses LessThan from circomlib to prove:
    // NOT (actualAmount < threshold) = (actualAmount >= threshold)
}

Enter fullscreen mode Exit fullscreen mode

When you compile this, it produces 128 R1CS constraints across 193 wires. Here is what those constraints actually do:

  • 64 of them decompose both actualAmount and threshold into their 64-bit binary representations.
  • The other 64 implement the bit-by-bit comparator that determines which number is larger.

A quick note on the 64-bit choice: hydrogen volumes in enterprise markets are measured in millions of MWh. A 64-bit field accommodates values up to 2^64, which gives roughly 2^40 headroom above anything you would ever trade. There is no practical ceiling concern.

The Groth16 prover takes this circuit, the witness, and a proving key from the setup ceremony, and outputs three elliptic curve group elements on BN254:

π_a, π_b, π_c

Enter fullscreen mode Exit fullscreen mode

These three elements are the proof. Serialised, they always come out to exactly 256 bytes, regardless of what the witness contains. That fixed size is genuinely useful in practice: gas costs are predictable, ABI encoding is clean, and storage is a non-issue.

Proof generation takes about 1 to 2 seconds on a regular laptop, and it all happens off-chain. The blockchain never sees the compute; it only sees the output.


The Smart Contracts: Access Control That Actually Makes Sense

The onlyOwner Trap

Here is a pattern I wanted to avoid from the start.

A lot of contract systems default to a single onlyOwner modifier for every privileged operation. It is simple. It works. And in a single-actor system, it is probably fine.

But H2Ledger has three distinct actor types with completely different trust assumptions: Producers (suppliers holding credits), Buyers (companies publishing procurement orders), and Verifier Agents (credentialed parties who attest the legitimacy of underlying certifications off-chain). Funnelling all three through a single owner address creates a unilateral control point that fundamentally contradicts the trustless premise of the whole system.

So I built a role-based access layer instead. Each address gets assigned one of four states: NONE, PRODUCER, VERIFIER_AGENT, or BUYER. Every sensitive function checks the caller's role before anything else runs.

pragma solidity ^0.8.0;
import "./Verifier.sol";

contract GreenHydrogenMarketplace {
    Verifier verifier;

    enum Role { NONE, PRODUCER, VERIFIER_AGENT, BUYER }

    mapping(address => Role) private roles;
    address public admin;

    modifier onlyRole(Role _required) {
        require(roles[msg.sender] == _required, "Access denied: insufficient role");
        _;
    }

    modifier onlyAdmin() {
        require(msg.sender == admin, "Access denied: not admin");
        _;
    }

    constructor(address _verifier) {
        verifier = Verifier(_verifier);
        admin = msg.sender;
    }

    function assignRole(address _account, Role _role) external onlyAdmin {
        roles[_account] = _role;
    }
}

Enter fullscreen mode Exit fullscreen mode

The result: no address can wear two hats. A buyer cannot submit proofs. A producer cannot create orders. Role assignment itself is gated behind the admin key, which is the one remaining centralisation point I will address honestly in the learnings section below. The onlyRole modifier is composable, so extending this to new function types costs one line.

Creating an Order

Only BUYER addresses can create procurement orders. And once an order is created, the threshold is immutable. I want to highlight that last part because it matters more than it might seem.

If a buyer could lower the threshold after a supplier has already generated their proof, they could retroactively disqualify a supplier who legitimately met the original bar. Locking the threshold at creation time prevents that manipulation entirely.

struct ProcurementOrder {
    address buyer;
    address supplier;
    uint256 threshold;
    bool fulfilled;
}

mapping(uint256 => ProcurementOrder) public orders;
uint256 public nextOrderId;

function createOrder(address _supplier, uint256 _threshold)
    external
    onlyRole(Role.BUYER)
    returns (uint256 orderId)
{
    orderId = nextOrderId++;
    orders[orderId] = ProcurementOrder({
        buyer: msg.sender,
        supplier: _supplier,
        threshold: _threshold,
        fulfilled: false
    });
}

Enter fullscreen mode Exit fullscreen mode

Proof Submission: Cheap Checks First, Expensive Check Last

This is where the ZK verification actually happens. When a supplier submits their proof, the contract runs five checks in deliberate order, from cheapest to most expensive:

  1. Role check: Is the caller a registered PRODUCER? (modifier, ~200 gas)
  2. Supplier identity: Is this the specific supplier bound to this order? (SLOAD, ~2,100 gas)
  3. Replay prevention: Has this order already been fulfilled? (SLOAD, ~2,100 gas)
  4. Threshold binding: Does the public signal match the stored threshold? (comparison, ~200 gas)
  5. Pairing check: Is the ZK proof cryptographically valid? (~285,000 gas)

The expensive pairing computation runs dead last. Every cheaper guard that fails before it saves the caller from spending 285k gas on a doomed transaction.

function submitThresholdProof(
    uint256 orderId,
    uint[2] calldata _pA,
    uint[2][2] calldata _pB,
    uint[2] calldata _pC,
    uint[1] calldata _pubSignals
) external onlyRole(Role.PRODUCER) {
    ProcurementOrder storage order = orders[orderId];

    require(msg.sender == order.supplier, "Caller is not the designated supplier");
    require(!order.fulfilled, "Order already fulfilled");
    require(_pubSignals[0] == order.threshold, "Public signal does not match order threshold");

    require(
        verifier.verifyProof(_pA, _pB, _pC, _pubSignals),
        "ZK proof verification failed"
    );

    order.fulfilled = true;
    // Downstream: emit event, trigger escrow release, etc.
}

Enter fullscreen mode Exit fullscreen mode

One check here deserves extra attention: _pubSignals[0] == order.threshold. This might look redundant but it is doing important work. Without it, a supplier could submit a valid proof generated against a different threshold (say, 1,000 MWh, which they easily meet) and pair it with an order that requires 3,000 MWh. The proof itself would pass the pairing check, because it is a valid proof for 1,000 MWh. Only this binding check catches the substitution and rejects it.


Performance Numbers: What Does This Actually Cost?

Metric Value
Proof size 256 bytes (always fixed)
Proof generation time 1 to 2 seconds (off-chain)
Verifier deployment gas ~2,850,000 (one-time)
Per-proof verification gas ~289,096
Cost on Ethereum L1 at 30 Gwei ~$0.87 per proof
Cost on Arbitrum or Optimism ~$0.01 per proof

For enterprise procurement deals where individual contracts are worth millions, $0.87 per verification on L1 is totally reasonable. For anything approaching higher frequency, L2 is the obvious path.


What I Got Right, and Where I Would Do Things Differently

The Good Stuff

Separating Verifier.sol from GreenHydrogenMarketplace.sol was the right architectural call. The verifier is a stateless cryptographic primitive with no business logic. Keeping it isolated means you can audit it independently from everything else. Smaller surface, cleaner audit scope.

The cheap-to-expensive ordering on submitThresholdProof also paid off during testing. Failed submissions on invalid inputs were consistently cheaper than they would have been with the pairing check running first.

The Honest Regrets

The trusted setup is my biggest unresolved liability. Groth16 requires a one-time MPC ceremony to generate the proving and verification keys. The PoC uses a simulated ceremony, which is fine for a research context. But in production, if any single participant in that ceremony retained their "toxic waste" (the secret randomness from their contribution), they could forge valid proofs for false claims indefinitely. A production deployment needs either a large, publicly verifiable MPC ceremony with auditable transcripts, or a migration to a setup-transparent proof system like PLONK or Halo2, where no trusted setup is needed at all.

The admin key is a trust bottleneck I did not fully solve. Right now, a single address controls role assignment for the entire marketplace. That is a meaningful centralisation risk. In the next version, the admin role should transfer to a Gnosis Safe multisig on day one, with a timelock on role assignment operations so participants have advance notice of any changes.

Gas can go lower. The BN254 pairing operations in Verifier.sol benefit significantly from the EIP-197 precompile on Ethereum. If the generated verifier correctly routes through it rather than computing in the EVM interpreter, verification cost drops by 30 to 40 percent. Worth measuring carefully before any production deployment.

The circuit only proves one thing. Real procurement contracts care about more than just volume. Purity grade, certification date, origin country; these all matter. Extending the circuit to a composite check (volume >= min_vol AND purity >= min_purity AND date >= cutoff) adds roughly 256 additional constraints and maybe doubles proof generation time. Both are well within practical limits, and it would make the system meaningfully more useful.


Run It Yourself

If you want to poke at the code:

git clone <your-repo-url>
cd h2ledger-poc
npm install
npm run verify
# Expected: OK
# (verifies the included proof where actualAmount=5000 >= threshold=3000)

Enter fullscreen mode Exit fullscreen mode

And to see the circuit stats directly:

snarkjs r1cs info circuits/credit_proof.r1cs
# Curve: bn-128
# Constraints: 128
# Wires: 193
# Private Inputs: 1
# Public Inputs: 1

Enter fullscreen mode Exit fullscreen mode


Why This Pattern Matters Beyond Hydrogen

Here is the thing I kept coming back to while building this: H2Ledger is not really a hydrogen project. It is a demonstration of a general-purpose pattern.

Any market where someone needs to prove a number meets a threshold, but revealing that number has a cost, is a candidate for this architecture. Credit scoring. Insurance underwriting. Supply chain vendor qualification. Payroll compliance audits. The circuit changes; the pattern does not.

Zero-knowledge proofs get talked about a lot in abstract terms. What I wanted to show here is that with Circom, SnarkJS, and a few hundred lines of Solidity, you can build something real with them in a matter of weeks. The tooling is genuinely usable. The math does not need to be magic; it just needs to be correctly wired together.

If you build something with a similar approach, or if you spot something I should fix, I would genuinely love to hear about it.


H2Ledger is a research proof of concept (v0.1.0). Proof system: Groth16 (BN254). Circuit: 128 constraints, 193 wires. Questions or collaboration: nioomeee@gmail.com