IntSquareMod
Description
Compute (value^2) mod modulus.
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the reduced square |
value |
in | Value to square |
modulus |
in | Modulus |
Usage example (from documentation)
IntSquareMod(&result, &value, &modulus);Success
Returns true. *result holds (value * value) mod modulus.
Failure
Returns false on modulus == 0 or allocator OOM. *result is left untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:2502:
}
bool IntSquareMod(Int *result, const Int *value, const Int *modulus) {
return IntModMul(result, value, value, modulus);
}- In
Int.c:2931:
for (i = 1; i < m; i++) {
if (!IntSquareMod(&scratch, &t_power, modulus)) {
IntDeinit(&scratch);
IntDeinit(&t_power);- In
Int.c:2980:
Int square = IntInit(IntAllocator(result));
if (!IntSquareMod(&square, &b, modulus)) {
IntDeinit(&square);
IntDeinit(&b);- In
Int.c:3016:
r = next;
if (!IntSquareMod(&b_sq, &b, modulus)) {
IntDeinit(&b);
IntDeinit(&b_sq);- In
Int.c:3164:
Int next = IntInit(IntAllocator(value));
if (!IntSquareMod(&next, &x, value)) {
IntDeinit(&next);
IntDeinit(&base);- In
Math.c:663:
bool test_int_square_mod(void) {
WriteFmt("Testing IntSquareMod\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:671:
Int result_value = IntInit(&alloc.base);
IntSquareMod(&result_value, &value, &mod);
bool result = IntToU64(&result_value) == 94;- In
Math.c:851:
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
result = result && (IntCompare(&check, 10) == 0);- In
Math.c:1153:
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
// result written, returns true, and root^2 == value (mod p).
- In
Math.c:1210:
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
result = result && (IntCompare(&check, 2) == 0);- In
Math.c:1240:
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
result = result && (IntCompare(&check, 4) == 0);- In
Math.c:1270:
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
result = result && (IntCompare(&check, 3) == 0);- In
Math.c:1299:
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
result = result && (IntCompare(&check, 2) == 0);- In
Math.c:1325:
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
result = result && (IntCompare(&check, 10) == 0);- In
Math.c:1511:
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
// root^2 must equal the *reduced* value 2, not 23.
- In
Math.c:2988:
bool ok = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
bool result = ok && (IntCompare(&check, 2) == 0);- In
Math.c:4271:
Int r = IntFrom(7u, a);
bool ok = IntSquareMod(&r, &x, &m);
ok = ok && IntToU64(&r) == (12345ull * 12345ull) % 1009ull;- In
Math.c:4754:
bool ok = IntModSqrt(&root, &value, &modulus);
ok = ok && IntSquareMod(&check, &root, &modulus);
ok = ok && IntCompare(&check, 9u) == 0;- In
Math.c:4777:
bool ok = IntModSqrt(&root, &value, &modulus);
ok = ok && IntSquareMod(&check, &root, &modulus);
ok = ok && IntCompare(&check, 2u) == 0;
Last updated on