arnaucube
arnaucube/circomPublic Self-hosted repository
circom/c/buildasm/main.c
c/buildasm/main.cRaw
 1#include <stdio.h>
 2#include <stdlib.h>
 3#include <assert.h>
 4#include "fr.h"
 5
 6int main() {
 7    Fr_init();
 8/*
 9    FrElement a = { 0, Fr_LONGMONTGOMERY, {1,1,1,1}};
10    FrElement b = { 0, Fr_LONGMONTGOMERY, {2,2,2,2}};
11
12
13    FrElement a={0x43e1f593f0000000ULL,0x2833e84879b97091ULL,0xb85045b68181585dULL,0x30644e72e131a029ULL};
14    FrElement b = {3,0,0,0};
15
16    FrElement c;
17*/
18//    Fr_add(&(c[0]), a, a);
19//    Fr_add(&(c[0]), c, b);
20
21/*
22    for (int i=0; i<1000000000; i++) {
23        Fr_mul(&c, &a, &b);
24    }
25
26    Fr_mul(&c,&a, &b);
27*/
28
29/*
30    FrElement a1[10];
31    FrElement a2[10];
32    for (int i=0; i<10; i++) {
33        a1[i].type = Fr_LONGMONTGOMERY;
34        a1[i].shortVal =0;
35        for (int j=0; j<Fr_N64; j++) {
36            a2[i].longVal[j] = i;
37        }
38    }
39
40    Fr_copyn(a2, a1, 10);
41
42    for (int i=0; i<10; i++) {
43        char *c1 = Fr_element2str(&a1[i]);
44        char *c2 = Fr_element2str(&a2[i]);
45        printf("%s\n%s\n\n", c1, c2);
46        free(c1);
47        free(c2);
48    }
49*/
50
51    int tests[7] = { 0, 1, 2, -1, -2, 0x7FFFFFFF, (int)0x80000000};
52    for (int i=0; i<7;i++) {
53        FrElement a = { tests[i], Fr_SHORT, {0,0,0,0}};
54        Fr_toLongNormal(&a);
55        int b = Fr_toInt(&a);
56        int c = Fr_isTrue(&a);
57        printf("%d, %d, %d\n", tests[i], b, c);
58    }
59
60    FrElement err = { 0, Fr_LONGMONTGOMERY, {1,1,1,1}};
61    Fr_toInt(&err);
62
63    // printf("%llu, %llu, %llu, %llu\n", c.longVal[0], c.longVal[1], c.longVal[2], c.longVal[3]);
64}