Skip to content

Commit 30aa1aa

Browse files
committed
[ripemd160] Small optimizations for compression
1 parent 37df258 commit 30aa1aa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/frontend/src/circuits/ripemd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn f(b: &CircuitBuilder, x: Wire, y: Wire, z: Wire) -> Wire {
169169

170170
// Selection function g(x, y, z) = (x AND y) OR (NOT x AND z) = z XOR (x AND (y XOR z))
171171
fn g(b: &CircuitBuilder, x: Wire, y: Wire, z: Wire) -> Wire {
172-
b.bor(b.band(x, y), b.band(b.bnot(x), z))
172+
b.bxor(z, b.band(x, b.bxor(y, z)))
173173
}
174174

175175
// Selection function h(x, y, z) = (x OR NOT y) XOR z
@@ -179,7 +179,7 @@ fn h(b: &CircuitBuilder, x: Wire, y: Wire, z: Wire) -> Wire {
179179

180180
// Selection function i(x, y, z) = (x AND z) OR (y AND NOT z) = y XOR (z AND (x XOR y))
181181
fn i(b: &CircuitBuilder, x: Wire, y: Wire, z: Wire) -> Wire {
182-
b.bor(b.band(x, z), b.band(y, b.bnot(z)))
182+
b.bxor(y, b.band(z, b.bxor(x, y)))
183183
}
184184

185185
// Selection function j(x, y, z) = x XOR (y OR NOT z)

0 commit comments

Comments
 (0)