maci
maci copied to clipboard
Ciphertext elements generated by encrypt() can be larger than the field size
This branch demonstrates the issue:
https://github.com/privacy-scaling-explorations/maci/compare/master...weijiekoh:maci:issue/ciphertext-size?expand=1#diff-c594eb0d370b319c8d21098d9c1a73f5e6b3a98895588dff46120ed9298b7e28
More often than not, the test should fail with the message The ciphertext should be smaller than the snark field size
.
The reason is as such:
encrypt()
in maci-crypto
with large enough plaintexts can lead to ciphertexts that exceed the prime field. See:
https://github.com/privacy-scaling-explorations/maci/blob/master/crypto/ts/index.ts#L256
const ciphertext: Ciphertext = {
iv,
data: plaintext.map((e: BigInt, i: number): BigInt => {
return e + mimc7.hash(
sharedKey,
iv + BigInt(i),
)
}),
}
I'm not sure how this issue bubbles up the stack and whether it's resolved at a higher level. Thanks @cryptopapi997 for raising this issue in the iden3 Telegram group!
This is most likely related to issue #460 as well. Ensuring the correctness here between the two implementations would probably squash this.
in v1 we are using poseidon Encryption, thus I believe this can be closed as v0.x is not supported anymore.