This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Extremely verbose at the moment... | |
// | |
// | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
int p; // Group of order p | |
int * ZpStar; // Set of integers coprime with p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//a^b mod c with a possibly huge b | |
int power_mod(int a, int b, int c) | |
{ | |
if (b * log(a) > 9) //9 digits is my max, could change this to be dynamic for your compiler. | |
{ | |
int b1 = b/2; | |
int b2 = b/2; | |
if (!(b % 2)) b2++; |