Skip to content

IntModInv

Usage example (Cross-references)

Usage examples (Cross-references)
        bool ok      = false;
    
        ok = IntModInv(&inverse, b, modulus);
        if (!ok) {
            IntDeinit(&inverse);
    }
    
    bool IntModInv(Int *result, const Int *value, const Int *modulus) {
        ValidateInt(result);
        ValidateInt(value);
    
    bool test_int_mod_inv(void) {
        WriteFmt("Testing IntModInv\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Int check        = IntInit(&alloc.base);
    
        bool result = IntModInv(&result_value, &value, &mod);
        result      = result && (IntToU64(&result_value) == 4);
    
    bool test_int_mod_inv_no_solution(void) {
        WriteFmt("Testing IntModInv no-solution case\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Int result_value = IntFrom(99, &alloc.base);
    
        bool result = !IntModInv(&result_value, &value, &mod);
        result      = result && (IntToU64(&result_value) == 99);
Last updated on