Skip to content

circom-prover: Bad bls12-381 proofs #697

@DragonDev1906

Description

@DragonDev1906

Problem

I've come across a circuit that works with BN254 but fails with BLS12-381. This issue might be in the Arkworks code, but I don't know that for sure (my own code was based on the circom-prover implementation), so I'm reporting this here.

Implementation bn254b Bls12-381
snarkjs valid valid
circom-prover valid invalid

I'd have tried with the other ProverLib, but it only supports bn254. Most changes to the circuit result in verification returning Ok(true), so this does not seem to be an issue with my setup or the trusted setup files.

This is not a purely theoretical example, I've found this issue while using Multiplexer from circomlib.

I was able to verify proofs generated with snarkjs (on a larger circuit) using circom-prover, so this issue likely lies in zkey parsing, with how Arkworks is used/called or is an issue within Arkworks.

Details

Minimal circuit:

pragma circom 2.2.3;

template Demo {
    signal input in;
    signal output out;

    signal x <-- 1;
    out <== in * x;
}
component main = Demo();

Rust code:

fn main() {
    let zkey_path = "zkey/mux.zkey";
    let input_json = r#"{"in":["42"]}"#;

    let mut proof = circom_prover::CircomProver::prove(
        circom_prover::prover::ProofLib::Arkworks,
        circom_prover::witness::WitnessFn::RustWitness(|_| {
            // Hard coding witness for simplicity of setup/compilation.
            vec![
                1.into(),  // Constant (first signal is always 1)
                42.into(), // main.out
                42.into(), // main.in
                1.into(),  // main.x
            ]
        }),
        input_json.to_owned(),
        zkey_path.to_owned(),
    )
    .unwrap();

    let valid = circom_prover::CircomProver::verify(
        circom_prover::prover::ProofLib::Arkworks,
        proof,
        zkey_path.to_owned(),
    )
    .unwrap();

    assert!(valid);
}

input4.json
mux.r1cs.txt
mux.sym.txt
mux.vkey.json
mux.zkey.txt

Acceptance criteria

Proof verification should work for the circuit with both curves (as it does with snarkjs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions