aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/primitives.ml12
-rw-r--r--test/test_curves.ml85
-rw-r--r--test/test_e.ml2
-rw-r--r--test/test_e12.ml455
-rw-r--r--test/test_e2.ml2
-rw-r--r--test/test_fp.ml2
-rw-r--r--test/test_fp12.ml4
-rw-r--r--test/test_fp2.ml4
-rw-r--r--test/test_pairing.ml41
-rw-r--r--test/test_plonkers.ml2
10 files changed, 40 insertions, 569 deletions
diff --git a/test/primitives.ml b/test/primitives.ml
index 66d25b9..f2cd043 100644
--- a/test/primitives.ml
+++ b/test/primitives.ml
@@ -1,6 +1,6 @@
-open Plonkers.Curves
-open Plonkers.Fields
-open Plonkers.Pairing
+open Plonkers.Bls12_381.Fields
+open Plonkers.Bls12_381.Curves
+open Plonkers.Bls12_381.Pairing
module Literals = struct
let fp = Fp.of_string
@@ -8,9 +8,6 @@ module Literals = struct
let fp12 c = Fp12.of_coeffs @@ Array.map fp c
let e (x, y) = E.Unsafe.of_coords_unchecked (fp x, fp y)
let e2 (x, y) = E2.Unsafe.of_coords_unchecked (fp2 x, fp2 y)
- let e12 (x, y) = E12.Unsafe.of_coords_unchecked (fp12 x, fp12 y)
- let g1 = e
- let g2 = e2
let gt c = Gt.Unsafe.of_f_unchecked @@ fp12 c
end
@@ -20,8 +17,5 @@ module Testables = struct
let fp12 = Testable.make Fp12.to_string Fp12.equal
let e = Testable.make E.to_string E.equal
let e2 = Testable.make E2.to_string E2.equal
- let e12 = Testable.make E12.to_string E12.equal
- let g1 = e
- let g2 = e2
let gt = Testable.make Gt.to_string Gt.equal
end
diff --git a/test/test_curves.ml b/test/test_curves.ml
deleted file mode 100644
index 143211c..0000000
--- a/test/test_curves.ml
+++ /dev/null
@@ -1,85 +0,0 @@
-module E2 = Plonkers.Curves.E2
-module E12 = Plonkers.Curves.E12
-
-let twist = Plonkers.Curves.twist
-let f2 = Primitives.Literals.e2
-let e12 = Primitives.Testables.e12
-let f12 = Primitives.Literals.e12
-
-let test_twist () =
- Alcotest.(check e12)
- "equals"
- (f2
- ( [|
- "1540172915528940641891926116690100808044692623394504676677921357014659026860895709663805875815315907372328317299798";
- "3225331128895415615728432739064042093474368865193551026434624504244808875880021719074327461050513525930991560321555";
- |],
- [|
- "3821166946900648900183417606277705329456497739035474648486543021526386081458734393093714179436014613784026951537426";
- "3271903498375440374313099549367347360713300158269487781915162011178571021409894476750657145495514462848190134148570";
- |] )
- |> twist)
- (f12
- ( [|
- "0";
- "0";
- "0";
- "0";
- "1540172915528940641891926116690100808044692623394504676677921357014659026860895709663805875815315907372328317299798";
- "0";
- "0";
- "0";
- "0";
- "0";
- "2843783884294071183627148224054922720993279530869027117544380641677090749754981936926604607182106641298278757790772";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "3821166946900648900183417606277705329456497739035474648486543021526386081458734393093714179436014613784026951537426";
- "0";
- "0";
- "0";
- "0";
- "0";
- "3727777830959063130482630797280725172185284029556014452046367630950124120466417906271159112158765588569975863865359";
- "0";
- "0";
- |] ))
-
-let test_isomorphism () =
- let a =
- f2
- ( [|
- "2109508776193857273074766488410969484271072993610345872414603016106553977333420070441822701292764210251579683428522";
- "3122689516821528327894678317146234429793657826538065999063801814299529533586972120357919860380161818422867843226102";
- |],
- [|
- "1096288604042692121608580288022426533189175239933724612935896261545208643656951679037482053510338623653634164811915";
- "1170946969994232162449075722035284212661104220582295241050315080132560517926924365377907307339371864116051233088516";
- |] )
- in
- let b =
- f2
- ( [|
- "1249927438163201574866859585937475005480631005557973853506467103895431793859087897855543227858106779532090068273481";
- "3316136808132952082246855662072348414235919944257935059559541300069920601748305368149334910959656758372765105616868";
- |],
- [|
- "81743811270164858346488114131996653093309264515814483449447422378937968491505855199671526555077281996286356618484";
- "1084133614285958528564866737145829519643307320120470464135106404047274008544004224502685177052190672561703116812406";
- |] )
- in
- Alcotest.(check e12)
- "equals"
- (E2.add a b |> twist)
- (E12.add (twist a) (twist b))
-
-let tests =
- Alcotest.
- [
- test_case "Twist" `Quick test_twist;
- test_case "Isomorphism" `Quick test_isomorphism;
- ]
diff --git a/test/test_e.ml b/test/test_e.ml
index e2b5fc8..d71763c 100644
--- a/test/test_e.ml
+++ b/test/test_e.ml
@@ -1,4 +1,4 @@
-module E = Plonkers.Curves.E
+module E = Plonkers.Bls12_381.Curves.E
let e = Primitives.Testables.e
let f = Primitives.Literals.e
diff --git a/test/test_e12.ml b/test/test_e12.ml
deleted file mode 100644
index 6be08a8..0000000
--- a/test/test_e12.ml
+++ /dev/null
@@ -1,455 +0,0 @@
-module E12 = Plonkers.Curves.E12
-
-let e12 = Primitives.Testables.e12
-let f = Primitives.Literals.e12
-
-let test_strconv () =
- let a =
- f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "3091671843177195696877148918276666486988770529143376300427304497723309492066409434415541799043648972299038428357487";
- "0";
- "0";
- "0";
- "0";
- "0";
- "3815085543371984344309954270809206701981910198711326563248651510366005113177104447633168433375165299595858892446448";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "3216482895116454205593926684868111924113047860439420435341632962637183676219338960167585843036993749097939480933003";
- "0";
- "0";
- "0";
- "0";
- "0";
- "2109732944141953385179814554641632616877235126971969222393178311770562775710586207386814389023669882647548613327750";
- "0";
- "0";
- |] )
- in
- let s =
- "{(0,0,0,0,3091671843177195696877148918276666486988770529143376300427304497723309492066409434415541799043648972299038428357487,0,0,0,0,0,3815085543371984344309954270809206701981910198711326563248651510366005113177104447633168433375165299595858892446448,0);(0,0,0,3216482895116454205593926684868111924113047860439420435341632962637183676219338960167585843036993749097939480933003,0,0,0,0,0,2109732944141953385179814554641632616877235126971969222393178311770562775710586207386814389023669882647548613327750,0,0)}"
- in
- Alcotest.(check string) "equals" s (E12.to_string a);
- Alcotest.(check e12) "equals" a (E12.of_string s)
-
-let test_curve () =
- Alcotest.(check bool)
- "fails" true
- (try
- E12.of_string "{(0,0,0,0,0,0,0,0,0,0,0,0);(0,0,0,0,0,0,0,0,0,0,0,0)}"
- |> ignore;
- false
- with
- | Invalid_argument _ -> true
- | _ -> false)
-
-let test_subgroup () =
- Alcotest.(check bool)
- "fails" true
- (try
- E12.of_string
- "{(0,0,0,0,1892439472479153589801064982851113576513855369383752766070453260535595479925033899105674578530308757833348467758334,0,0,0,0,0,3933473072416727749376352748178029259523619754763125185527750551907955966209860004099303009334745298312250252056103,0);(0,0,0,794551614141569136399571058573462200719130525886688829309738555530265772199592670562441013794848828639618754399483,0,0,0,0,0,3192958957310966052428309415378437932193540333890835514256315804018770631464911425978565124930935819694042257078857,0,0)}"
- |> ignore;
- false
- with
- | Invalid_argument _ -> true
- | _ -> false)
-
-let test_add () =
- Alcotest.(check e12)
- "equals"
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "2929451176954387799194033409256344834898378201802754981173591542622666580295883587745860521250662884121876062549983";
- "0";
- "0";
- "0";
- "0";
- "0";
- "3461759878132083262758004943698898296800121697473199295622886337999821087592477923031706633208800009194815413801518";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "942624260271445495579165381526574569202111666876112362964832930049127003568811892520272165788145686052177002469346";
- "0";
- "0";
- "0";
- "0";
- "0";
- "3359602987414003489897229475537961953001886362351876752895373868269680338526524405951089727852832481417055207619739";
- "0";
- "0";
- |] ))
- (E12.add
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "3577779649806248054643775548832767759316348940252471854726074628830920332172047644506373975311425491914524969724781";
- "0";
- "0";
- "0";
- "0";
- "0";
- "2399602958687966675444499051795357243399654745487511551062570132634625817263531954834246389717858349513538423979839";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "3469592015573153874932067971174117536042353913949658146829883594661681707207832993352017346593533677053567177917365";
- "0";
- "0";
- "0";
- "0";
- "0";
- "1151400766283648126691959067795471138907053142308666569304665656476264270870733893928854872692788980876149632731266";
- "0";
- "0";
- |] ))
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "3359139998119707196528515154517032529878638458125880871059769187012893082790375046547813363647182669061408112484760";
- "0";
- "0";
- "0";
- "0";
- "0";
- "62497013792237496829604596520223735291518619338562343287921465074342037807885618452846713288828357151810745569900";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "2160638480464909694045638391084460619982867776766949998529832158649043460368937062272954230999807453239744952753962";
- "0";
- "0";
- "0";
- "0";
- "0";
- "1126329043102416166228707569418335696072154646728752961333880357646274870334482490410779225488804211857673854639763";
- "0";
- "0";
- |] )))
-
-let test_sub () =
- Alcotest.(check e12)
- "equals"
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "260820864302800499055951456737734696520749024683574951158372641177953505726197462888820002139337144943486830755127";
- "0";
- "0";
- "0";
- "0";
- "0";
- "2309504807264682131023954645694244888958846929437569256970234438110912672798339047228059898746397460880680243113234";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "1884262644549124297286999423197037917702698957768720465436456735668246940838254360191765967749870609253415859480075";
- "0";
- "0";
- "0";
- "0";
- "0";
- "1458765347227296194079361565401588615835349340270921870155075823051943355511654368453233851359781030485555331973821";
- "0";
- "0";
- |] ))
- (E12.sub
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "2548602455258519267027441838112041855729507725494336811234353266047952196432771974216852033238608280273800578504341";
- "0";
- "0";
- "0";
- "0";
- "0";
- "2506983850042387088709693983583400906243074258926729247169056174398175244377107659017228070877516224003507328999567";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "1697001650665816015571508376404481973733665579127989008532059292342460117240801454003662803080007480979986625768578";
- "0";
- "0";
- "0";
- "0";
- "0";
- "786940995340872797209857163071225469740844223100851966708730789135747927137475425247846950807186157855050793117595";
- "0";
- "0";
- |] ))
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "335585570380237738269479499019064005630181432684740610104387294850079646947794944339384592807744830934034358319148";
- "0";
- "0";
- "0";
- "0";
- "0";
- "3928039984576404929321729629401457719785598103596404127762810286191874666699102144281999415955166246019051362402625";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "2738843309836194684111788072521876850689450836525674623422145438705528038163470601918566915043088888961341964517564";
- "0";
- "0";
- "0";
- "0";
- "0";
- "1712943099674700879795417735364378450430564895281158485064468710245655725591367633459097560637616611829823884827868";
- "0";
- "0";
- |] )))
-
-let test_scalar_mul () =
- Alcotest.(check e12)
- "equals"
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "3357855297579876784089148534308911222130978631684443825955438012453799536767627749242490964002530400421373781469533";
- "0";
- "0";
- "0";
- "0";
- "0";
- "2677804744293618541446194559207414126615217723294705750716365310934351437624898175352847955786724875817376614717219";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "1915502024687773287090662296267210584286994097198288317665526658659200922203992392110288118787661761019927810880977";
- "0";
- "0";
- "0";
- "0";
- "0";
- "1760921192099020069214533105397817595823932059994647772858020372402134581938309465971031516925918886223193490944630";
- "0";
- "0";
- |] ))
- (E12.scalar_mul
- (Z.of_string
- "703594376515145504600149806566586228383250905518012106197988171833561726440")
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "1749021454757251805466302363090849032461428103311018075473114210413137797790930850580625254459899665288368449856937";
- "0";
- "0";
- "0";
- "0";
- "0";
- "2186129250262469085814801856197751909890991632841241156466941822089525090504923468858070412713902752872342023901749";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "886919149452047606753370501423204305132698474831088324208349828000112295671876445794020761886983391377923459546785";
- "0";
- "0";
- "0";
- "0";
- "0";
- "2884680018184262851673782573133878840881948626212500716086567795728465064168792509223042657485292396482495135092395";
- "0";
- "0";
- |] )))
-
-let test_neg () =
- Alcotest.(check e12)
- "equals"
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "2510731992258037488917923072779386912130593748560772070925187720759618936807988199231840501866378139127146033382420";
- "0";
- "0";
- "0";
- "0";
- "0";
- "139994380365044868720503499540211498999674505225457299682186297734122616101065195677155394940127752473050846199674";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "2953323231939446131835641091801583289848813559944641025189986405134032624530476053107287527843032990989824459319311";
- "0";
- "0";
- "0";
- "0";
- "0";
- "3006319017089597825899390606645412383505581997773614203793702942169217973661078287028360663533881006950619741641054";
- "0";
- "0";
- |] ))
- (E12.neg
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "2510731992258037488917923072779386912130593748560772070925187720759618936807988199231840501866378139127146033382420";
- "0";
- "0";
- "0";
- "0";
- "0";
- "139994380365044868720503499540211498999674505225457299682186297734122616101065195677155394940127752473050846199674";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "1049086323282221261582148733934320866708069259994366860142071730989999025960361811335400101285982673048069813240476";
- "0";
- "0";
- "0";
- "0";
- "0";
- "996090538132069567518399219090491773051300822165393681538355193954813676829759577414326965595134657087274530918733";
- "0";
- "0";
- |] )));
- let a =
- f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "174596558160867992931929381678564420867047966812951865620128480620036445313093830658810814465792025017812429878751";
- "0";
- "0";
- "0";
- "0";
- "0";
- "3492629321158940080093431519188658666684469676506878174071465032762267492492939017933177917408814913264887997167785";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "2480687101688729026958456527114342859137384944778496301906088322119864429059527285116213514015556557832700420458645";
- "0";
- "0";
- "0";
- "0";
- "0";
- "1764449632710224012943205738233577179745318497967961642347638292997400684086372242247269616317573230446730496336696";
- "0";
- "0";
- |] )
- in
- Alcotest.(check e12) "equals" E12.inf (E12.add a (E12.neg a))
-
-let test_g () =
- Alcotest.(check e12)
- "equals" E12.g
- (f
- ( [|
- "0";
- "0";
- "0";
- "0";
- "352701069587466618187139116011060144890029952792775240219908644239793785735715026873347600343865175952761926303160";
- "0";
- "0";
- "0";
- "0";
- "0";
- "1353221637328373545892060349371360746048220186341936159219732281025920769516621702780080981380240920942561918531299";
- "0";
- |],
- [|
- "0";
- "0";
- "0";
- "1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905";
- "0";
- "0";
- "0";
- "0";
- "0";
- "1472406309213353956798468635167385199506877017588472562248853724925831900559844855499883907296819622485916638215732";
- "0";
- "0";
- |] ))
-
-let tests =
- Alcotest.
- [
- test_case "String Conversion" `Quick test_strconv;
- test_case "Is On Curve" `Quick test_curve;
- test_case "Is In Canonical Subgroup" `Quick test_subgroup;
- test_case "Addition" `Quick test_add;
- test_case "Subtraction" `Quick test_sub;
- test_case "Scalar Multiplication" `Quick test_scalar_mul;
- test_case "Additive Inverse" `Quick test_neg;
- test_case "Generator" `Quick test_g;
- ]
diff --git a/test/test_e2.ml b/test/test_e2.ml
index d4f951b..fe67d15 100644
--- a/test/test_e2.ml
+++ b/test/test_e2.ml
@@ -1,4 +1,4 @@
-module E2 = Plonkers.Curves.E2
+module E2 = Plonkers.Bls12_381.Curves.E2
let e2 = Primitives.Testables.e2
let f = Primitives.Literals.e2
diff --git a/test/test_fp.ml b/test/test_fp.ml
index f3d24e6..2398e81 100644
--- a/test/test_fp.ml
+++ b/test/test_fp.ml
@@ -1,4 +1,4 @@
-module Fp = Plonkers.Fields.Fp
+module Fp = Plonkers.Bls12_381.Fields.Fp
let fp = Primitives.Testables.fp
let f = Primitives.Literals.fp
diff --git a/test/test_fp12.ml b/test/test_fp12.ml
index 040bea8..8f02f96 100644
--- a/test/test_fp12.ml
+++ b/test/test_fp12.ml
@@ -1,5 +1,5 @@
-module Fp = Plonkers.Fields.Fp
-module Fp12 = Plonkers.Fields.Fp12
+module Fp = Plonkers.Bls12_381.Fields.Fp
+module Fp12 = Plonkers.Bls12_381.Fields.Fp12
let fp12 = Primitives.Testables.fp12
let f = Primitives.Literals.fp12
diff --git a/test/test_fp2.ml b/test/test_fp2.ml
index 5059d97..6c603f7 100644
--- a/test/test_fp2.ml
+++ b/test/test_fp2.ml
@@ -1,5 +1,5 @@
-module Fp = Plonkers.Fields.Fp
-module Fp2 = Plonkers.Fields.Fp2
+module Fp = Plonkers.Bls12_381.Fields.Fp
+module Fp2 = Plonkers.Bls12_381.Fields.Fp2
let fp2 = Primitives.Testables.fp2
let f = Primitives.Literals.fp2
diff --git a/test/test_pairing.ml b/test/test_pairing.ml
index 82e4ab3..d3cdb35 100644
--- a/test/test_pairing.ml
+++ b/test/test_pairing.ml
@@ -1,13 +1,32 @@
-module Pairing = Plonkers.Pairing
-module G1 = Plonkers.Pairing.G1
-module G2 = Plonkers.Pairing.G2
-module Gt = Plonkers.Pairing.Gt
+module Pairing = Plonkers.Bls12_381.Pairing
+module E = Plonkers.Bls12_381.Curves.E
+module E2 = Plonkers.Bls12_381.Curves.E2
+module Gt = Plonkers.Bls12_381.Pairing.Gt
let gt = Primitives.Testables.gt
-let f1 = Primitives.Literals.g1
-let f2 = Primitives.Literals.g2
+let f1 = Primitives.Literals.e
+let f2 = Primitives.Literals.e2
let ft = Primitives.Literals.gt
-let test_generator () = Alcotest.(check gt) "equals" Gt.g Pairing.(e G1.g G2.g)
+
+let test_generator () =
+ Alcotest.(check gt)
+ "equals"
+ (ft
+ [|
+ "3408834164464458755751340723502736743445402614640994055433339214424916442641449510670327077303074893591740399366532";
+ "1017299873256115394687936133146817339783508925356207904663165117501336940438300180831508525168135575931758510829235";
+ "1919447955347661378578718469488414822573562393353397544098339472673901193098010131520945815709482515519580400649694";
+ "233557331756520805040932826416017142246700002714928636467514104620558679338483625829873520553081791155104026612174";
+ "2882199334237819327910933128503231887000342950792587449681715803095618652567681747054312179958427092970985872417068";
+ "579878855790610229145575079003483905368886712027403088810647643659132674704592975818766405092658613973478871626949";
+ "3268798540077874559188095304926415053902298079662269128631117894259354335713488241073281881110999874366368799440511";
+ "2688711983546324406847903726099677850388169649284572370749691792743294691894680263880362424577638309433508620982332";
+ "3520140447471844017044610248175793726488927385800919015247604269617056365166670232096113218155158979455637700602719";
+ "1555267885602801620621747613743921378408444002839854792606782732724136830563310004098024452104661167182680744848589";
+ "2626389147790168154036854297373352480470342009417426750876875476996308393122833154115295241935326582225976246741447";
+ "873321072950766150592434764742436722571574260472569072177205897167854308426485977134306337249021436737462538398830";
+ |])
+ Pairing.(e E.g E2.g)
let test_pairing () =
Alcotest.(check gt)
@@ -55,8 +74,8 @@ let test_bilinearity () =
"equals" true
(Pairing.check
[
- (G1.(scalar_mul a g), G2.(scalar_mul b g));
- (G1.(neg @@ scalar_mul b g), G2.(scalar_mul a g));
+ (E.(scalar_mul a g), E2.(scalar_mul b g));
+ (E.(neg @@ scalar_mul b g), E2.(scalar_mul a g));
])
let test_inverse () =
@@ -66,8 +85,8 @@ let test_inverse () =
"2771533846423619448760061452592233431921571821664938471039058787579168163258312047422278741446979265860731259685588"
)
in
- let t = Pairing.e a G2.g in
- let tinv = Pairing.e G1.(neg a) G2.g in
+ let t = Pairing.e a E2.g in
+ let tinv = Pairing.e E.(neg a) E2.g in
Alcotest.(check gt) "equals" (Gt.inv t) tinv;
Alcotest.(check gt) "equals" Gt.id (Gt.dot t tinv)
diff --git a/test/test_plonkers.ml b/test/test_plonkers.ml
index 4e20fba..044e937 100644
--- a/test/test_plonkers.ml
+++ b/test/test_plonkers.ml
@@ -6,7 +6,5 @@ let () =
("Fp12", Test_fp12.tests);
("E", Test_e.tests);
("E2", Test_e2.tests);
- ("E12", Test_e12.tests);
- ("Curves", Test_curves.tests);
("Pairing", Test_pairing.tests);
]