aboutsummaryrefslogtreecommitdiff
path: root/test/test_e.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_e.ml')
-rw-r--r--test/test_e.ml92
1 files changed, 75 insertions, 17 deletions
diff --git a/test/test_e.ml b/test/test_e.ml
index 4ed48f3..0238544 100644
--- a/test/test_e.ml
+++ b/test/test_e.ml
@@ -6,17 +6,17 @@ let f x y = E.of_coords E.F.(of_string x, of_string y)
let test_strconv () =
let a =
f
- "3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507"
- "1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569"
+ "2376759339040134764212872788353941124992112438470797710505260327947509392797392045352255582857163267674668587297510"
+ "2680611318541745317201589928800822277854035293387537860457713871028948345023926973028031532994931068370323829388300"
in
Alcotest.(check string)
"equals"
- "{3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507;1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569}"
+ "{2376759339040134764212872788353941124992112438470797710505260327947509392797392045352255582857163267674668587297510;2680611318541745317201589928800822277854035293387537860457713871028948345023926973028031532994931068370323829388300}"
(E.to_string a);
Alcotest.(check e)
"equals" a
(E.of_string
- "{3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507;1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569}")
+ "{2376759339040134764212872788353941124992112438470797710505260327947509392797392045352255582857163267674668587297510;2680611318541745317201589928800822277854035293387537860457713871028948345023926973028031532994931068370323829388300}")
let test_curve () =
Alcotest.(check bool)
@@ -29,20 +29,74 @@ let test_curve () =
| _ -> false)
let test_subgroup () =
- let fails s =
- Alcotest.(check bool)
- "fails" true
- (try
- E.of_string s |> ignore;
- false
- with
- | Plonkers.Curves.Not_in_canonical_subgroup -> true
- | _ -> false)
+ Alcotest.(check bool)
+ "fails" true
+ (try
+ E.of_string
+ "{1408129534356243367832052928099913992304651055488638954780633513706178736784848313850316003837543087214824267124696;3572102251607930234099216160523741049730449126093114409014947741659190641290410485354864536261071899055735703220899}"
+ |> ignore;
+ false
+ with
+ | Plonkers.Curves.Not_in_canonical_subgroup -> true
+ | _ -> false)
+
+let test_add () =
+ Alcotest.(check e)
+ "equals"
+ (f
+ "2732848421806933458055216662842663503751428072772029771533370760315348414319694592240768520876175341987716520797550"
+ "2954464846774599053097780011068897191733983980290260437633461565406800411699491071546253465288167362995079357027871")
+ (E.add
+ (f
+ "1840283922001395670795119289697588143466119761033432968923752536154183507956399910760936094073043042902070150237666"
+ "2435928528633846363548965937010170747763592518731703976253428871194016124789594596420862163693375094956371363693568")
+ (f
+ "571033441095339769561050329047836607559757996909911746970000233940080782217640964772866527140482257683410794602275"
+ "3751513699951780822806204149545068929347461752396128233032372349172282127292099402193824058844455410431018547944025"))
+
+let test_sub () =
+ Alcotest.(check e)
+ "equals"
+ (f
+ "1065664903311802711883855953960241132042312919064412218977797750859438116499136425070701529990848206724729373134394"
+ "3828224933887415137804089846896095902450405724640402095510481781504713634254836891357622934547480985549264035957202")
+ (E.sub
+ (f
+ "569713281464432123940419792794667906886387781217235827058538230598383416735537971774329038789662229041505709016151"
+ "507866778674612040501945809996411600066982283825728984146845807722822788180266344145139553998843014766672161118189")
+ (f
+ "320516338292453551949272557105773528190260160795255351762548348902870907892802238932012154400256119846725752875631"
+ "332356225023154996422766027677238490574502325265257760464083075027175592739213840800887632705272849868365518606138"))
+
+let test_scalar_mul () =
+ Alcotest.(check e)
+ "equals"
+ (f
+ "2147268162765015109201667050261280318609818220619179616739419731542037190650706037211530298532745597400678392647871"
+ "1822569631528531419070603952760167309674278828504570075585130903766336929975557974083136509531508332985028088493375")
+ (E.scalar_mul
+ (Z.of_string
+ "34076944663681539617575489333515490120154419691065167429080578803276402241842")
+ (f
+ "3872438102744901432868151057829019352425910481545269510591218290059835422749132295706099147073522490538524825314162"
+ "244022099586493667172296645843335057731326087432941293350787873695950734077660496958795394807248616844411556537170"))
+
+let test_neg () =
+ Alcotest.(check e)
+ "equals"
+ (f
+ "2105851117015157825448768787589743408062880571161114852134896430722466721293912161596062995325833210500961066149764"
+ "1835613369986611690971022618026582756933883838586482973006162582193858829397447622159678449565672339451620438958993")
+ (E.neg
+ (f
+ "2105851117015157825448768787589743408062880571161114852134896430722466721293912161596062995325833210500961066149764"
+ "2166796185235055702446767207709321399622998981352524912325895553930172821093390242283009179563343324586273833600794"));
+ let a =
+ f
+ "1941684181438987475678618661128509185580141750065988950539114961538558200585083736783163136882151604727855756516325"
+ "1662255517347795641618887042798002285595962168500080871445759274019356536297975481332071671342481234773972808352293"
in
- fails
- "{980669326159545649263804252026951545804569479867856393900195820932308021605342594512359315664807832835593476691977;2495572288805567003614829204459695097025160810248948605097890007546743160366866086918562910297675348438728151671429}";
- fails
- "{1069666319329652829987469716448407827813054733044804636498977267777209654377372971020541102311296686223746457925861;2002055975540879804411492431965632823513627576867073743429207373519001811700965967624073843443645677059600261577048}"
+ Alcotest.(check e) "equals" E.inf (E.add a (E.neg a))
let tests =
Alcotest.
@@ -50,4 +104,8 @@ let tests =
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;
]