blob: 2189c7d3004d5432a01659d916e5f1adb2c3aaf5 (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
module Fq = Plonkers.Fields.Fq
let fq = Testable.make Fq.to_string Fq.equal
let f = Fq.of_string
let test_add () =
Alcotest.(check fq)
"equals"
(f
"5034212870056682811541563993093442956024207074167934414259669251040086104221")
(Fq.add
(f
"3019612232293951348432769707427639303474751231631017441050730061639747788964")
(f
"2014600637762731463108794285665803652549455842536916973208939189400338315257"));
Alcotest.(check fq)
"equals" Fq.zero
(Fq.add
(f
"21888242871839275222246405745257275088696311157297823662689037894645226208582")
Fq.one);
Alcotest.(check fq)
"equals"
(f
"7363893478117210948657131929839491162862302555393162961985689652909776739235")
(Fq.add
(f
"7363893478117210948657131929839491162862302555393162961985689652909776739235")
Fq.zero)
let test_sub () =
Alcotest.(check fq)
"equals"
(f
"1647997538064335793847192302859723563372189463772006638527106196094592175035")
(Fq.sub
(f
"17522329235179667504196475280824254606128390327458085261948007699233694805172")
(f
"15874331697115331710349282977964531042756200863686078623420901503139102630137"));
Alcotest.(check fq)
"equals"
(f
"21888242871839275222246405745257275088696311157297823662689037894645226208582")
(Fq.sub Fq.zero Fq.one);
Alcotest.(check fq)
"equals"
(f
"1550460075629904631277637708383660261580971272511193857451434052003108082807")
(Fq.add
(f
"1550460075629904631277637708383660261580971272511193857451434052003108082807")
Fq.zero)
let test_mul () =
Alcotest.(check fq)
"equals"
(f
"20539703399960180369319660518633290048071922000666914740466234074847854697757")
(Fq.mul
(f
"16652515618518207323315643285221741056245295412987863357779458647516886387587")
(f
"15388577223719168739739036375931130294575142146897880107473273404618844312776"));
Alcotest.(check fq)
"equals" Fq.zero
(Fq.mul
(f
"10935302729977221140784701859408855206669147633587285404353277660075789680922")
Fq.zero)
let test_div () =
Alcotest.(check fq)
"equals"
(f
"7363953525538778156567393633860492517850968441297156550375719598579598367322")
(Fq.div
(f
"7363953525538778156567393633860492517850968441297156550375719598579598367322")
Fq.one)
let test_inv () =
Alcotest.(check fq)
"equals"
(f
"14812345552713361047837749161990489217154524375614120373819285291721752372748")
(Fq.inv
(f
"1160181877204925047836599448201084379181489517022839288462621953652233427695"));
Alcotest.(check fq)
"equals" Fq.one
(let a =
f
"17876831255806984619368587498426968568242044248616647019388897055879503636463"
in
Fq.mul a (Fq.inv a))
let tests =
Alcotest.
[
test_case "Addition" `Quick test_add;
test_case "Subtraction" `Quick test_sub;
test_case "Multiplication" `Quick test_mul;
test_case "Division" `Quick test_mul;
test_case "Multiplicative Inverse" `Quick test_inv;
]
|