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

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

int64_t gcd(int64_t a,int64_t b);

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 bigrandom(Rng &rng,const Bigint &upperbound); //Return value in [0,upperbound]