aboutsummaryrefslogtreecommitdiff
path: root/test/test_curves.ml
blob: d3067cc87f293f400ccebc68de98f832316f6656 (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
module E2 = Plonkers.Curves.E2
module E12 = Plonkers.Curves.E12

let twist = Plonkers.Curves.twist
let f2 x y = E2.Unsafe.of_coords_unchecked E2.F.(of_string x, of_string y)
let e12 = Testable.make E12.to_string E12.equal
let f12 x y = E12.Unsafe.of_coords_unchecked E12.F.(of_string x, of_string y)

let test_twist () =
  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));
  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 tests = Alcotest.[ test_case "Twist" `Quick test_twist ]