}
}
-function xfail_ge_is_canonical_one (vector: i32, position: i32, mask: i32, data: StaticArray<u8>): void {
+function xfail_ge_is_canonical (vector: i32, t: i32, data: StaticArray<u8>): void {
if (ge_is_canonical(data)) {
- raise(ERROR_SELFTEST_XFAIL_ONE, vector, (position << 8) | mask)
+ raise(ERROR_SELFTEST_XFAIL_ONE, vector, t)
}
}
}
/**
- * ge_is_canonical must report "non-canonical" for every difference regardless of shape
+ * ge_is_canonical must report "canonical" for every `s` less than `p` and
+ * "non-canonical" for every `s` equal to or greater than `p`.
+ *
* - `zeros`: lower boundary with every bit cleared
* - `ones`: upper boundary with every bit set
* - `spread`: all bytes distinct from each other and setting each bit to 0 or 1
memory.copy(changetype<usize>(actual), changetype<usize>(expected), KEY_BYTELENGTH)
xpass_ge_is_canonical(v, actual)
- for (let i = 0; i < KEY_BYTELENGTH; i++) {
+ // verify all 19 non-canonical encodings fail
+ for (let i = 0; i <= 19; i++) {
+ actual[31] -= u8(i)
+ xfail_ge_is_canonical(v, i, actual)
+ actual[31] = expected[i]
+ }
- // verify any individual bit difference fails
- for (let j = 1; j < 256; j++) {
- actual[i] ^= u8(j)
- xfail_ge_is_canonical_one(v, i, j, actual)
- actual[i] = expected[i]
- }
+ for (let i = 0; i < KEY_BYTELENGTH; i++) {
// verify |= was not replaced by ^= or += due to a typo
// invisible to single byte checks, caught only by comparing byte pairs