w3f / apk-proofs

Apache License 2.0
56 stars 19 forks source link

Counting prover can falsely prove the statement for count+1 #27

Open swasilyev opened 2 years ago

swasilyev commented 2 years ago

For efficiency reasons APK computation is arithmetized using incomplete affined addition formula for SW curves. To make exceptional cases (adding the same/opposite point) impossible, we start the computation from a 'seed' point in G1 complement, E\G1:

partial_sums[0] = seed partial_sums[i+1] = partial_sums[i] + bitmask[i] * public_keys[i], i = 0, ..., domain_size-2

It follows that the last bit bitmask[domain_size-1] remains unconstrained by the (conditional) affine addition gate. This doesn't affect 'basic' and 'packed' schemes where verifier has access to the bitmask as a public input. However, in the 'counting' scheme prover can set bitmask[domain_size-1] = true, and falsely prove the statement for count = actual_count + 1.

The issue can be fixed in different ways:

  1. Constraint bitmask[domain_size-1] = false, by showing that bitmask(X) * L_{domain_size-1}(X) = 0 over the domain.
  2. Assume that bitmask[domain_size-1] = true. Then the verifier decrements the count claimed by the prover. In this case the prover still can cheat by claiming count = actual_count - 1, that is better, though not perfect.