o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps
https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp
Apache License 2.0
475 stars 105 forks source link

`ForeignField.toBits()` discards high limbs of unreduced elements for input bit lengths < 176 #1616

Closed mitschabaude closed 2 months ago

mitschabaude commented 2 months ago

https://github.com/o1-labs/o1js/blob/ea199efea8f393fa72a5d672762812a88989efec/src/lib/provable/foreign-field.ts#L356-L360

This behaviour is incorrect since we don't prove the higher limbs are zero! The simple fix is to add assertions that they are.

mitschabaude commented 2 months ago

closed by #1617