elibensasson / libSTARK

A library for zero knowledge (ZK) scalable transparent argument of knowledge (STARK)
Other
507 stars 90 forks source link

Fix typos in ALU.cpp and add missing opcodes #16

Open jimouris opened 5 years ago

jimouris commented 5 years ago

As stated in #15 UMOD seems to be broken.

There has been a typo in ALU.cpp and it was

components_[Opcode::UMOD] = ALU_UDIV_Gadget::create(pb_, inputVariables_, resultVariables_);

instead of

components_[Opcode::UMOD] = ALU_UMOD_Gadget::create(pb_, inputVariables_, resultVariables_);

That was probably a problem with UMOD, however it still seems to be broken.

iddo333 commented 5 years ago

There seems to be another typo in ALU.cpp: enforceBooleanity(witnessRemainder_[i], Opcode::UMOD) in ALU_UDIV_Gadget::generateConstraints()

I think that the unit test of UMOD should pass just fine, but yes it will still be broken when used in a TinyRAM program because it's absent from the switch statements of tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/traceConsistency.cpp (it's easy to add the missing opcodes there, and then create a TinyRAM program to test it).

jimouris commented 5 years ago

Thanks @iddo333 , I have changed the second UMOD typo and added the missing opcodes (UDIV and others were also missing). Seems ok now.