boltlabs-inc / tss-ecdsa

An implementation of a threshold ECDSA signature scheme
Other
12 stars 5 forks source link

Fix "negative tests" in pifac #465

Closed marsella closed 11 months ago

marsella commented 1 year ago

The pifac module includes lots of tests, but some of them are not testing exactly what they say they are testing. We need to review these and fix documentation / test names for the ones that are misleading.

Specifically, the test test_no_small_factors_proof_negative_cases() has many test of the following form:

// for a given valid `input` and `proof`:
let invalid_proof = PiFacProof::prove(input, ... other bad fields ...)?;
let invalid_input = CommonInput::new(...bad things...);
assert!(invalid_proof.verify(invalid_input, &(), &mut transcript()).is_err());

This applies to small_proof, and the two mixed_proofs.

However, these tests are failing because the common input is different between proving (input) and verifying (invalid_input), so the challenge will be wrong. It's a bit hard to tell because this proof, unlike the others, doesn't specifically include the challenge in the proof, so it's not explicit in the logs. If you print out the challenge in proving and verifying, though, you'll see it's different.

However, the proofs are trying to demonstrate different properties:

In fact, I think these test won't ever work because the proof actually tests that no factors are too large (e.g. the range check is an upper bound, not a lower bound). It doesn't explicitly encode that the modulus is supposed to be 2048 bits. See test_modulus_cannot_have_large_factors for the thing we can actually verify.

So, action items that remain are