diff --git a/tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/ALU.cpp b/tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/ALU.cpp index e98a196..843753e 100644 --- a/tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/ALU.cpp +++ b/tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/ALU.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -132,7 +133,7 @@ void ALU_Gadget::createInternalComponents() { resultVariables_); components_[Opcode::UDIV] = ALU_UDIV_Gadget::create(pb_, inputVariables_, resultVariables_); - components_[Opcode::UMOD] = ALU_UDIV_Gadget::create(pb_, inputVariables_, + components_[Opcode::UMOD] = ALU_UMOD_Gadget::create(pb_, inputVariables_, resultVariables_); components_[Opcode::CMPE] = ALU_CMPE_Gadget::create(pb_, inputVariables_, resultVariables_); @@ -963,7 +964,7 @@ void ALU_UDIV_Gadget::generateConstraints(){ unpackResult_g_->generateConstraints(); const size_t & registerLength = tinyRAMparams()->registerLength(); for (size_t i = 0; i < registerLength; i++) - enforceBooleanity(witnessRemainder_[i], Opcode::UMOD); + enforceBooleanity(witnessRemainder_[i], Opcode::UDIV); mult_g_->generateConstraints(); if (standAlone_) unpackArg1_g_->generateConstraints(); @@ -1789,10 +1790,14 @@ void ALU_ANSWER_Gadget::generateWitness(){ flag = false; if (Algebra::one() == program_output) program_output = pb_->val(inputs_.arg2_val_); - /* - * size_t a = mapFieldElementToInteger(0, EXTDIM, pb_->val(inputs_.arg2_val_)); - * std::cout << "\n*** TIMESTEPS=" << max_timestep << " ANSWER=" << a << " (binary " << std::bitset(a) << ")\n" << std::endl; - */ + + /** + * Uncomment the following lines to print the result of ANSWER + **/ + + // size_t a = mapFieldElementToInteger(0, EXTDIM, pb_->val(inputs_.arg2_val_)); + // std::cout << "\n*** TIMESTEPS=" << max_timestep << " ANSWER=" << a << " (binary " << std::bitset(a) << ")\n" << std::endl; + } } diff --git a/tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/traceConsistency.cpp b/tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/traceConsistency.cpp index 1e1f7f9..ea8e1d9 100644 --- a/tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/traceConsistency.cpp +++ b/tinyram/stark-tinyram/src/TinyRAMtoBair/RamToContraintSystem/traceConsistency.cpp @@ -166,9 +166,15 @@ case Opcode::OR: case Opcode::XOR: case Opcode::MOV: + case Opcode::CMOV: case Opcode::SHL: case Opcode::SHR: + case Opcode::SHAR: case Opcode::MULL: + case Opcode::UMULH: + case Opcode::SMULH: + case Opcode::UDIV: + case Opcode::UMOD: case Opcode::RESERVED_OPCODE_24: selectorToConstraint[j] = 0; //constraintPoly = constraintPoly + (selector_j * (regiSecond + aluOutput_.result_)); @@ -300,10 +306,16 @@ case Opcode::AND: case Opcode::OR: case Opcode::XOR: + case Opcode::MOV: + case Opcode::CMOV: case Opcode::SHL: case Opcode::SHR: - case Opcode::MOV: + case Opcode::SHAR: case Opcode::MULL: + case Opcode::UMULH: + case Opcode::SMULH: + case Opcode::UDIV: + case Opcode::UMOD: case Opcode::RESERVED_OPCODE_24: pb_->val(regiSecond) = pb_->val(aluOutput_.result_); break;