Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in point equality assertion #720

Closed
ilitteri opened this issue Jan 18, 2023 · 0 comments · Fixed by #721
Closed

Bug in point equality assertion #720

ilitteri opened this issue Jan 18, 2023 · 0 comments · Fixed by #721
Labels
fix:bug Something isn't working

Comments

@ilitteri
Copy link
Contributor

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

@ilitteri ilitteri added the fix:bug Something isn't working label Jan 18, 2023
@moCello moCello linked a pull request Jan 19, 2023 that will close this issue
@moCello moCello mentioned this issue Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant