IntModSqrt
Description
Compute a modular square root.
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the root |
value |
in | Value whose square root is requested |
modulus |
in | Modulus |
Usage example (from documentation)
bool ok = IntModSqrt(&root, &value, &modulus);Success
Returns true when a modular square root exists.
Failure
Returns false otherwise.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:2428:
}
bool IntModSqrt(Int *result, const Int *value, const Int *modulus) {
ValidateInt(result);
ValidateInt(value);- In
Int.Math.c:831:
bool test_int_mod_sqrt(void) {
WriteFmt("Testing IntModSqrt\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:840:
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);
IntSquareMod(&check, &root, &mod);
result = result && (IntCompare(&check, 10) == 0);- In
Int.Math.c:853:
bool test_int_mod_sqrt_no_solution(void) {
WriteFmt("Testing IntModSqrt no-solution case\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:861:
Int root = IntFrom(99, &alloc.base);
bool result = !IntModSqrt(&root, &value, &mod);
result = result && (IntCompare(&root, 99) == 0);
Last updated on