-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBigInt.h
More file actions
64 lines (44 loc) · 1.26 KB
/
Copy pathBigInt.h
File metadata and controls
64 lines (44 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// Created by noeim on 03/02/2020.
//
#ifndef ALGORITHMICONBIGNUMBER_BIGINT_H
#define ALGORITHMICONBIGNUMBER_BIGINT_H
#import <vector>
#include <cstring>
#import <iostream>
#include <cmath>
#include <bitset>
using namespace std;
class BigInt {
public:
int size;
unsigned int vector_size = 0;
vector<uint64_t> value;
BigInt(int siz, vector<uint64_t> vect);
friend bool operator>(BigInt A, BigInt B) {
for (int i = 0; i < A.vector_size; i++) {
if (A.value[i] > B.value[i]) {
return true;
} else if (A.value[i] < B.value[i]) {
return false;
}
}
return false;
};
void print();
BigInt add(BigInt B);
BigInt addModular(BigInt B, BigInt p);
friend BigInt operator+(BigInt A, BigInt B) {
return A.add(B);
}
BigInt substract(BigInt B, BigInt p);
BigInt multiply(BigInt B);
void reset();
BigInt montgomery(BigInt B, BigInt r, BigInt v, BigInt p);
void extend_to_size(int size);
void reduce_size_to(int size);
};
BigInt mask_with_k(BigInt a, int k);
BigInt elementar_montgomery(BigInt A, BigInt B, BigInt v, BigInt p, int k);
BigInt shift_to_right(BigInt a, int k);
#endif //ALGORITHMICONBIGNUMBER_BIGINT_H