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

  • Iranian Parliament Proposes Permanent Ban on Oil Tankers Linked to US and Israel in Strait of Hormuz

    On April 10, market news: Ebrahim Azizi, chairman of the Iranian Parliament's National Security Committee, stated that the parliament has proposed a measure to permanently prohibit oil tankers associated with the United States and Israel from passing through the Strait of Hormuz. Vessels linked to Israel or traveling to and from Israel will also be banned from passage, and this prohibition will extend to countries that take action against the 'Resistance Front.'

  • Hong Kong's First Batch of Stablecoin Licenses to be Announced Today Afternoon

    On April 10, the Hong Kong Monetary Authority (HKMA) will announce the first batch of stablecoin licenses at 5 PM. Following this, licensed stablecoin issuers will meet with the media. Previously, the HKMA completed the final review of the first batch of applications in mid-March 2026 and is now in the official public announcement preparation stage. The HKMA received a total of 36 applications and plans to issue 2 to 3 licenses in this first batch, with strict regulatory standards. In early February this year, HKMA Chief Executive Eddie Yue stated that they aimed to issue the first stablecoin issuer licenses in Hong Kong in March, emphasizing that 'the number of licenses issued in the first batch will definitely be limited, with a focus on prudence.' (Daily Economic News)

  • DeepSeek Officially Introduces Features of DeepSeek V4

    On April 10, the DeepSeek official blog published an article introducing DeepSeek V4, the flagship model set to be launched by DeepSeek. This model not only breaks the limits of parameter scale but also promises unprecedented efficiency. DeepSeek V4 is expected to handle 1 trillion (1T) parameters, natively supports multimodal data including text, images, videos, and audio, and features a context window of 1 million tokens (equivalent to 15-20 complete novels), making it a direct competitor to Western giants like OpenAI's GPT-5.4 and Anthropic's Claude Opus 4.5. The API pricing for DeepSeek V4 is 10-50 times cheaper than that of GPT-5.4 and Claude Opus 4.5; it is anticipated that DeepSeek V4 will be open-sourced under the Apache 2.0 license. DeepSeek V4 can run locally on dual RTX 4090 or single RTX 5090 setups. Additionally, DeepSeek introduced three groundbreaking innovations for DeepSeek V4: 1. Engram memory; 2. Manifold-constrained hyperconnection (mHC); 3. Sparse attention mechanism (DSA) and Lightning indexer. Furthermore, the DeepSeek official statement noted that due to strict U.S. export restrictions on high-end NVIDIA GPUs (such as the B300 and H200), DeepSeek has optimized V4 to primarily rely on domestically produced chips in China for inference. While initial training may still have utilized NVIDIA hardware (like H800s), the model has been highly optimized for Huawei's Ascend 950PR and Cambricon MLU chips.

  • US Spot Ethereum ETF Sees Net Inflow of $106.16 Million

    On April 10, according to monitoring by Trader T, the US spot Ethereum ETF recorded a net inflow of $106.16 million yesterday.

  • US Spot Bitcoin ETF Sees Net Inflow of $304.9 Million Yesterday

    On April 10, according to monitoring by Trader T, the US spot Bitcoin ETF experienced a net inflow of $304.9 million yesterday.

  • ETH Falls Below $2200

    Market data shows that ETH has fallen below $2200, currently priced at $2199.32, with a 24-hour increase of 1.11%. The market is experiencing significant volatility, so please ensure proper risk management.

  • Hassett: Confident Waller Will Assume Fed Chair Position in May

    Hassett, the Director of the National Economic Council at the White House, expects that Powell will not remain as a Federal Reserve governor. He is confident that Waller will assume the position of Fed Chair in May.

  • Becerra: It's Time to Submit the CLARITY Act for President Trump's Signature

    On April 9, U.S. Treasury Secretary Becerra stated that Congress has spent nearly five years attempting to pass a framework to ensure the future development of the financial industry. Now is the time for Senate Banking Republicans to review and submit the CLARITY Act for President Trump's signature.

  • Binance Officially Launches Prediction Market

    On April 9, Binance announced the launch of its prediction market, a new feature that allows users to participate in probability-based markets through integration with third-party platforms from the Binance app. The Binance wallet will integrate market access provided by Predict.fun, a leading on-chain prediction market provider on the BNB Smart Chain (BSC). In the Binance App, go to the [Markets] tab. Click on the [Prediction] tab (available only in supported regions). Select a category to browse available markets offering real-time probability pricing.

  • Iranian Military Spokesman: 'Prepared for Long-term War'

    According to the Iranian Students' News Agency on the 9th, the Iranian military spokesman expressed hope for reaching an agreement in the ceasefire negotiations, but stated that if the talks fail, 'we are also prepared for a long-term war.' The conditions proposed by Iran will serve as the basis for the negotiations. (Xinhua News Agency)