aboutsummaryrefslogtreecommitdiff
path: root/numalgo.h
blob: 2304e946870e715e0c2fe3d869094b76ada01819 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once

#include <cstdint>
#include "bigint.h"

Bigint gcd(Bigint a,Bigint b);
Bigint egcd(const Bigint &a,const Bigint &b,Bigint &x,Bigint &y);

Bigint expmod(const Bigint &base,const Bigint &exponent,const Bigint &modulus);

int jacobiSymbol(Bigint a,Bigint n);

// Returns sqrt(n), rounded down if necessary
Bigint isqrt(const Bigint &n);

int ilog2(uint64_t i);

Bigint cryptrandom_big(const Bigint &upperbound); //Return value in [0,upperbound]