diff --git a/libsnark/gadgetlib1/gadgets/cpu_checkers/tinyram/tinyram_cpu_checker.tcc b/libsnark/gadgetlib1/gadgets/cpu_checkers/tinyram/tinyram_cpu_checker.tcc index 736f365f..b0ea2d6d 100644 --- a/libsnark/gadgetlib1/gadgets/cpu_checkers/tinyram/tinyram_cpu_checker.tcc +++ b/libsnark/gadgetlib1/gadgets/cpu_checkers/tinyram/tinyram_cpu_checker.tcc @@ -326,12 +326,12 @@ void tinyram_cpu_checker::generate_r1cs_witness_other(tinyram_input_tape } this->pb.val(read_not1) = this->pb.val(opcode_indicators[tinyram_opcode_READ]) * (FieldT::one() - this->pb.val(arg2val->packed)); - if (this->pb.val(read_not1) != FieldT::one()) + if (this->pb.val(read_not1) != FieldT::zero()) { - /* reading from tape other than 0 raises the flag */ + /* reading from tape other than 1 raises the flag */ this->pb.val(instruction_flags[tinyram_opcode_READ]) = FieldT::one(); } - else + else if (this->pb.val(opcode_indicators[tinyram_opcode_READ]) != FieldT::zero()) { /* otherwise perform the actual read */ if (aux_it != aux_end) diff --git a/libsnark/relations/ram_computations/rams/tinyram/tinyram_aux.cpp b/libsnark/relations/ram_computations/rams/tinyram/tinyram_aux.cpp index 8866275e..d7845149 100644 --- a/libsnark/relations/ram_computations/rams/tinyram/tinyram_aux.cpp +++ b/libsnark/relations/ram_computations/rams/tinyram/tinyram_aux.cpp @@ -117,7 +117,7 @@ void ensure_tinyram_opcode_value_map() std::vector generate_tinyram_prelude(const tinyram_architecture_params &ap) { std::vector result; - const size_t increment = libff::log2(ap.w)/8; + const size_t increment = ap.w/8; const size_t mem_start = 1ul<<(ap.w-1); result.emplace_back(tinyram_instruction(tinyram_opcode_STOREW, true, 0, 0, 0)); // 0: store.w 0, r0 result.emplace_back(tinyram_instruction(tinyram_opcode_MOV, true, 0, 0, mem_start)); // 1: mov r0, 2^{W-1}