Cointime

Download App
iOS & Android

ZKP Series: Pseudonym Input Vulnerability in Circom’s Verification Contract Has Been Replicated

Overview

Earlier, a double-spending vulnerability in a zero-knowledge proof verification contract on Semaphore was uncovered by the Russian developer, Poma. As a matter of curiosity, my intention is to replicate the vulnerability’s PoC initially. However, due to the vulnerability code being old and the project being relatively complex, I opted to create a straightforward PoC to replicate the vulnerability.

Introduction

The foundation of Zero Knowledge Proof (ZKP) technology lies in an algorithm called a “proof system”. By performing a series of computations on the message, the algorithm produces a proof to demonstrate the genuineness of the message. The recipient can confirm the message’s authenticity by verifying the proof alone, without requiring additional information.

There are various implementation schemes for ZKP technology, which we discussed in our earlier article “Technical Features of ZKP Mainstream Implementation Schemes”. In this experiment, the Circom platform is employed, which utilizes Groth16 and PlonK as its proof system. During development, developers can select either system. The development framework generates proof parameters and verification contracts automatically without circuit modification.

In simpler terms, Circom creates witness data and attestation data on the client side and submits them to the contract. The verifier.sol contract verifies the submitted data to confirm whether the proof adheres to the specified rules. This approach enables rapid, efficient, and secure verification while safeguarding the message’s content and privacy.

Vulnerability Analysis

1. There isn’t much to discuss, so let’s proceed straight to the problematic code. Please refer to the “verifyHash” function in the image below. The code enclosed in the red box indicates whether specific witness data has been utilized. This method is commonly employed to prevent double spending. However, the vulnerability has arisen in the witness data “hash1”. Normally, a particular set of proof data should only correspond to a set of “hash1” values for verification purposes.

2. The “verify” function in the “verifier.sol” contract carries out elliptic curve computation verification on the input value via the “scalar_mul()” function. This function conducts calculations on elliptic curves utilizing the input parameters and matches the resulting value against the value specified in the provided proof. The function thereby confirms whether the input value is legitimate or not.

3. In a Solidity smart contract, encoding Fq necessitates the usage of the uint256 type. However, as the maximum value of uint256 is larger than the q value, several distinct integers may correspond to the same Fq value following the modulo operation. For example, “s” and “s+q” indicate the same point, namely the “sth” point. Similarly, “s+2q” and so on are also aliases for point “s”. This phenomenon is known as “Input Aliasing”, whereby these integers serve as pseudonyms for one another.

The “q” value mentioned here pertains to the cyclic group’s order, which signifies the number of values within the same Fq that can be input with numerous large integers. In essence, even if a q value is added to the hash, it can still satisfy the verification criterion. Within the uint256 type’s scope, a maximum of uint256_max/q distinct integers can indicate the same point. This signifies that a set of proofs can have up to 5 hash1 values that match and can pass the contract’s verification.

Vulnerability Recurrence

1. Develop a basic circuit that inputs two data sets and produces a witness data, i.e., “hash1,” utilized in the contract.

2. Compile the circuit to create “circuit_final.zkey”, “circuit.wasm”, and “verifier.sol”. Afterward, generate a collection of proofs, a standard hash, and a corrupted hash.

3. Subsequently, deploy the contract and employ the “checkHash” generated earlier to conduct a verification process. The verification successfully passes.

4. Next, apply the identical witness data and the previously generated “attackHash”. It is discovered that the verification is also successful. This demonstrates that a set of proofs can feature several matching hashes that meet the contract’s verification criteria. Thus, the Circom verification contract input pseudonym vulnerability has been effectively replicated.

Solutions to Vulnerabilities

The vulnerability arises from a set of proofs that can have at most 5 hash values that match and meet the contract’s verification requirements. Thus, the bug fix is straightforward: restricting all input hashes to a value less than “q”.

Summary

Input pseudonym vulnerability is a frequently encountered vulnerability in zero-knowledge proof and cryptography implementation. Its fundamental cause lies in the value being equivalent to the remainder within the finite field. Therefore, developers must focus on the verification group’s order when creating cryptography.

Get the latest news here: Cointime channel — https://t.me/cointime_en

Comments

All Comments

Recommended for you

  • ETH breaks through $2100

    market shows ETH breaking through $2100, currently at $2100.24, with a 24-hour increase of 7.65%. The market is highly volatile, please manage your risks accordingly.

  • BTC falls below $66,000

    the market shows BTC falling below 66,000 USD, currently at 65,996.42 USD, a 24-hour decline of 2.35%, with significant market fluctuations, please manage your risk properly.

  • YesGo Makes Its Public Debut: Joining Forces with Ecosystem and Industry Leaders to Usher in a New Era of On-Chain Native Commerce

    Hong Kong, February 11, 2026 – As one of the most visionary cross-sector dialogues held during Hong Kong Consensus Week, the YesGo Ecosystem Partner Meeting concluded successfully yesterday. This closed-door event, spearheaded by YesGo and co-hosted by Nexus Chain and compliant digital asset exchange CoinMy, brought together a select group of global ecosystem partners, industry KOLs, and media representatives.

  • The number of Americans filing for unemployment benefits last week was 227,000.

     initial jobless claims in the United States last week were 227,000, estimated at 224,000, previous value was 231,000.

  • BTC breaks through $68,000

     the market shows BTC breaking through $68,000, currently at $68,023.93, with a 24-hour decline of 1.36%. The market is highly volatile, please manage your risk accordingly.

  • [Consensus HK] ENI CEO Arion Ho: Decentralization is an Engineering Choice, Not a Slogan

    At the Consensus Hong Kong 2026 summit, ENI Founder and CEO Arion Ho joined the DeFi Lead at CoinDesk and executives from Paradigm and Blockdaemon to debate the future of DeFi decentralization. Ho delivered a sharp critique of the industry’s current trajectory, asserting that decentralization should never be about "slogan-style freedom," but is fundamentally a rigorous engineering choice.

  • Trump praised the non-farm payroll data and urged the Federal Reserve to cut interest rates to the "lowest in the world."

    US President Trump posted on social media, "Employment data is excellent, far exceeding expectations! The US should pay much less interest on borrowing costs (bonds!). We have once again become the world's number one power, and therefore deserve the lowest interest rates ever. This will bring at least one trillion dollars in interest savings annually — the budget will not only be balanced but will have a substantial surplus. Wow! The golden age of America has arrived!!!"

  • BTC falls below $67,000

    the market shows BTC falling below $67,000, currently at $66,991.58, with a 24-hour decline of 3.41%. The market is highly volatile, please manage your risk accordingly.

  • BTC falls below $69,000

     the market shows BTC fell below 69,000 USD, currently at 68,996.18 USD, with a 24-hour decline of 2.21%. The market is highly volatile, please manage your risk accordingly.

  • BTC falls below $70,000

     the market shows BTC falling below $70,000, currently at $69,990, with a 24-hour decline of 1.04%. The market is highly volatile, please manage your risk accordingly.