arnaucube
arnaucube/circomPublic Self-hosted repository
circom/c/zqfield.h
c/zqfield.hRaw
 1#ifndef ZQFIELD_H
 2#define ZQFIELD_H
 3
 4#include "circom.h"
 5
 6class ZqField {
 7    mpz_t tmp;
 8
 9public:
10    BigInt p;
11    BigInt one;
12    BigInt zero;
13    size_t nBits;
14    BigInt mask;
15    ZqField(PBigInt ap);
16    ~ZqField();
17
18    void copyn(PBigInt a, PBigInt b, int n);
19
20    void add(PBigInt r,PBigInt a, PBigInt b);
21    void sub(PBigInt r,PBigInt a, PBigInt b);
22    void neg(PBigInt r,PBigInt a);
23    void mul(PBigInt r,PBigInt a, PBigInt b);
24    void div(PBigInt r,PBigInt a, PBigInt b);
25    void idiv(PBigInt r,PBigInt a, PBigInt b);
26    void mod(PBigInt r,PBigInt a, PBigInt b);
27    void pow(PBigInt r,PBigInt a, PBigInt b);
28
29    void lt(PBigInt r, PBigInt a, PBigInt b);
30    void eq(PBigInt r, PBigInt a, PBigInt b);
31    void gt(PBigInt r, PBigInt a, PBigInt b);
32    void leq(PBigInt r, PBigInt a, PBigInt b);
33    void geq(PBigInt r, PBigInt a, PBigInt b);
34    void neq(PBigInt r, PBigInt a, PBigInt b);
35
36    void land(PBigInt r, PBigInt a, PBigInt b);
37    void lor(PBigInt r, PBigInt a, PBigInt b);
38    void lnot(PBigInt r, PBigInt a);
39
40    void band(PBigInt r, PBigInt a, PBigInt b);
41    void bor(PBigInt r, PBigInt a, PBigInt b);
42    void bxor(PBigInt r, PBigInt a, PBigInt b);
43    void bnot(PBigInt r, PBigInt a);
44    void shl(PBigInt r, PBigInt a, PBigInt b);
45    void shr(PBigInt r, PBigInt a, PBigInt b);
46
47    int isTrue(PBigInt a);
48    int toInt(PBigInt a);
49};
50
51#endif // ZQFIELD_H