dusk-network/plonk

Bug in point equality assertion

Closed this issue · 0 comments

Describe the bug
Point equality is not being done correctly. b's y component is being compared to itself here

To Reproduce

  1. rustup update nightly
  2. rustup override set nightly
  3. Run the test above (p1's y component is different than p2's y component and the proving fails.
#[test]
fn failing_test() {
    let rng = &mut StdRng::seed_from_u64(8349u64);

    let n = 1 << 12;
    let label = b"demo";
    let pp = PublicParameters::setup(n, rng).expect("failed to create pp");

    pub struct DummyCircuit {
        p1: JubJubExtended,
        p2: JubJubExtended,
    }

    impl Default for DummyCircuit {
        fn default() -> Self {
            Self {
                p1: JubJubExtended::from_raw_unchecked(
                    BlsScalar::zero(),
                    BlsScalar::one(),
                    BlsScalar::one(),
                    BlsScalar::zero(),
                    BlsScalar::zero(),
                ),
                p2: JubJubExtended::from_raw_unchecked(
                    BlsScalar::zero(),
                    BlsScalar::zero(),
                    BlsScalar::one(),
                    BlsScalar::zero(),
                    BlsScalar::zero(),
                ),
            }
        }
    }

    impl Circuit for DummyCircuit {
        fn circuit<C>(&self, composer: &mut C) -> Result<(), Error>
        where
            C: Composer,
        {
            let w_x = composer.append_point(self.p1);
            let w_y = composer.append_point(self.p2);
            composer.assert_equal_point(w_x, w_y);
            Ok(())
        }
    }

    let (prover, _verifier) = Compiler::compile::<DummyCircuit>(&pp, label)
        .expect("failed to compile circuit");

    let proving_result = prover
        .prove(rng, &Default::default());

    assert!(proving_result.is_err(), "proving should fail because the points are not equal");
}

Expected behavior
Proving should fail because the points that are being compared are not equal.

Logs/Screenshot

thread 'failing_test' panicked at 'proving should fail because the points are not equal', tests/composer.rs:167:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4781233a77e879e49cb5ce3c98d2abba6a6ade7a/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/4781233a77e879e49cb5ce3c98d2abba6a6ade7a/library/core/src/panicking.rs:64:14
   2: composer::failing_test
             at ./tests/composer.rs:167:5
   3: composer::failing_test::{{closure}}
             at ./tests/composer.rs:116:19
   4: core::ops::function::FnOnce::call_once
             at /rustc/4781233a77e879e49cb5ce3c98d2abba6a6ade7a/library/core/src/ops/function.rs:250:5
   5: core::ops::function::FnOnce::call_once
             at /rustc/4781233a77e879e49cb5ce3c98d2abba6a6ade7a/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test failing_test ... FAILED

failures:

failures:
    failing_test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 16.31s

Platform
Fill as appropriate

  • Architecture:ARM
  • OS: macOS
  • Browser: firefox

Additional context