Skip to content

Commit

Permalink
Merge pull request #17 from macfarla/alu-mul
Browse files Browse the repository at this point in the history
MulTracer
  • Loading branch information
Gabriel-Trintinalia authored Apr 26, 2023
2 parents 1f2813a + c401c4c commit b00e634
Show file tree
Hide file tree
Showing 9 changed files with 1,483 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/java/net/consensys/linea/zktracer/OpCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public enum OpCode {
SGT(0x13),
EQ(0x14),
ISZERO(0x15),
// mul
MUL(0x02),
EXP(0x0a),
// shf
SHL(0x1b),
SHR(0x1c),
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/consensys/linea/zktracer/ZkTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.consensys.linea.zktracer.module.ModuleTracer;
import net.consensys.linea.zktracer.module.alu.add.AddTracer;
import net.consensys.linea.zktracer.module.alu.mod.ModTracer;
import net.consensys.linea.zktracer.module.alu.mul.MulTracer;
import net.consensys.linea.zktracer.module.shf.ShfTracer;
import net.consensys.linea.zktracer.module.wcp.WcpTracer;

Expand All @@ -42,7 +43,8 @@ public ZkTracer(final ZkTraceBuilder zkTraceBuilder, final List<ModuleTracer> tr
public ZkTracer(final ZkTraceBuilder zkTraceBuilder) {
this(
zkTraceBuilder,
List.of(new ShfTracer(), new WcpTracer(), new AddTracer(), new ModTracer()));
List.of(
new MulTracer(), new ShfTracer(), new WcpTracer(), new AddTracer(), new ModTracer()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static Bytes16 leftPad(Bytes value) {
* Right pad a {@link Bytes} value with zero bytes to create a {@link Bytes16}.
*
* @param value The bytes value pad.
* @return A {@link Bytes16} that exposes the rightw-padded bytes of {@code value}.
* @return A {@link Bytes16} that exposes the right-padded bytes of {@code value}.
* @throws IllegalArgumentException if {@code value.size() > 16}.
*/
static Bytes16 rightPad(Bytes value) {
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/net/consensys/linea/zktracer/module/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,21 @@ public static UInt256 multiplyRange(Bytes[] range1, Bytes[] range2) {
UInt256 sum = UInt256.ZERO;
for (int i = 0; i < range1.length; i++) {
UInt256 prod =
UInt256.fromBytes(range1[i]).multiply(UInt256.fromBytes(range2[range2.length - i - 1]));
UInt256.fromBytes(range1[i]).multiply(UInt256.fromBytes(range2[range2.length - i - 1]));
sum = sum.add(prod);
}
return sum;
}
/**
* Converts a boolean value to a byte (1 for true and 0 for false).
*
* @param b The boolean value to be converted.
* @return A byte representing the input boolean value.
*/
public static byte boolToByte(boolean b) {
if (b) {
return 1;
}
return 0;
}
}
Loading

0 comments on commit b00e634

Please sign in to comment.