mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-07 03:06:42 +01:00
Arrays working
This commit is contained in:
@@ -142,7 +142,7 @@ void Circom_CalcWit::checkConstraint(PBigInt value1, PBigInt value2, char const
|
||||
#ifdef SANITY_CHECK
|
||||
if (mpz_cmp(*value1, *value2) != 0) {
|
||||
char *pcV1 = mpz_get_str(0, 10, *value1);
|
||||
char *pcV2 = mpz_get_str(0, 10, *value1);
|
||||
char *pcV2 = mpz_get_str(0, 10, *value2);
|
||||
std::string sV1 = std::string(pcV1);
|
||||
std::string sV2 = std::string(pcV2);
|
||||
free(pcV1);
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
#include "zqfield.h"
|
||||
|
||||
ZqField::ZqField(PBigInt ap) {
|
||||
mpz_init2(tmp, 1024);
|
||||
mpz_init_set(p, *ap);
|
||||
mpz_init_set_ui(zero, 0);
|
||||
mpz_init_set_ui(one, 1);
|
||||
}
|
||||
|
||||
ZqField::~ZqField() {
|
||||
mpz_clear(tmp);
|
||||
mpz_clear(p);
|
||||
mpz_clear(zero);
|
||||
mpz_clear(one);
|
||||
}
|
||||
|
||||
void ZqField::add(PBigInt r, PBigInt a, PBigInt b) {
|
||||
mpz_add(*r,*a,*b);
|
||||
mpz_fdiv_r(*r, *r, p);
|
||||
mpz_add(tmp,*a,*b);
|
||||
mpz_fdiv_r(*r, tmp, p);
|
||||
}
|
||||
|
||||
void ZqField::mul(PBigInt r, PBigInt a, PBigInt b) {
|
||||
mpz_mul(tmp,*a,*b);
|
||||
mpz_fdiv_r(*r, tmp, p);
|
||||
}
|
||||
|
||||
void ZqField::lt(PBigInt r, PBigInt a, PBigInt b) {
|
||||
|
||||
@@ -4,15 +4,18 @@
|
||||
#include "circom.h"
|
||||
|
||||
class ZqField {
|
||||
mpz_t tmp;
|
||||
|
||||
public:
|
||||
BigInt p;
|
||||
BigInt one;
|
||||
BigInt zero;
|
||||
ZqField(PBigInt ap);
|
||||
~ZqField();
|
||||
|
||||
void copyn(PBigInt a, PBigInt b, int n);
|
||||
void add(PBigInt r,PBigInt a, PBigInt b);
|
||||
void mul(PBigInt r,PBigInt a, PBigInt b);
|
||||
void lt(PBigInt r, PBigInt a, PBigInt b);
|
||||
int isTrue(PBigInt a);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user