Skip to content

Commit f76b52a

Browse files
author
gefeili
committed
replace Mayo.GF16Utils.inverseF with GF16.inv
1 parent 9d609da commit f76b52a

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/mayo/GF16Utils.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,6 @@ static void mulAddMUpperTriangularMatXMatTrans(int mVecLimbs, long[] bsMat, byte
208208
}
209209
}
210210

211-
/**
212-
* Computes the multiplicative inverse in GF(16) for a GF(16) element.
213-
*/
214-
static byte inverseF(int a)
215-
{
216-
// In GF(16), the inverse can be computed via exponentiation.
217-
int a2 = GF16.mul(a, a);
218-
int a4 = GF16.mul(a2, a2);
219-
int a8 = GF16.mul(a4, a4);
220-
int a6 = GF16.mul(a2, a4);
221-
return (byte)GF16.mul(a8, a6);
222-
}
223-
224211
/**
225212
* Performs a GF(16) carryless multiplication of a nibble (lower 4 bits of a)
226213
* with a 64-bit word b, then reduces modulo the polynomial x⁴ + x + 1 on each byte.

core/src/main/java/org/bouncycastle/pqc/crypto/mayo/MayoSigner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ void ef(byte[] A, int nrows, int ncols)
762762
}
763763

764764
// Multiply the pivot row by the inverse of the pivot element.
765-
vecMulAddU64(rowLen, pivotRow, GF16Utils.inverseF(pivot), pivotRow2);
765+
vecMulAddU64(rowLen, pivotRow, GF16.inv((byte)pivot), pivotRow2);
766766

767767
// Conditionally write the pivot row back into the correct row (if pivot is nonzero).
768768
for (int row = lowerBound, rowRowLen = lowerBound * rowLen; row <= upperBound; row++, rowRowLen += rowLen)

core/src/main/java/org/bouncycastle/util/GF16.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,17 @@ public static int mul(int a, int b)
6565
return MT4B[a << 4 | b];
6666
}
6767

68+
/**
69+
* Computes the multiplicative inverse in GF(16) for a GF(16) element.
70+
*/
6871
public static byte inv(byte a)
6972
{
7073
return INV4B[a & 0xF];
74+
// int a2 = GF16.mul(a, a);
75+
// int a4 = GF16.mul(a2, a2);
76+
// int a8 = GF16.mul(a4, a4);
77+
// int a6 = GF16.mul(a2, a4);
78+
// return (byte)GF16.mul(a8, a6);
7179
}
7280

7381
/**

0 commit comments

Comments
 (0)