dusk-network / plonk

Pure Rust implementation of the PLONK ZKProof System done by the Dusk team
https://dusk-network.github.io/plonk
Mozilla Public License 2.0
543 stars 150 forks source link

Test fails when using `rng` #777

Closed xevisalle closed 12 months ago

xevisalle commented 1 year ago

Describe the bug While implementing some required blinders in the prover, we noticed that the test append_logical_xor fails, when trying to generate a proof for the specific case // Test random works. The returned error is Polynomial Degree Too Large.

To Reproduce Go to the prover, and add the following lines:

let b_10 = BlsScalar::random(&mut *rng); let b_11 = BlsScalar::random(&mut *rng); let b_12 = BlsScalar::random(&mut *rng);

Then test append_logical_xor. If you remove one of the 3 added lines, it will pass. If you go to the function blind_poly() and remove the randomness used there, it will pass too.

EDIT: We found out that the tests passes when changing the seed in https://github.com/dusk-network/plonk/blob/29c9500a5395f49869b4372ef8cd2b6a02395c5c/tests/logic.rs#L240.

Actually, the part failing is this one: https://github.com/dusk-network/plonk/blob/29c9500a5395f49869b4372ef8cd2b6a02395c5c/tests/logic.rs#L105

EDIT 2: The problem is in the test itself. It computes an xor operation without taking into account the modulus applied to all operations. Basically:

((a ^ b) & bit_mask) % mod != (((a ^ b) % mod) & bit_mask) % mod