aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Rodrigues Lordello <[email protected]>2025-07-28 12:35:51 +0200
committerNicholas Rodrigues Lordello <[email protected]>2025-07-28 12:35:51 +0200
commit96c1a864a7c3cdd5006cef5ae8e30cdca61d303a (patch)
treecc138e06b9d4cacf04e520c293aecc829a5dfffd
parent2bf12c1d8c9c879d9d3907457e36e8b1b3217315 (diff)
Pairing Tests and Refactor
We refactored the extension field types to use an array for coefficients instead of a tuple. Tests were modified to only have string literals for numerical literals (istead of previously encoding a whole `Fp12` in a single string for example). As a result, we get better formatting and more line breaks instead of super dense and long lines. Unfortunately, this makes a very big PR instead. The pairing development will continue in the next one to not overgrow this too much.
-rw-r--r--.gitignore1
-rw-r--r--docs/journal/README.md3
-rw-r--r--docs/journal/pages/extension-fields.md (renamed from docs/journal/pages/field-extension.md)6
-rw-r--r--docs/journal/pages/pairings.md11
-rw-r--r--lib/curve.ml6
-rw-r--r--lib/curves.ml43
-rw-r--r--lib/curves.mli6
-rw-r--r--lib/field.ml21
-rw-r--r--lib/fields.ml121
-rw-r--r--lib/fields.mli50
-rw-r--r--lib/pairing.ml24
-rw-r--r--lib/pairing.mli41
-rw-r--r--lib/plonkers.ml1
-rw-r--r--test/primitives.ml27
-rw-r--r--test/test_curves.ml87
-rw-r--r--test/test_e.ml64
-rw-r--r--test/test_e12.ml394
-rw-r--r--test/test_e2.ml156
-rw-r--r--test/test_fp.ml4
-rw-r--r--test/test_fp12.ml539
-rw-r--r--test/test_fp2.ml124
-rw-r--r--test/test_pairing.ml115
-rw-r--r--test/test_plonkers.ml1
23 files changed, 1269 insertions, 576 deletions
diff --git a/.gitignore b/.gitignore
index 876b9e3..e507824 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
_build/
_opam/
+dune.lock/
diff --git a/docs/journal/README.md b/docs/journal/README.md
index a16fa3f..20f10aa 100644
--- a/docs/journal/README.md
+++ b/docs/journal/README.md
@@ -5,6 +5,7 @@ This directory contains the development journal for PLONKers!. It is a collectio
## Table of Contents
1. [Finite Fields](./pages/finite-fields.md)
-2. [Field Extension](./pages/field-extension.md)
+2. [Extension Fields](./pages/extension-fields.md)
3. [Elliptic Curves](./pages/elliptic-curves.md)
4. [Torsion](./pages/torsion.md)
+4. [Pairings](./pages/pairings.md)
diff --git a/docs/journal/pages/field-extension.md b/docs/journal/pages/extension-fields.md
index 6995570..eec81d8 100644
--- a/docs/journal/pages/field-extension.md
+++ b/docs/journal/pages/extension-fields.md
@@ -1,10 +1,10 @@
> [Index](../README.md)
-# Polynomial Extension Rings
+# Extension Fields (Polynomial Extension Rings)
-The other kind of field that is important for elliptic curve pairings are polynomial extension fields. These are just polynomial quotient rings over the curve's field modulo some irreducible monic polynomial (chosen as a parameter of the extension field). This concept is a _little_ complicated, and the Wikipedia article linked in the resources section does a decent job at explainng it (at least better than I can, as I lack a lot of the jargon required).
+The other kind of field that is important for elliptic curve pairings are extension fields, and more specifically polynomial extension rings. These are just polynomial quotient rings over the curve's field modulo some irreducible monic polynomial (chosen as a parameter of the extension field). This concept is a _little_ complicated, and the Wikipedia article linked in the resources section does a decent job at explainng it (at least better than I can, as I lack a lot of the jargon required).
-To try and explain it better, lets take the polynomial extension field of degree 2 used in BLS12-381 pairings. This is defined as the polynomial quotient ring `Fp[x] / (1 + x^2)`, or `Fp2` for brevity, where `Fp[x]` are polynomials over the field `Fp`. With a slightly more concrete example, imagine the polynomials `a + bx` and `c + dx` belonging to `Fp2` where `a`, `b`, `c`, `d` are elements of `Fp` and `x` is some indeterminate also belonging to `Fp`. In code we can represent the elements of `Fp2` as a tuple of two `Fp` elements `Fp.t * Fp.t` where `(a, b)` represents `a + bx`. For this field, addition and multiplication are just definied to be the addition and multiplication modulo `1 + x^2` respectively of the polynomials.
+To try and summarize it, lets take the polynomial extension field of degree 2 used in BLS12-381 pairings. This is defined as the polynomial quotient ring `Fp[x] / (1 + x^2)`, or `Fp2` for brevity, where `Fp[x]` are polynomials over the field `Fp`. With a slightly more concrete example, imagine the polynomials `a + bx` and `c + dx` belonging to `Fp2` where `a`, `b`, `c`, `d` are elements of `Fp` and `x` is some indeterminate also belonging to `Fp`. In code we can represent the elements of `Fp2` as a tuple of two `Fp` elements `Fp.t * Fp.t` where `(a, b)` represents `a + bx`. For this field, addition and multiplication are just definied to be the addition and multiplication modulo `1 + x^2` respectively of the polynomials.
- Addition: `(a + bx) + (c + dx) = (a + c) + (b + d)x`. Since we don't create any `x^2` terms, this is already non-divisible by `1 + x^2`. Addition in these polynomial extension fields are, therefore, very straight forward: `(a, b) + (c, d) = (a + b, c + d)`.
- Multiplication: `(a + bx) * (c + dx) = ac + adx + bcx + bdx^2`. This must be taken modulo `1 + x^2`, so `ac + adx + bcx + bdx^2 =~ ac + adx + bcx + bdx^2 - bd(1 + x^2) =~ (ac - bd) + (ad + bc)x`. Multiplication over `Fp2` is therefore `(a, b) * (c, d) = (ac - bd, ad + bc)`. Look familiar? It is the same as complex number multiplication - which isn't a coincidence as the complex numbers are an extension field of degree 2 over the real numbers.
diff --git a/docs/journal/pages/pairings.md b/docs/journal/pages/pairings.md
new file mode 100644
index 0000000..7260b08
--- /dev/null
+++ b/docs/journal/pages/pairings.md
@@ -0,0 +1,11 @@
+> [Index](../README.md)
+
+# Pairings
+
+TODO.
+
+# Resources
+
+- [Resource](https://example.com)
+
+> [Index](../README.md)
diff --git a/lib/curve.ml b/lib/curve.ml
index 4d1fa5b..214be2b 100644
--- a/lib/curve.ml
+++ b/lib/curve.ml
@@ -1,11 +1,11 @@
(** Elliptic Curve. *)
exception Not_on_curve
-(* Raised when creating a curve element with a point that not on the curve. *)
+(** Raised when creating a curve element with a point that not on the curve. *)
exception Not_in_canonical_subgroup
-(* Raised when creating a curve element with a point that not part of the
- canonical subgroup defined by the curve's generator point. *)
+(** Raised when creating a curve element with a point that not part of the
+ canonical subgroup defined by the curve's generator point. *)
(** Module signature for an elliptic curve. *)
module type S = sig
diff --git a/lib/curves.ml b/lib/curves.ml
index 16d5083..1459fcc 100644
--- a/lib/curves.ml
+++ b/lib/curves.ml
@@ -9,7 +9,7 @@ module Eimpl (E : sig
val b : F.t
val g : F.t * F.t
-end) : Curve.S with type t = E.F.t point = struct
+end) : Curve.S with type t = E.F.t point and type F.t = E.F.t = struct
module F = E.F
type t = F.t point
@@ -119,27 +119,44 @@ end)
let g2 =
Fields.Fp2.
- ( of_string
- "(352701069587466618187139116011060144890029952792775240219908644239793785735715026873347600343865175952761926303160,3059144344244213709971259814753781636986470325476647558659373206291635324768958432433509563104347017837885763365758)",
- of_string
- "(1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905,927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582)"
- )
+ ( of_coeffs
+ Fields.Fp.
+ [|
+ of_string
+ "352701069587466618187139116011060144890029952792775240219908644239793785735715026873347600343865175952761926303160";
+ of_string
+ "3059144344244213709971259814753781636986470325476647558659373206291635324768958432433509563104347017837885763365758";
+ |],
+ of_coeffs
+ Fields.Fp.
+ [|
+ of_string
+ "1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905";
+ of_string
+ "927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582";
+ |] )
let twist_coords (x, y) =
let open Fields in
let w =
- Fp.(zero, one, zero, zero, zero, zero, zero, zero, zero, zero, zero, zero)
- |> Fp12.of_coeffs
+ Fp12.of_coeffs
+ Fp.
+ [|
+ zero; one; zero; zero; zero; zero; zero; zero; zero; zero; zero; zero;
+ |]
in
let w2 = Fp12.(w * w) in
let w3 = Fp12.(w2 * w) in
let w2inv = Fp12.inv w2 in
let w3inv = Fp12.inv w3 in
let iso a =
- let c0, c1 = Fp2.to_coeffs a in
- let c0' = Fp.(c0 - c1) in
- Fp.(c0', zero, zero, zero, zero, zero, c1, zero, zero, zero, zero, zero)
- |> Fp12.of_coeffs
+ let c = Fp2.to_coeffs a in
+ let c0' = Fp.(c.(0) - c.(1)) in
+ Fp12.of_coeffs
+ Fp.
+ [|
+ c0'; zero; zero; zero; zero; zero; c.(1); zero; zero; zero; zero; zero;
+ |]
in
let nx, ny = (iso x, iso y) in
Fp12.(nx * w2inv, ny * w3inv)
@@ -154,7 +171,7 @@ end)
module E12 = Eimpl (struct
module F = Fields.Fp12
- let b = Fields.Fp.of_string "4" |> F.of_fp
+ let b = F.of_f @@ Fields.Fp.of_string "4"
let g = twist_coords g2
end)
diff --git a/lib/curves.mli b/lib/curves.mli
index ce66b73..72b5c22 100644
--- a/lib/curves.mli
+++ b/lib/curves.mli
@@ -1,12 +1,12 @@
(** BLS12-381 curves used for pairings *)
-module E : Curve.S
+module E : Curve.S with type F.t = Fields.Fp.t
(* The BLS12-381 curve over [Fields.Fp]. *)
-module E2 : Curve.S
+module E2 : Curve.S with type F.t = Fields.Fp2.t
(* The BLS12-381 curve over [Fields.Fp2]. *)
-module E12 : Curve.S
+module E12 : Curve.S with type F.t = Fields.Fp12.t
(* The BLS12-381 curve over [Fields.Fp12]. *)
val twist : E2.t -> E12.t
diff --git a/lib/field.ml b/lib/field.ml
index 8f72c37..cb5cbe4 100644
--- a/lib/field.ml
+++ b/lib/field.ml
@@ -1,5 +1,9 @@
(** Finite field. *)
+exception Invalid_arrity
+(** Raised when creating a polynomial extension field element with the wrong
+ number of coefficients. *)
+
(** Module signature for a finite field. *)
module type S = sig
type t
@@ -60,3 +64,20 @@ module type S = sig
val ( / ) : t -> t -> t
(** [div]. *)
end
+
+(** Module signature for a polynomial extension field. *)
+module type Sx = sig
+ include S
+
+ type f
+ (** The field over which the polynomial is defined. *)
+
+ val of_f : f -> t
+ (** [of_f a] maps an underlying field element to the extension field. *)
+
+ val of_coeffs : f array -> t
+ (** [of_coeffs c] is the field element with polynomial coefficients [c]. *)
+
+ val to_coeffs : t -> f array
+ (** [to_coeffs a] are the polynomial coefficients of [a]. *)
+end
diff --git a/lib/fields.ml b/lib/fields.ml
index f18977b..13fc07f 100644
--- a/lib/fields.ml
+++ b/lib/fields.ml
@@ -33,36 +33,45 @@ end) : Field.S with type t = F.t = struct
end
module Fp = struct
- let p =
+ let q =
Z.of_string
"4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787"
- let p_minus_2 = Z.(p - ~$2)
- let mod_p x = Z.erem x p
+ let q_minus_2 = Z.(q - ~$2)
+ let mod_q x = Z.erem x q
include Fimpl (struct
type t = Z.t
let zero = Z.zero
let one = Z.one
- let of_string s = Z.of_string s |> mod_p
+ let of_string s = Z.of_string s |> mod_q
let to_string = Z.to_string
let equal = Z.equal
- let neg a = Z.neg a |> mod_p
- let inv a = Z.powm a p_minus_2 p
- let add a b = Z.add a b |> mod_p
- let mul a b = Z.mul a b |> mod_p
+ let neg a = Z.neg a |> mod_q
+ let inv a = Z.powm a q_minus_2 q
+ let add a b = Z.add a b |> mod_q
+ let mul a b = Z.mul a b |> mod_q
end)
end
module FpN (R : sig
- val p : Fp.t array
+ val q : Fp.t array
end) =
struct
- let degree = Array.length R.p
+ type f = Fp.t
+
+ let degree = Array.length R.q
+ let of_f a = Array.init degree (function 0 -> a | _ -> Fp.zero)
+
+ let of_coeffs a =
+ if Array.length a != degree then raise Field.Invalid_arrity
+ else Array.copy a
+
+ let to_coeffs = Array.copy
include Fimpl (struct
- type t = Fp.t array
+ type t = f array
let zero = Array.make degree Fp.zero
let one = Array.init degree (function 0 -> Fp.one | _ -> Fp.zero)
@@ -100,7 +109,7 @@ struct
if not (Fp.equal q Fp.zero) then
for j = 0 to degree - 1 do
let j' = i - degree + j in
- r.(j') <- Fp.sub r.(j') (Fp.mul q R.p.(j))
+ r.(j') <- Fp.sub r.(j') (Fp.mul q R.q.(j))
done
else ()
done;
@@ -140,7 +149,7 @@ struct
in
let t = ref (Array.append zero [| Fp.zero |]) in
let newt = ref (Array.append one [| Fp.zero |]) in
- let r = ref (Array.append R.p [| Fp.one |]) in
+ let r = ref (Array.append R.q [| Fp.one |]) in
let newr = ref (Array.append a [| Fp.zero |]) in
while Array.for_all Fp.(equal zero) !newr = false do
let q = ediv !r !newr in
@@ -154,69 +163,27 @@ struct
let a0 = Fp.inv !r.(0) in
Array.map (Fp.mul a0) (Array.sub !t 0 degree)
end)
-
- let of_fp a = Array.init degree (function 0 -> a | _ -> Fp.zero)
-end
-
-module Fp2 = struct
- include FpN (struct
- let p = Fp.[| one; zero |]
- end)
-
- type coeffs = Fp.t * Fp.t
-
- let of_coeffs (c0, c1) = [| c0; c1 |]
- let to_coeffs a = (a.(0), a.(1))
end
-module Fp12 = struct
- include FpN (struct
- let p =
- Fp.
- [|
- of_string "2";
- zero;
- zero;
- zero;
- zero;
- zero;
- of_string "-2";
- zero;
- zero;
- zero;
- zero;
- zero;
- |]
- end)
-
- type coeffs =
- Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
-
- let of_coeffs (c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) =
- [| c0; c1; c2; c3; c4; c5; c6; c7; c8; c9; c10; c11 |]
-
- let to_coeffs a =
- ( a.(0),
- a.(1),
- a.(2),
- a.(3),
- a.(4),
- a.(5),
- a.(6),
- a.(7),
- a.(8),
- a.(9),
- a.(10),
- a.(11) )
-end
+module Fp2 = FpN (struct
+ let q = Fp.[| one; zero |]
+end)
+
+module Fp12 = FpN (struct
+ let q =
+ Fp.
+ [|
+ of_string "2";
+ zero;
+ zero;
+ zero;
+ zero;
+ zero;
+ of_string "-2";
+ zero;
+ zero;
+ zero;
+ zero;
+ zero;
+ |]
+end)
diff --git a/lib/fields.mli b/lib/fields.mli
index 18bc142..2ccc23b 100644
--- a/lib/fields.mli
+++ b/lib/fields.mli
@@ -1,50 +1,10 @@
(** Finite fields used by the BLS12-381 curve and pairings *)
module Fp : Field.S
-(* The prime field over which the BLS12-381 curve is defined. *)
+(** The prime field over which the BLS12-381 curve is defined. *)
-module Fp2 : sig
- include Field.S
+module Fp2 : Field.Sx with type f = Fp.t
+(** The polynomial field extension of degree 2 for BLS12-381 pairings. *)
- type coeffs = Fp.t * Fp.t
- (** Polynomial coefficients of the extension field. *)
-
- val of_fp : Fp.t -> t
- (** [of_fp a] returns maps a field element to the extension field. *)
-
- val of_coeffs : coeffs -> t
- (** [of_coeffs c] is the field element with polynomial coefficients [c]. *)
-
- val to_coeffs : t -> coeffs
- (** [to_coeffs a] are the polynomial coefficients of [a]. *)
-end
-(* The polynomial field extension of degree 2 for BLS12-381 pairings. *)
-
-module Fp12 : sig
- include Field.S
-
- type coeffs =
- Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- * Fp.t
- (** Polynomial coefficients of the extension field. *)
-
- val of_fp : Fp.t -> t
- (** [of_fp a] returns maps a field element to the extension field. *)
-
- val of_coeffs : coeffs -> t
- (** [of_coeffs c] is the field element with polynomial coefficients [c]. *)
-
- val to_coeffs : t -> coeffs
- (** [to_coeffs a] are the polynomial coefficients of [a]. *)
-end
-(* The polynomial field extension of degree 12 for BLS12-381 pairings. *)
+module Fp12 : Field.Sx with type f = Fp.t
+(** The polynomial field extension of degree 12 for BLS12-381 pairings. *)
diff --git a/lib/pairing.ml b/lib/pairing.ml
new file mode 100644
index 0000000..dc8e59c
--- /dev/null
+++ b/lib/pairing.ml
@@ -0,0 +1,24 @@
+module G1 = Curves.E
+module G2 = Curves.E2
+
+module Gt = struct
+ module Fp12 = Fields.Fp12
+
+ type t = Fp12.t
+
+ let identity = Fp12.one
+ let dot = Fp12.mul
+ let inverse = Fp12.inv
+ let to_fp12 a = a
+ let equal = Fp12.equal
+ let to_string = Fp12.to_string
+
+ module Unsafe = struct
+ let of_fp12_unchecked a = a
+ let of_string_unchecked = Fp12.of_string
+ end
+end
+
+let e p q =
+ let _ = (p, q) in
+ failwith "todo"
diff --git a/lib/pairing.mli b/lib/pairing.mli
new file mode 100644
index 0000000..fc66fcb
--- /dev/null
+++ b/lib/pairing.mli
@@ -0,0 +1,41 @@
+module G1 : Curve.S with type t = Curves.E.t and type F.t = Fields.Fp.t
+module G2 : Curve.S with type t = Curves.E2.t and type F.t = Fields.Fp2.t
+
+module Gt : sig
+ type t
+
+ val identity : t
+ (** The group's identity element. *)
+
+ val dot : t -> t -> t
+ (** [dot a b] is the group operation applied to [a] and [b]. *)
+
+ val inverse : t -> t
+ (** [inverse a] is the inverse of [a]. Note that the invariant
+ [equal identity (dot a (inverse a))] always holds. *)
+
+ val equal : t -> t -> bool
+ (** [equal a b] is true if [a] has the same value as [b] *)
+
+ val to_fp12 : t -> Fields.Fp12.t
+ (** [to_fp12 a] is the underlying field value of the group element [a]. *)
+
+ val to_string : t -> string
+ (** [to_string a] is the string representation of [a]. *)
+
+ (** Unsafe pairing group construction functions. *)
+ module Unsafe : sig
+ val of_fp12_unchecked : Fields.Fp12.t -> t
+ (** [of_fp12_unchecked a] is a pairing element of value [a]. This function
+ does not check whether the value actually belongs to the pairing group
+ [Gt]. *)
+
+ val of_string_unchecked : string -> t
+ (** [of_string_unchecked s] returns the pairing element represented by [s].
+ This function does not check whether the value belongs to the group
+ [Gt]. *)
+ end
+end
+
+val e : G1.t -> G2.t -> Gt.t
+(** [e p q] is the elliptic curve pairing of [p] and [q]. *)
diff --git a/lib/plonkers.ml b/lib/plonkers.ml
index 9c7c858..aa14f53 100644
--- a/lib/plonkers.ml
+++ b/lib/plonkers.ml
@@ -2,3 +2,4 @@ module Field = Field
module Fields = Fields
module Curve = Curve
module Curves = Curves
+module Pairing = Pairing
diff --git a/test/primitives.ml b/test/primitives.ml
new file mode 100644
index 0000000..f908612
--- /dev/null
+++ b/test/primitives.ml
@@ -0,0 +1,27 @@
+open Plonkers.Curves
+open Plonkers.Fields
+open Plonkers.Pairing
+
+module Literals = struct
+ let fp = Fp.of_string
+ let fp2 c = Fp2.of_coeffs @@ Array.map fp c
+ 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_fp12_unchecked @@ fp12 c
+end
+
+module Testables = struct
+ let fp = Testable.make Fp.to_string Fp.equal
+ let fp2 = Testable.make Fp2.to_string Fp2.equal
+ 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
index d3067cc..143211c 100644
--- a/test/test_curves.ml
+++ b/test/test_curves.ml
@@ -2,33 +2,84 @@ 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 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)"
+ ( [|
+ "2109508776193857273074766488410969484271072993610345872414603016106553977333420070441822701292764210251579683428522";
+ "3122689516821528327894678317146234429793657826538065999063801814299529533586972120357919860380161818422867843226102";
+ |],
+ [|
+ "1096288604042692121608580288022426533189175239933724612935896261545208643656951679037482053510338623653634164811915";
+ "1170946969994232162449075722035284212661104220582295241050315080132560517926924365377907307339371864116051233088516";
+ |] )
in
let b =
f2
- "(1249927438163201574866859585937475005480631005557973853506467103895431793859087897855543227858106779532090068273481,3316136808132952082246855662072348414235919944257935059559541300069920601748305368149334910959656758372765105616868)"
- "(81743811270164858346488114131996653093309264515814483449447422378937968491505855199671526555077281996286356618484,1084133614285958528564866737145829519643307320120470464135106404047274008544004224502685177052190672561703116812406)"
+ ( [|
+ "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)")
+ (E12.add (twist a) (twist b))
-let tests = Alcotest.[ test_case "Twist" `Quick test_twist ]
+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 d287831..585cb20 100644
--- a/test/test_e.ml
+++ b/test/test_e.ml
@@ -1,13 +1,14 @@
module E = Plonkers.Curves.E
-let e = Testable.make E.to_string E.equal
-let f x y = E.Unsafe.of_coords_unchecked E.F.(of_string x, of_string y)
+let e = Primitives.Testables.e
+let f = Primitives.Literals.e
let test_strconv () =
let a =
f
- "704648225832996754434548433071026029921434261490324062624046528007387592893305783031149959865132570914021074338890"
- "2790809590887885290880356803296049708176452905760090772131241016249472860044571856060358509135396867961864286840213"
+ ( "704648225832996754434548433071026029921434261490324062624046528007387592893305783031149959865132570914021074338890",
+ "2790809590887885290880356803296049708176452905760090772131241016249472860044571856060358509135396867961864286840213"
+ )
in
let s =
"{704648225832996754434548433071026029921434261490324062624046528007387592893305783031149959865132570914021074338890;2790809590887885290880356803296049708176452905760090772131241016249472860044571856060358509135396867961864286840213}"
@@ -41,57 +42,68 @@ let test_add () =
Alcotest.(check e)
"equals"
(f
- "2732848421806933458055216662842663503751428072772029771533370760315348414319694592240768520876175341987716520797550"
- "2954464846774599053097780011068897191733983980290260437633461565406800411699491071546253465288167362995079357027871")
+ ( "2732848421806933458055216662842663503751428072772029771533370760315348414319694592240768520876175341987716520797550",
+ "2954464846774599053097780011068897191733983980290260437633461565406800411699491071546253465288167362995079357027871"
+ ))
(E.add
(f
- "1840283922001395670795119289697588143466119761033432968923752536154183507956399910760936094073043042902070150237666"
- "2435928528633846363548965937010170747763592518731703976253428871194016124789594596420862163693375094956371363693568")
+ ( "1840283922001395670795119289697588143466119761033432968923752536154183507956399910760936094073043042902070150237666",
+ "2435928528633846363548965937010170747763592518731703976253428871194016124789594596420862163693375094956371363693568"
+ ))
(f
- "571033441095339769561050329047836607559757996909911746970000233940080782217640964772866527140482257683410794602275"
- "3751513699951780822806204149545068929347461752396128233032372349172282127292099402193824058844455410431018547944025"))
+ ( "571033441095339769561050329047836607559757996909911746970000233940080782217640964772866527140482257683410794602275",
+ "3751513699951780822806204149545068929347461752396128233032372349172282127292099402193824058844455410431018547944025"
+ )))
let test_sub () =
Alcotest.(check e)
"equals"
(f
- "1065664903311802711883855953960241132042312919064412218977797750859438116499136425070701529990848206724729373134394"
- "3828224933887415137804089846896095902450405724640402095510481781504713634254836891357622934547480985549264035957202")
+ ( "1065664903311802711883855953960241132042312919064412218977797750859438116499136425070701529990848206724729373134394",
+ "3828224933887415137804089846896095902450405724640402095510481781504713634254836891357622934547480985549264035957202"
+ ))
(E.sub
(f
- "569713281464432123940419792794667906886387781217235827058538230598383416735537971774329038789662229041505709016151"
- "507866778674612040501945809996411600066982283825728984146845807722822788180266344145139553998843014766672161118189")
+ ( "569713281464432123940419792794667906886387781217235827058538230598383416735537971774329038789662229041505709016151",
+ "507866778674612040501945809996411600066982283825728984146845807722822788180266344145139553998843014766672161118189"
+ ))
(f
- "320516338292453551949272557105773528190260160795255351762548348902870907892802238932012154400256119846725752875631"
- "332356225023154996422766027677238490574502325265257760464083075027175592739213840800887632705272849868365518606138"))
+ ( "320516338292453551949272557105773528190260160795255351762548348902870907892802238932012154400256119846725752875631",
+ "332356225023154996422766027677238490574502325265257760464083075027175592739213840800887632705272849868365518606138"
+ )))
let test_scalar_mul () =
Alcotest.(check e)
"equals"
(f
- "2147268162765015109201667050261280318609818220619179616739419731542037190650706037211530298532745597400678392647871"
- "1822569631528531419070603952760167309674278828504570075585130903766336929975557974083136509531508332985028088493375")
+ ( "2147268162765015109201667050261280318609818220619179616739419731542037190650706037211530298532745597400678392647871",
+ "1822569631528531419070603952760167309674278828504570075585130903766336929975557974083136509531508332985028088493375"
+ ))
(E.scalar_mul
(Z.of_string
"34076944663681539617575489333515490120154419691065167429080578803276402241842")
(f
- "3872438102744901432868151057829019352425910481545269510591218290059835422749132295706099147073522490538524825314162"
- "244022099586493667172296645843335057731326087432941293350787873695950734077660496958795394807248616844411556537170"))
+ ( "3872438102744901432868151057829019352425910481545269510591218290059835422749132295706099147073522490538524825314162",
+ "244022099586493667172296645843335057731326087432941293350787873695950734077660496958795394807248616844411556537170"
+ )))
let test_neg () =
Alcotest.(check e)
"equals"
(f
- "2105851117015157825448768787589743408062880571161114852134896430722466721293912161596062995325833210500961066149764"
- "1835613369986611690971022618026582756933883838586482973006162582193858829397447622159678449565672339451620438958993")
+ ( "2105851117015157825448768787589743408062880571161114852134896430722466721293912161596062995325833210500961066149764",
+ "1835613369986611690971022618026582756933883838586482973006162582193858829397447622159678449565672339451620438958993"
+ ))
(E.neg
(f
- "2105851117015157825448768787589743408062880571161114852134896430722466721293912161596062995325833210500961066149764"
- "2166796185235055702446767207709321399622998981352524912325895553930172821093390242283009179563343324586273833600794"));
+ ( "2105851117015157825448768787589743408062880571161114852134896430722466721293912161596062995325833210500961066149764",
+ "2166796185235055702446767207709321399622998981352524912325895553930172821093390242283009179563343324586273833600794"
+ )));
let a =
f
- "1941684181438987475678618661128509185580141750065988950539114961538558200585083736783163136882151604727855756516325"
- "1662255517347795641618887042798002285595962168500080871445759274019356536297975481332071671342481234773972808352293"
+ ( "1941684181438987475678618661128509185580141750065988950539114961538558200585083736783163136882151604727855756516325",
+ "1662255517347795641618887042798002285595962168500080871445759274019356536297975481332071671342481234773972808352293"
+ )
in
Alcotest.(check e) "equals" E.inf (E.add a (E.neg a))
diff --git a/test/test_e12.ml b/test/test_e12.ml
index 0af2df6..2ee3f17 100644
--- a/test/test_e12.ml
+++ b/test/test_e12.ml
@@ -1,13 +1,39 @@
module E12 = Plonkers.Curves.E12
-let e12 = Testable.make E12.to_string E12.equal
-let f x y = E12.Unsafe.of_coords_unchecked E12.F.(of_string x, of_string y)
+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)"
+ ( [|
+ "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)}"
@@ -42,57 +68,343 @@ 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)")
+ ( [|
+ "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)")
+ ( [|
+ "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)"))
+ ( [|
+ "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)")
+ ( [|
+ "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)")
+ ( [|
+ "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)"))
+ ( [|
+ "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)")
+ ( [|
+ "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)"))
+ ( [|
+ "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)")
+ ( [|
+ "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)"));
+ ( [|
+ "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)"
+ ( [|
+ "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))
@@ -100,8 +412,34 @@ 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)")
+ ( [|
+ "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.
diff --git a/test/test_e2.ml b/test/test_e2.ml
index 3dd5c22..5e40e65 100644
--- a/test/test_e2.ml
+++ b/test/test_e2.ml
@@ -1,13 +1,19 @@
module E2 = Plonkers.Curves.E2
-let e2 = Testable.make E2.to_string E2.equal
-let f x y = E2.Unsafe.of_coords_unchecked E2.F.(of_string x, of_string y)
+let e2 = Primitives.Testables.e2
+let f = Primitives.Literals.e2
let test_strconv () =
let a =
f
- "(1995966487400060513418002023207574157295305948670062141574847467571155809406706098785462170240887564093686629877623,662886336588505248783096013641071887822498506927882698632762069520277859710519968066621437591913838510294024221845)"
- "(2118133940922730619706689117607342224796346036207279785462459268901402082964459754036268590522181697629582678327818,3180158093976603722423949631887924556492770394116171123059316509806286695323674296949805082557706278821978684422237)"
+ ( [|
+ "1995966487400060513418002023207574157295305948670062141574847467571155809406706098785462170240887564093686629877623";
+ "662886336588505248783096013641071887822498506927882698632762069520277859710519968066621437591913838510294024221845";
+ |],
+ [|
+ "2118133940922730619706689117607342224796346036207279785462459268901402082964459754036268590522181697629582678327818";
+ "3180158093976603722423949631887924556492770394116171123059316509806286695323674296949805082557706278821978684422237";
+ |] )
in
let s =
"{(1995966487400060513418002023207574157295305948670062141574847467571155809406706098785462170240887564093686629877623,662886336588505248783096013641071887822498506927882698632762069520277859710519968066621437591913838510294024221845);(2118133940922730619706689117607342224796346036207279785462459268901402082964459754036268590522181697629582678327818,3180158093976603722423949631887924556492770394116171123059316509806286695323674296949805082557706278821978684422237)}"
@@ -41,91 +47,126 @@ let test_add () =
Alcotest.(check e2)
"equals"
(f
- "(499713417605359223674748473758724973948438124705509202302245471290609292306320586538959574203334940457575903991711,3849381523047393672660382657163613807212712961677974554645092181592292011827458146770352521145227167398610078418185)"
- "(3750738009713936929372241922830934361036892789616987325774050932170221795352544491858695643172294211282599110319834,3561628900031869771392652210785168204755113200504180138415139599905464331701794168749876553728218422931049173996790)")
+ ( [|
+ "499713417605359223674748473758724973948438124705509202302245471290609292306320586538959574203334940457575903991711";
+ "3849381523047393672660382657163613807212712961677974554645092181592292011827458146770352521145227167398610078418185";
+ |],
+ [|
+ "3750738009713936929372241922830934361036892789616987325774050932170221795352544491858695643172294211282599110319834";
+ "3561628900031869771392652210785168204755113200504180138415139599905464331701794168749876553728218422931049173996790";
+ |] ))
(E2.add
(f
- "(22988558892716969390996985732585240683297793773456313893700754641768024025112560131028908246472269831559878289575,2129706665424714060840367155348060356419393088613610263996150242693619717302217969445633229711091283126869298324191)"
- "(326344468552893907028622086721957524007052308610498663186676327256007196980344862961459048761730914514101678031123,3578939464694739647421989794082523254572164841250176471270721235280032616122779184472701860960655547698666209531163)")
+ ( [|
+ "22988558892716969390996985732585240683297793773456313893700754641768024025112560131028908246472269831559878289575";
+ "2129706665424714060840367155348060356419393088613610263996150242693619717302217969445633229711091283126869298324191";
+ |],
+ [|
+ "326344468552893907028622086721957524007052308610498663186676327256007196980344862961459048761730914514101678031123";
+ "3578939464694739647421989794082523254572164841250176471270721235280032616122779184472701860960655547698666209531163";
+ |] ))
(f
- "(3695633206715132410492337765882907918857795221238051472281688705875004174483167692618918438807066911317626485478957,2976733649841946843632279759860096327423816839648446597596824846941966186914175551584845353423964217077348053962065)"
- "(49466427428220367265805901178013626540803904016880618718453870927457307757178707263045811558641515336191874310112,2193129241285505962248559104914181807138658074292296828774608320812063550960488358009160505763316933125829480800311)"))
+ ( [|
+ "3695633206715132410492337765882907918857795221238051472281688705875004174483167692618918438807066911317626485478957";
+ "2976733649841946843632279759860096327423816839648446597596824846941966186914175551584845353423964217077348053962065";
+ |],
+ [|
+ "49466427428220367265805901178013626540803904016880618718453870927457307757178707263045811558641515336191874310112";
+ "2193129241285505962248559104914181807138658074292296828774608320812063550960488358009160505763316933125829480800311";
+ |] )))
let test_sub () =
Alcotest.(check e2)
"equals"
(f
- "(2312381534305864038524856410951813412729532000275307896810795592963361639762761897364492993639180834599053426654921,2941946573854091849965088183943891771101444533626394142063742950941901356314086230253727457469500594733301574969126)"
- "(3177038204107211918017473977040505404653337824416553912249365797499278408762074130788569657467795326880900042739300,3911466467618211275615446067985091611817124681549927950440782870032642030586794441825300408067249342511123677227979)")
+ ( [|
+ "2312381534305864038524856410951813412729532000275307896810795592963361639762761897364492993639180834599053426654921";
+ "2941946573854091849965088183943891771101444533626394142063742950941901356314086230253727457469500594733301574969126";
+ |],
+ [|
+ "3177038204107211918017473977040505404653337824416553912249365797499278408762074130788569657467795326880900042739300";
+ "3911466467618211275615446067985091611817124681549927950440782870032642030586794441825300408067249342511123677227979";
+ |] ))
(E2.sub
(f
- "(3084805454959641404340859217267539384943233503012252203041979288484567877164842557655530989970590180692844056705034,1032626932734486057118525818914103317004948135891523645620202784883454249860761416804451664418540921374537112657339)"
- "(567609968615494874083532393538964631912521339405909452432595170197158682938070010563153437595578466221475239150664,3965723577064707140049831298501225403010472139339519470330943732886849966270836690577682873296098666976942450913027)")
+ ( [|
+ "3084805454959641404340859217267539384943233503012252203041979288484567877164842557655530989970590180692844056705034";
+ "1032626932734486057118525818914103317004948135891523645620202784883454249860761416804451664418540921374537112657339";
+ |],
+ [|
+ "567609968615494874083532393538964631912521339405909452432595170197158682938070010563153437595578466221475239150664";
+ "3965723577064707140049831298501225403010472139339519470330943732886849966270836690577682873296098666976942450913027";
+ |] ))
(f
- "(1437969629809004608879055525849883700261548412934340004984286831449951101506825523108895949333702907561636531462862,3378050752672563498305643671412654890539264706582196808663756002199076494302859579346688785007817086448260264744631)"
- "(3688003734830478721040484715021921439921663750934892483251989073660346159418502949754053418120146012703162584349321,294600807465112254390070142232849516815757700388555441412905845762862521178052505971852404123896853420248399045909)"))
+ ( [|
+ "1437969629809004608879055525849883700261548412934340004984286831449951101506825523108895949333702907561636531462862";
+ "3378050752672563498305643671412654890539264706582196808663756002199076494302859579346688785007817086448260264744631";
+ |],
+ [|
+ "3688003734830478721040484715021921439921663750934892483251989073660346159418502949754053418120146012703162584349321";
+ "294600807465112254390070142232849516815757700388555441412905845762862521178052505971852404123896853420248399045909";
+ |] )))
let test_scalar_mul () =
Alcotest.(check e2)
"equals"
(f
- "(1092894641180253280627824475749822745538993676284211343464536443667704016213631359345660547916686207447599304492990,3324099030654709813055482585412186377145855773893664369906420608900967641626669259098384400094403575314217078271321)"
- "(1687432397129777546869295921172489186821991613986891301985886124965631277467866465780351130557754827159028199904720,2313960103129372774774734178634617919906919386825218848510448126559550974987820849911034145924048313343848913976180)")
+ ( [|
+ "1092894641180253280627824475749822745538993676284211343464536443667704016213631359345660547916686207447599304492990";
+ "3324099030654709813055482585412186377145855773893664369906420608900967641626669259098384400094403575314217078271321";
+ |],
+ [|
+ "1687432397129777546869295921172489186821991613986891301985886124965631277467866465780351130557754827159028199904720";
+ "2313960103129372774774734178634617919906919386825218848510448126559550974987820849911034145924048313343848913976180";
+ |] ))
(E2.scalar_mul
(Z.of_string
"18231751679696756095586214113699656074182459369522013003988412807673749568724")
(f
- "(2514664268577432573560291176315683541072067402533046184786583901096804522469891814129602032754241329292791735547731,1538891981432352671530281965293325684836353821970151860371636345672221993717129428051893539595256156434325115353328)"
- "(1020197595243302833683556943176598276009062246952019251126700930527258255249495123842828836305850271186575937412091,957529907995660594751569367214519238040770457577242766357201002881030298493381525670720382223549185747922813057348)"))
+ ( [|
+ "2514664268577432573560291176315683541072067402533046184786583901096804522469891814129602032754241329292791735547731";
+ "1538891981432352671530281965293325684836353821970151860371636345672221993717129428051893539595256156434325115353328";
+ |],
+ [|
+ "1020197595243302833683556943176598276009062246952019251126700930527258255249495123842828836305850271186575937412091";
+ "957529907995660594751569367214519238040770457577242766357201002881030298493381525670720382223549185747922813057348";
+ |] )))
let test_neg () =
Alcotest.(check e2)
"equals"
(f
- "(1545269364848460984490225670755503760473037616438596925671109140482515442704584830885661527842646221605111107590693,1267478445196980059681345977877996221353505182887596481010812841900715170279481217659186985334416192910417976590132)"
- "(2138086320981055187350247210500555749249791226828379441597708773600979851439979713108017155176731805322171737993018,2923510363463074904143568736318190088176676574358556535023319924451820130012383135761860188454542388330577656123700)")
+ ( [|
+ "1545269364848460984490225670755503760473037616438596925671109140482515442704584830885661527842646221605111107590693";
+ "1267478445196980059681345977877996221353505182887596481010812841900715170279481217659186985334416192910417976590132";
+ |],
+ [|
+ "2138086320981055187350247210500555749249791226828379441597708773600979851439979713108017155176731805322171737993018";
+ "2923510363463074904143568736318190088176676574358556535023319924451820130012383135761860188454542388330577656123700";
+ |] ))
(E2.neg
(f
- "(1545269364848460984490225670755503760473037616438596925671109140482515442704584830885661527842646221605111107590693,1267478445196980059681345977877996221353505182887596481010812841900715170279481217659186985334416192910417976590132)"
- "(1864323234240612206067542615235348407307091593110628443734349362523051799050858151334670473952283858715722534566769,1078899191758592489274221089417714068380206245580451350308738211672211520478454728680827440674473275707316616436087)"));
+ ( [|
+ "1545269364848460984490225670755503760473037616438596925671109140482515442704584830885661527842646221605111107590693";
+ "1267478445196980059681345977877996221353505182887596481010812841900715170279481217659186985334416192910417976590132";
+ |],
+ [|
+ "1864323234240612206067542615235348407307091593110628443734349362523051799050858151334670473952283858715722534566769";
+ "1078899191758592489274221089417714068380206245580451350308738211672211520478454728680827440674473275707316616436087";
+ |] )));
let a =
f
- "(2145319835080253046126157108405019899066932648811331837314642288549615338163523922360993646054737343377628571487304,1358459155514781387151184879883145700362295043361724816677598042273140202854606635229527873146151979028028462660866)"
- "(2261863074976855596039999928645826587478562702008490591716114111186951516904330390847333904655429074513962463071272,2015356306298728612773777903102863638865287815742386042734473839158493228418734519947389685935269331153485256794451)"
+ ( [|
+ "2145319835080253046126157108405019899066932648811331837314642288549615338163523922360993646054737343377628571487304";
+ "1358459155514781387151184879883145700362295043361724816677598042273140202854606635229527873146151979028028462660866";
+ |],
+ [|
+ "2261863074976855596039999928645826587478562702008490591716114111186951516904330390847333904655429074513962463071272";
+ "2015356306298728612773777903102863638865287815742386042734473839158493228418734519947389685935269331153485256794451";
+ |] )
in
Alcotest.(check e2) "equals" E2.inf (E2.add a (E2.neg a))
-let test_twist () =
- let module E12 = Plonkers.Curves.E12 in
- let e12 = Testable.make E12.to_string E12.equal in
- let f12 x y =
- E12.Unsafe.of_coords_unchecked E12.F.(of_string x, of_string y)
- in
- let twist = Plonkers.Curves.twist in
- let a =
- f
- "(3669611369294948974634765224261160863259976623025174450692974024135660938677293949484127780340633015696505838316130,3090687185578156925132141476322078020023392467014425193206309553370795378348206159236670341492900186918308124507493)"
- "(2779970239140385631920565954330663246292556112368464275383215059538548403396374960378890105420876329855513347894085,3097437972523464042565784881677563184964797100562369589471018391346730349842749358034624136069384567019997582090957)"
- in
- let b =
- f
- "(1053300572803981667384367752902994951183157118132662809599648130824356188957537236411558781666933412964027713776540,1445977520422141287162517647930196440114009706588757547597541156345622544583208585670790387386046081159986177959998)"
- "(3689824775759870994521791010305891175032741515121577774537433898953647904897504950875889040684809164534200503484058,2853882551173372307457093223859059530229833448859184381902653127266710787574249534844087593772863369427604788749655)"
- in
- Alcotest.(check e12)
- "equals"
- (E2.add a b |> twist)
- (E12.add (twist a) (twist b));
- Alcotest.(check e12)
- "equals"
- (f
- "(2606921651592105754475529398132710526491771329060996833171782094578621322484869256778991328135243962740388516701670,2825253982791353034679973984849711146583580678189915790389883143879948292831336084622718804815562162657047466258624)"
- "(1589868014688087566534303814516145532269762769759394338531872847925266893368410252824018876911895493136813971365761,778718326085510634191669420774555971516341962061804758334244302026416954528851727912605155423863203911476334494468)"
- |> twist)
- (f12
- "(0,0,0,0,2606921651592105754475529398132710526491771329060996833171782094578621322484869256778991328135243962740388516701670,0,0,0,0,0,109166165599623640102222293358500310045904674564459478609050524650663485173233413921863738340159099958329474778477,0)"
- "(0,0,0,1589868014688087566534303814516145532269762769759394338531872847925266893368410252824018876911895493136813971365761,0,0,0,0,0,1595629933309545230537577715997157297901731006120709152567214795112590855825639669765636953820491687406278317844247,0,0)")
-
let tests =
Alcotest.
[
@@ -136,5 +177,4 @@ let tests =
test_case "Subtraction" `Quick test_sub;
test_case "Scalar Multiplication" `Quick test_scalar_mul;
test_case "Additive Inverse" `Quick test_neg;
- test_case "Twist" `Quick test_twist;
]
diff --git a/test/test_fp.ml b/test/test_fp.ml
index 9691bfb..687170f 100644
--- a/test/test_fp.ml
+++ b/test/test_fp.ml
@@ -1,7 +1,7 @@
module Fp = Plonkers.Fields.Fp
-let fp = Testable.make Fp.to_string Fp.equal
-let f = Fp.of_string
+let fp = Primitives.Testables.fp
+let f = Primitives.Literals.fp
let test_strconv () =
let a =
diff --git a/test/test_fp12.ml b/test/test_fp12.ml
index e88b96b..6807d0f 100644
--- a/test/test_fp12.ml
+++ b/test/test_fp12.ml
@@ -1,39 +1,26 @@
module Fp = Plonkers.Fields.Fp
module Fp12 = Plonkers.Fields.Fp12
-let fp12 = Testable.make Fp12.to_string Fp12.equal
-
-let f c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 =
- Fp12.of_coeffs
- Fp.
- ( of_string c0,
- of_string c1,
- of_string c2,
- of_string c3,
- of_string c4,
- of_string c5,
- of_string c6,
- of_string c7,
- of_string c8,
- of_string c9,
- of_string c10,
- of_string c11 )
+let fp12 = Primitives.Testables.fp12
+let f = Primitives.Literals.fp12
let test_strconv () =
let a =
f
- "2916030131112425910736728833294966280877348127497066861802260324152389116184665963977658957216391196180579077474202"
- "1519862437235303187188961557435602349317662069421862747209181232217613587604953767705018210876984976062405524645622"
- "296645580800680675009621881920997395213790816778008448436221746142308017377314413585580661715141084537701545554168"
- "1981557211956889095227901276564616817712990386953892187870249475222326830471202728108345999615285753394142232132312"
- "833361220704354884434302513333442088322974161003072803264824357410372777926316698647896734024111451895881451892941"
- "2711755601893075919832148493574676626069798533950866837790424822014009949251210477322950287178868808802513013310092"
- "371213053563436252645940045458060653872935108881239949520789125958735351804960527435344045802826289621926519389359"
- "504151947300534428538773393472324784669777301827817398729819216017440270289061739490404467920801765270857364809526"
- "3563993255617322600585910657699631528415397776575273554957383151855598758349437838089591153976674032653746780002367"
- "1396274584009387615887886835913193518070291009462177144922465656390031512961216497255957290669783178741610222179461"
- "1791645971276582626341761994075837917473870474245353102664092427839586202945803660199735855654457386807016012521755"
- "171029163675750402723404477137748189341455451129895111449568566066650114642345344282976819697533131681587059212847"
+ [|
+ "2916030131112425910736728833294966280877348127497066861802260324152389116184665963977658957216391196180579077474202";
+ "1519862437235303187188961557435602349317662069421862747209181232217613587604953767705018210876984976062405524645622";
+ "296645580800680675009621881920997395213790816778008448436221746142308017377314413585580661715141084537701545554168";
+ "1981557211956889095227901276564616817712990386953892187870249475222326830471202728108345999615285753394142232132312";
+ "833361220704354884434302513333442088322974161003072803264824357410372777926316698647896734024111451895881451892941";
+ "2711755601893075919832148493574676626069798533950866837790424822014009949251210477322950287178868808802513013310092";
+ "371213053563436252645940045458060653872935108881239949520789125958735351804960527435344045802826289621926519389359";
+ "504151947300534428538773393472324784669777301827817398729819216017440270289061739490404467920801765270857364809526";
+ "3563993255617322600585910657699631528415397776575273554957383151855598758349437838089591153976674032653746780002367";
+ "1396274584009387615887886835913193518070291009462177144922465656390031512961216497255957290669783178741610222179461";
+ "1791645971276582626341761994075837917473870474245353102664092427839586202945803660199735855654457386807016012521755";
+ "171029163675750402723404477137748189341455451129895111449568566066650114642345344282976819697533131681587059212847";
+ |]
in
Alcotest.(check string)
"equals"
@@ -48,239 +35,271 @@ let test_add () =
Alcotest.(check fp12)
"equals"
(f
- "1417698107936940251656853016453631673853953147794130703688156638303717713671579717506241150013821790861974661084813"
- "792288135695906690561617515571635410409198000683556573960320145107387958915155976496080156825242313681095297946173"
- "2768807922396056277686625334834708552295944254902517947671122565749281453035333584699101299898802848306012061095298"
- "2123881407946793111417208152438015687323592268938277556863437509152647876437818767678349242386974498402005202252863"
- "2187596370412268256703110817541663861182466938952767216748358682929146876456187725141523524643928591960953548660596"
- "393424626160571421097297466792791400640147184023365772807809662595160957839353777097312935007211617993177100557093"
- "880317360010960432313524952239370498461080789740307126320280928593363595069130509033792099592053747116656782052243"
- "1645244777451315328185153783354613920940580832479907771177820667317430957113220304491940597182965422762751259531468"
- "3550205573265255320534629007751052347537068281527380931777085738915760806622336640463301064769220645662052425173228"
- "2957590738957628570740580103912486294937061504675093251592653444372362940930349147902523627092157366967470420527935"
- "882876052288115399116926554091482448039746502161453564572609371822751787193338655553501889234120032702517679348070"
- "1930706352132404339144090579209142276523501987246090592288999425964598202756156585453497036577529225701774908717617")
+ [|
+ "1417698107936940251656853016453631673853953147794130703688156638303717713671579717506241150013821790861974661084813";
+ "792288135695906690561617515571635410409198000683556573960320145107387958915155976496080156825242313681095297946173";
+ "2768807922396056277686625334834708552295944254902517947671122565749281453035333584699101299898802848306012061095298";
+ "2123881407946793111417208152438015687323592268938277556863437509152647876437818767678349242386974498402005202252863";
+ "2187596370412268256703110817541663861182466938952767216748358682929146876456187725141523524643928591960953548660596";
+ "393424626160571421097297466792791400640147184023365772807809662595160957839353777097312935007211617993177100557093";
+ "880317360010960432313524952239370498461080789740307126320280928593363595069130509033792099592053747116656782052243";
+ "1645244777451315328185153783354613920940580832479907771177820667317430957113220304491940597182965422762751259531468";
+ "3550205573265255320534629007751052347537068281527380931777085738915760806622336640463301064769220645662052425173228";
+ "2957590738957628570740580103912486294937061504675093251592653444372362940930349147902523627092157366967470420527935";
+ "882876052288115399116926554091482448039746502161453564572609371822751787193338655553501889234120032702517679348070";
+ "1930706352132404339144090579209142276523501987246090592288999425964598202756156585453497036577529225701774908717617";
+ |])
(Fp12.add
(f
- "3159920112550153431066628439665589032819589113436943826256968434878458171469430959332402305608699902549825494548481"
- "280477632787313770308256716090223370904109239916966236801520233572575817285128701723410768518512359978230649258938"
- "1413291885782085817633040683653940857250625455659320078914008351676709667450062537779617175392659654164452433135"
- "1390203788953831203284410955429001727804727066121899705177902792997039912748042065096210386797318190962813044260483"
- "2450327257338258979467333234199279439466897651669281394853367065946750995514548983056158869109063641273013270171923"
- "49857405203040712095496579185765642444889317234755469422130724151910605131192922290259073202130142411211432065900"
- "253274012167990632051406165976175533248954578500167998516665746125111248103572214467996880864844594029272028226548"
- "2512128876430470827829664804162664940531442892318313783768490289055976632958517172224489818357368867918187485939206"
- "2511525475294446153720884061140214935737412169338105798844746660622109445888838301856505039889558164997842986900428"
- "451706832780583443878249787673165328239847678451875576597273825449492634194044862642622017818494316682101584595802"
- "1683349459646826044538749514744448857687163920507629663198009179347076226082396279224364058411096505586649366819639"
- "3974781563482596547935340466735509564309044585338123627615570048595283414895855463786352214200921789080075770352068")
+ [|
+ "3159920112550153431066628439665589032819589113436943826256968434878458171469430959332402305608699902549825494548481";
+ "280477632787313770308256716090223370904109239916966236801520233572575817285128701723410768518512359978230649258938";
+ "1413291885782085817633040683653940857250625455659320078914008351676709667450062537779617175392659654164452433135";
+ "1390203788953831203284410955429001727804727066121899705177902792997039912748042065096210386797318190962813044260483";
+ "2450327257338258979467333234199279439466897651669281394853367065946750995514548983056158869109063641273013270171923";
+ "49857405203040712095496579185765642444889317234755469422130724151910605131192922290259073202130142411211432065900";
+ "253274012167990632051406165976175533248954578500167998516665746125111248103572214467996880864844594029272028226548";
+ "2512128876430470827829664804162664940531442892318313783768490289055976632958517172224489818357368867918187485939206";
+ "2511525475294446153720884061140214935737412169338105798844746660622109445888838301856505039889558164997842986900428";
+ "451706832780583443878249787673165328239847678451875576597273825449492634194044862642622017818494316682101584595802";
+ "1683349459646826044538749514744448857687163920507629663198009179347076226082396279224364058411096505586649366819639";
+ "3974781563482596547935340466735509564309044585338123627615570048595283414895855463786352214200921789080075770352068";
+ |])
(f
- "2260187550608454214008014402523946797591246854296194762763246339549291192692986622616526473534137552350043439096119"
- "511810502908592920253360799481412039505088760766590337158799911534812141630027274772669388306729953702864648687235"
- "2767394630510274191868992294151054611438693629446858627592208557397604743367883522161321682723410188651847608662163"
- "733677618992961908132797197009013959518865202816377851685534716155607963689776702582138855589656307439192157992380"
- "3739678668295676670653567409078288578272452107222493707227049753106427531432476606528052284663880614725834551048460"
- "343567220957530709001800887607025758195257866788610303385678938443250352708160854807053861805081475581965668491193"
- "627043347842969800262118786263194965212126211240139127803615182468252346965558294565795218727209153087384753825695"
- "3135525456242511893773278804927853136966020760100601872741388514385485974645540996710138407954612218882458046152049"
- "1038680097970809166813744946610837411799656112189275132932339078293651360733498338606796024879662480664209438272800"
- "2505883906177045126862330316239320966697213826223217674995379618922870306736304285259901609273663050285368835932133"
- "3201936147862956747995966865082937746909465401592831786706658328599707211601780240771825459952039191153762585088218"
- "1958334343871475184626539938209536868771340221846974850005487513493346438351138986109832451505623100659593410925336"))
+ [|
+ "2260187550608454214008014402523946797591246854296194762763246339549291192692986622616526473534137552350043439096119";
+ "511810502908592920253360799481412039505088760766590337158799911534812141630027274772669388306729953702864648687235";
+ "2767394630510274191868992294151054611438693629446858627592208557397604743367883522161321682723410188651847608662163";
+ "733677618992961908132797197009013959518865202816377851685534716155607963689776702582138855589656307439192157992380";
+ "3739678668295676670653567409078288578272452107222493707227049753106427531432476606528052284663880614725834551048460";
+ "343567220957530709001800887607025758195257866788610303385678938443250352708160854807053861805081475581965668491193";
+ "627043347842969800262118786263194965212126211240139127803615182468252346965558294565795218727209153087384753825695";
+ "3135525456242511893773278804927853136966020760100601872741388514385485974645540996710138407954612218882458046152049";
+ "1038680097970809166813744946610837411799656112189275132932339078293651360733498338606796024879662480664209438272800";
+ "2505883906177045126862330316239320966697213826223217674995379618922870306736304285259901609273663050285368835932133";
+ "3201936147862956747995966865082937746909465401592831786706658328599707211601780240771825459952039191153762585088218";
+ "1958334343871475184626539938209536868771340221846974850005487513493346438351138986109832451505623100659593410925336";
+ |]))
let test_sub () =
Alcotest.(check fp12)
"equals"
(f
- "3302553944936288011643395671890771075571681497159638881272954830827032367567008527963007902081284851370109804229088"
- "1325613031177529576144133538277886189350713619747637107688493489251401019269067393891544567500333097532571295283794"
- "3805255956365341597630104644739730607199485990454731216235200520270319979759735375470238244426461522848732645582242"
- "2196648721276981988563328503938139938892211137934773085385114495500234983523501262753359657102847886110587423847168"
- "3127437766993370361458146465170019288005821048579194846864914178670867461423375299988432458740055968314665322852862"
- "304945425395469061969770290304380737390462915026224192936198947728056343810591328414986653474492012551032004415019"
- "2898307448689798982565686407038926323813195077028289552653420593797301256143759131171602797144787818249441315719452"
- "674009870830843433167645711241932305602524166984274071941075647458161614707730864745757064001444935162367045177204"
- "2760889607303326695193484568465692094448033282205796091080018189800885357661894534974811614871035999947711045979301"
- "2465323220280373332375030075978100795801342439922963455067792787314361987131732699585556895639364795485192470795614"
- "462958911565986865956219637782395139191579025158444312444715041695023763530435579920580737009932406540462434608374"
- "14550393435262095234314415188176353354796522697068473155585578156413100948935579460238797182191051302482608867277")
+ [|
+ "3302553944936288011643395671890771075571681497159638881272954830827032367567008527963007902081284851370109804229088";
+ "1325613031177529576144133538277886189350713619747637107688493489251401019269067393891544567500333097532571295283794";
+ "3805255956365341597630104644739730607199485990454731216235200520270319979759735375470238244426461522848732645582242";
+ "2196648721276981988563328503938139938892211137934773085385114495500234983523501262753359657102847886110587423847168";
+ "3127437766993370361458146465170019288005821048579194846864914178670867461423375299988432458740055968314665322852862";
+ "304945425395469061969770290304380737390462915026224192936198947728056343810591328414986653474492012551032004415019";
+ "2898307448689798982565686407038926323813195077028289552653420593797301256143759131171602797144787818249441315719452";
+ "674009870830843433167645711241932305602524166984274071941075647458161614707730864745757064001444935162367045177204";
+ "2760889607303326695193484568465692094448033282205796091080018189800885357661894534974811614871035999947711045979301";
+ "2465323220280373332375030075978100795801342439922963455067792787314361987131732699585556895639364795485192470795614";
+ "462958911565986865956219637782395139191579025158444312444715041695023763530435579920580737009932406540462434608374";
+ "14550393435262095234314415188176353354796522697068473155585578156413100948935579460238797182191051302482608867277";
+ |])
(Fp12.sub
(f
- "114317628434492963777402547849225713944776016754894887425944137970903990856299568127855965746861193102831803855316"
- "1330794661088328866278324379190307844831119113153984231090294723464336866838414732790104240513879124233936645760267"
- "682820077349712942685831444808782244087203729856631577095597078287950646118454900284542224718937099449247565866211"
- "2541805122017509324170461754319871504234807303251243066972862129561163635712011474187055436290675207110973141933982"
- "1585987320332076449717837598835656901185075640110364982460903446073741042896123764904487910931516635414792416504104"
- "3029921088799501823177617262500676237655541421229492749172325122297154015204189311942027019239102400007326816752478"
- "3054107585261413780374328134970411595453992746307388247345687054213359783238069725343576833043890842660602939094799"
- "2309483918573673457387618324019124385250281417691549513680788506763996313932998444275730969230142990401946675524438"
- "310396503003474175635473989154522083036639984599220642030249532719094826962716266890748453669266805253958158027929"
- "2840133932637102618284847584546851376950163903653961618550546053481349534178385214905314575658907893167318610878599"
- "2890090158956375957317541802200870597875764625368236090436583145261778498800959259599762835295546592450919644184906"
- "1374278753306173607307190341006418462639850053984896307033910269789945759389518149771029935845353541978592690401828")
+ [|
+ "114317628434492963777402547849225713944776016754894887425944137970903990856299568127855965746861193102831803855316";
+ "1330794661088328866278324379190307844831119113153984231090294723464336866838414732790104240513879124233936645760267";
+ "682820077349712942685831444808782244087203729856631577095597078287950646118454900284542224718937099449247565866211";
+ "2541805122017509324170461754319871504234807303251243066972862129561163635712011474187055436290675207110973141933982";
+ "1585987320332076449717837598835656901185075640110364982460903446073741042896123764904487910931516635414792416504104";
+ "3029921088799501823177617262500676237655541421229492749172325122297154015204189311942027019239102400007326816752478";
+ "3054107585261413780374328134970411595453992746307388247345687054213359783238069725343576833043890842660602939094799";
+ "2309483918573673457387618324019124385250281417691549513680788506763996313932998444275730969230142990401946675524438";
+ "310396503003474175635473989154522083036639984599220642030249532719094826962716266890748453669266805253958158027929";
+ "2840133932637102618284847584546851376950163903653961618550546053481349534178385214905314575658907893167318610878599";
+ "2890090158956375957317541802200870597875764625368236090436583145261778498800959259599762835295546592450919644184906";
+ "1374278753306173607307190341006418462639850053984896307033910269789945759389518149771029935845353541978592690401828";
+ |])
(f
- "814173238719872345551796701694358794929977339534263891485047443267903273780128904607535692794592005770616272186015"
- "5181629910799290134190840912421655480405493406347123401801234212935847569347338898559673013546026701365350476473"
- "879973676206038738473516625804955793444600559340908246192454694141662316849557389256991609421491240638409192843756"
- "345156400740527335607133250381731565342596165316469981587747634060928652188510211433695779187827321000385718086814"
- "2460959108560373481677480959401541769736137411470178020928047403526905231963586329358743081320476331138021366211029"
- "2724975663404032761207846972196295500265078506203268556236126174569097671393597983527040365764610387456294812337459"
- "155800136571614797808641727931485271640797669279098694692266460416058527094310594171974035899103024411161623375347"
- "1635474047742830024219972612777192079647757250707275441739712859305834699225267579529973905228698055239579630347234"
- "1551916450921814873859779246424734145145489522332432436282289479042241119791659596358624467927246469344141384608415"
- "374810712356729285909817508568750581148821463730998163482753266166987547046652515319757680019543097682126140082985"
- "2427131247390389091361322164418475458684185600209791777991868103566754735270523679679182098285614185910457209576532"
- "1359728359870911512072875925818242109285053531287827833878324691633532658440582570310791138663162490676110081534551"))
+ [|
+ "814173238719872345551796701694358794929977339534263891485047443267903273780128904607535692794592005770616272186015";
+ "5181629910799290134190840912421655480405493406347123401801234212935847569347338898559673013546026701365350476473";
+ "879973676206038738473516625804955793444600559340908246192454694141662316849557389256991609421491240638409192843756";
+ "345156400740527335607133250381731565342596165316469981587747634060928652188510211433695779187827321000385718086814";
+ "2460959108560373481677480959401541769736137411470178020928047403526905231963586329358743081320476331138021366211029";
+ "2724975663404032761207846972196295500265078506203268556236126174569097671393597983527040365764610387456294812337459";
+ "155800136571614797808641727931485271640797669279098694692266460416058527094310594171974035899103024411161623375347";
+ "1635474047742830024219972612777192079647757250707275441739712859305834699225267579529973905228698055239579630347234";
+ "1551916450921814873859779246424734145145489522332432436282289479042241119791659596358624467927246469344141384608415";
+ "374810712356729285909817508568750581148821463730998163482753266166987547046652515319757680019543097682126140082985";
+ "2427131247390389091361322164418475458684185600209791777991868103566754735270523679679182098285614185910457209576532";
+ "1359728359870911512072875925818242109285053531287827833878324691633532658440582570310791138663162490676110081534551";
+ |]))
let test_mul () =
Alcotest.(check fp12)
"equals"
(f
- "2769459291334042016045760656318365999112422715283761607268389276474674836440707023143101799859934899202748797427386"
- "3361320093180761939725550094168988000971274999740984587588968831333492275445713065388295550504330088713053119659248"
- "2548058068324782003511582863560967716415975732420681850701575946506718185654529020546234051591864142079999479468312"
- "2832018745467737515819525261173821675791848574299575461716718224691533072415952644294554311485484240251461998553646"
- "3439704161884893823555257769651271148320755007087117925446721974393201492838174177133034642764840371798879036849279"
- "2281104732151119255911652385082379793572539700746943286088110168179780216568371455040179036953876759046938448866990"
- "2015349705563352245995128836142944307288590644854023576468059839756795566611952082365200188828979549227984715122487"
- "155159649148811540561459146065591286181994346958123489722131136875807099831440751360149754587770106079973431322217"
- "3667366500769490085341434481129794744757896765430211409460846330993398960673516540894555067887119647442948261891721"
- "3443457215989773083210277336336386477319698634144615905045854619225124817069488127578774116205921282424119802129140"
- "1398097189476533387592939930766583747023012857085645758824473894144850073357928429202288558262130720000402076976850"
- "905934421424989755770709842314968754142619338124544865909393071018998472742701334456268966551948065227132135928541")
+ [|
+ "2769459291334042016045760656318365999112422715283761607268389276474674836440707023143101799859934899202748797427386";
+ "3361320093180761939725550094168988000971274999740984587588968831333492275445713065388295550504330088713053119659248";
+ "2548058068324782003511582863560967716415975732420681850701575946506718185654529020546234051591864142079999479468312";
+ "2832018745467737515819525261173821675791848574299575461716718224691533072415952644294554311485484240251461998553646";
+ "3439704161884893823555257769651271148320755007087117925446721974393201492838174177133034642764840371798879036849279";
+ "2281104732151119255911652385082379793572539700746943286088110168179780216568371455040179036953876759046938448866990";
+ "2015349705563352245995128836142944307288590644854023576468059839756795566611952082365200188828979549227984715122487";
+ "155159649148811540561459146065591286181994346958123489722131136875807099831440751360149754587770106079973431322217";
+ "3667366500769490085341434481129794744757896765430211409460846330993398960673516540894555067887119647442948261891721";
+ "3443457215989773083210277336336386477319698634144615905045854619225124817069488127578774116205921282424119802129140";
+ "1398097189476533387592939930766583747023012857085645758824473894144850073357928429202288558262130720000402076976850";
+ "905934421424989755770709842314968754142619338124544865909393071018998472742701334456268966551948065227132135928541";
+ |])
(Fp12.mul
(f
- "3188965852511671063713365520426013860876038913881062821253377695122765059224885667839392639969816734037104670613244"
- "739230562742065869428711570131322565650363017363321772468200996729374315480859067980217062249942447699717461975435"
- "2176703902856768340923498396069790708726027328202399564021031361317557749307316024777712001130489797595255105145574"
- "2670928296575291897567182668008518066900700368725847572099438663375532458643254583023716168915531437800319570762359"
- "490493474292589590290985164041744408386694847492050815490827814231625948304243075844177545163347050487540031351408"
- "1447231287355316410460109761296716454406840030157949463466429671839408681857143198732909489409168758850527959693128"
- "380566892947120789169176467967036122180970212567524587253946816937505290817541604787685483045734490086808180188209"
- "1933270752469040734962325106835008701319037970034715630543772447121736485673581521720004281570522954301236757912058"
- "3764384355623541980227347862260938586306933471250237826985597550572856756424268613647164167330369743152591888002476"
- "1255883430247624307681915611919079518991014033717687609361032678352309027109569694756330457157678676849112845044093"
- "249133888792184767833878049631213302737617830806417857850257246800963239084169262142539368627987584542252728578744"
- "1318313694940289353002371656163361499247765041433217402587131255038015671326878036168961275846882909253309634498906")
+ [|
+ "3188965852511671063713365520426013860876038913881062821253377695122765059224885667839392639969816734037104670613244";
+ "739230562742065869428711570131322565650363017363321772468200996729374315480859067980217062249942447699717461975435";
+ "2176703902856768340923498396069790708726027328202399564021031361317557749307316024777712001130489797595255105145574";
+ "2670928296575291897567182668008518066900700368725847572099438663375532458643254583023716168915531437800319570762359";
+ "490493474292589590290985164041744408386694847492050815490827814231625948304243075844177545163347050487540031351408";
+ "1447231287355316410460109761296716454406840030157949463466429671839408681857143198732909489409168758850527959693128";
+ "380566892947120789169176467967036122180970212567524587253946816937505290817541604787685483045734490086808180188209";
+ "1933270752469040734962325106835008701319037970034715630543772447121736485673581521720004281570522954301236757912058";
+ "3764384355623541980227347862260938586306933471250237826985597550572856756424268613647164167330369743152591888002476";
+ "1255883430247624307681915611919079518991014033717687609361032678352309027109569694756330457157678676849112845044093";
+ "249133888792184767833878049631213302737617830806417857850257246800963239084169262142539368627987584542252728578744";
+ "1318313694940289353002371656163361499247765041433217402587131255038015671326878036168961275846882909253309634498906";
+ |])
(f
- "4001873370591540083496166250646055711726072422193724090307974274629729343800446490612585626259709075180407919102622"
- "2381691022154841244422795422272821831958572984018765292538573818425881254555104379811082907429249497777931833833376"
- "280598032905619331801221212082915377532443217602049470185527116036623938978512431470105010230000261635064479395726"
- "3201267635033507671570742561753619101772478174192594656326090148928091568774524367063003457402869495752556937283287"
- "235662028814856435814177059372599670172928395505573490987559673717902910667854381750212127270270615977469099765899"
- "2767542260487979603817786865232490339768738539649093598109993837852031223891091898135323929286876809238782193512589"
- "461931201117817542257036959941540589433085255840277245099857960931805762867169082291827137797005994717405863452458"
- "2352905815802217650777604705491663515805476928982110124837855837463020809344910768781112298539176325025716749994185"
- "565988735302527395594598223791239663211041041894166833196313968046686963510638275205734606307498578656794695467639"
- "635003532145447302815810457639392294067051414008441966927557377389534021035755093764489766183353612834453688937680"
- "3326309082927816928671114598367626403152435253065767331209692366852408397633791132983761483456881458862714270033581"
- "1847549737499226286135589532836789142960266552488220324407653442999952545023129510122014859030811553097538193595356"))
+ [|
+ "4001873370591540083496166250646055711726072422193724090307974274629729343800446490612585626259709075180407919102622";
+ "2381691022154841244422795422272821831958572984018765292538573818425881254555104379811082907429249497777931833833376";
+ "280598032905619331801221212082915377532443217602049470185527116036623938978512431470105010230000261635064479395726";
+ "3201267635033507671570742561753619101772478174192594656326090148928091568774524367063003457402869495752556937283287";
+ "235662028814856435814177059372599670172928395505573490987559673717902910667854381750212127270270615977469099765899";
+ "2767542260487979603817786865232490339768738539649093598109993837852031223891091898135323929286876809238782193512589";
+ "461931201117817542257036959941540589433085255840277245099857960931805762867169082291827137797005994717405863452458";
+ "2352905815802217650777604705491663515805476928982110124837855837463020809344910768781112298539176325025716749994185";
+ "565988735302527395594598223791239663211041041894166833196313968046686963510638275205734606307498578656794695467639";
+ "635003532145447302815810457639392294067051414008441966927557377389534021035755093764489766183353612834453688937680";
+ "3326309082927816928671114598367626403152435253065767331209692366852408397633791132983761483456881458862714270033581";
+ "1847549737499226286135589532836789142960266552488220324407653442999952545023129510122014859030811553097538193595356";
+ |]))
let test_div () =
Alcotest.(check fp12)
"equals"
(f
- "1088191120450889471008080434220823822724481466713997839230930280979494944365169538570720787371316135622615380704907"
- "763586133645656306504237229020782434670077269496450825440272754809264673423806612505833519243290624472723147173348"
- "1707679080535042433675444210439209318150111604054543396361463652314045859894921581420249937947110141828350610877993"
- "827719249543693888899520078226963351508440005829157207139779006188312805663643955920764377010883516024971471412392"
- "1670976992567442264594092472913962112664205686219416536583345959321143994394979677168463645851734273195131213548769"
- "1332580825428383428915357054358964399667499601326760579660311040723405346096321805018432619765572146789465208947413"
- "3022912129472159846831339528062355962231308863485628015140274259231118064888526224703517916104229049483242824113499"
- "2614858795056328963792613930127519383950909788846840302217657952676013771314600089040168561513165821379236778779390"
- "3042455406421231680689024574442362895780321848721368922808317665636039424337674315246068583526430967830075629358278"
- "1915688907907831828287174596392774041948474822125277657742586455558627195848534825636734762819155454967137835530417"
- "2699429829070728410559484094948933802442497083319705661264366297393973601594198492466505856394860764197145873591205"
- "2556773905133270246408876485939744407521607167628527716285291299155235848448290034403167143189795397270468361200924")
+ [|
+ "1088191120450889471008080434220823822724481466713997839230930280979494944365169538570720787371316135622615380704907";
+ "763586133645656306504237229020782434670077269496450825440272754809264673423806612505833519243290624472723147173348";
+ "1707679080535042433675444210439209318150111604054543396361463652314045859894921581420249937947110141828350610877993";
+ "827719249543693888899520078226963351508440005829157207139779006188312805663643955920764377010883516024971471412392";
+ "1670976992567442264594092472913962112664205686219416536583345959321143994394979677168463645851734273195131213548769";
+ "1332580825428383428915357054358964399667499601326760579660311040723405346096321805018432619765572146789465208947413";
+ "3022912129472159846831339528062355962231308863485628015140274259231118064888526224703517916104229049483242824113499";
+ "2614858795056328963792613930127519383950909788846840302217657952676013771314600089040168561513165821379236778779390";
+ "3042455406421231680689024574442362895780321848721368922808317665636039424337674315246068583526430967830075629358278";
+ "1915688907907831828287174596392774041948474822125277657742586455558627195848534825636734762819155454967137835530417";
+ "2699429829070728410559484094948933802442497083319705661264366297393973601594198492466505856394860764197145873591205";
+ "2556773905133270246408876485939744407521607167628527716285291299155235848448290034403167143189795397270468361200924";
+ |])
(Fp12.div
(f
- "553519384159409545394828443365875904103984936708617615018997854922725722045050663916872183987860344110881458839300"
- "2551179480580905827815816507015793090462143539258201052682699476482990332142911858021207505604703941240285222712127"
- "3293736434413374618351634015836468677887129730347082720891859721435831590023521317591181426300262391017914412314452"
- "1126069844494917325334876146715289301900746396397803311418144330973830221622870125903645445357364929754717926022010"
- "2948659636755282229787876268434177316237104051743077525585857738600440901412973493286500817512218767732685063028927"
- "2364444973260657648984604501944196434318571008532303451512979193388627541667853845350145766007457933492528774608364"
- "1543784379424065791608190347537667949396972361188055194366508310148735469329834791944686050406146949830424922635676"
- "911931132736808617483189599074438345466177318795470132404606720436237726817086490751673788994970605241869953651718"
- "735198991681366730725229643665191010980125457374997642991474607960460778691571711798267933027111316714986161192182"
- "97010038858965734213682017802148146496114737698885571098652579465016354652266840122234009349707468786023755170643"
- "2327540194916374633650422506254589901440606348243254413955101853356793690734868276236653592467951864568737565156462"
- "2819837983673746453085471900604194981619924849353466195641626861041559460819593939717905185795048926505935561664940")
+ [|
+ "553519384159409545394828443365875904103984936708617615018997854922725722045050663916872183987860344110881458839300";
+ "2551179480580905827815816507015793090462143539258201052682699476482990332142911858021207505604703941240285222712127";
+ "3293736434413374618351634015836468677887129730347082720891859721435831590023521317591181426300262391017914412314452";
+ "1126069844494917325334876146715289301900746396397803311418144330973830221622870125903645445357364929754717926022010";
+ "2948659636755282229787876268434177316237104051743077525585857738600440901412973493286500817512218767732685063028927";
+ "2364444973260657648984604501944196434318571008532303451512979193388627541667853845350145766007457933492528774608364";
+ "1543784379424065791608190347537667949396972361188055194366508310148735469329834791944686050406146949830424922635676";
+ "911931132736808617483189599074438345466177318795470132404606720436237726817086490751673788994970605241869953651718";
+ "735198991681366730725229643665191010980125457374997642991474607960460778691571711798267933027111316714986161192182";
+ "97010038858965734213682017802148146496114737698885571098652579465016354652266840122234009349707468786023755170643";
+ "2327540194916374633650422506254589901440606348243254413955101853356793690734868276236653592467951864568737565156462";
+ "2819837983673746453085471900604194981619924849353466195641626861041559460819593939717905185795048926505935561664940";
+ |])
(f
- "3659460078149879001326507968005835143443273255368528177408849590512039955706053472882397547960477348262898117834992"
- "1411887134534869698530903323518776142275919065091117458618790951859171627994980372213450665325067823376007037339496"
- "1370180038531956719537291195447646815964136047415891792957615965221930267663030748831633577127678514914661955764546"
- "2940156517138858640290129479419494068549288339660729264664218260452822733746997136205496907651633687825963363247525"
- "939869771623157928890792782966937726297983662565406960493067262901149914939870089700504524656981164130396303206617"
- "2835423297696274650004757144329922009277352017479256469999713870412075023214829435523270461062113497323069970866657"
- "3223415582396100811749718836855028104928416515236239249071829048255916532185741487948072584341519903713918326301135"
- "3682126611207831212310201819657665427809296346090344016066649599364174095299298762483592987469818157989734232939857"
- "1350350826667854275057334687660534971455319159947207878924976406309061336504357452346590883878730254593697158913399"
- "2486364747653101657306704833360712823201299556169280757882865190162919666627645426290188904278660748092056268744369"
- "1615429309095368427137050356678981375951561384670799935192898670305508950053725720249524621420395227999560990386034"
- "485555330932470122639034055733320699175008602546225368389195384633967594821038350260245866636580552683463223464005"));
+ [|
+ "3659460078149879001326507968005835143443273255368528177408849590512039955706053472882397547960477348262898117834992";
+ "1411887134534869698530903323518776142275919065091117458618790951859171627994980372213450665325067823376007037339496";
+ "1370180038531956719537291195447646815964136047415891792957615965221930267663030748831633577127678514914661955764546";
+ "2940156517138858640290129479419494068549288339660729264664218260452822733746997136205496907651633687825963363247525";
+ "939869771623157928890792782966937726297983662565406960493067262901149914939870089700504524656981164130396303206617";
+ "2835423297696274650004757144329922009277352017479256469999713870412075023214829435523270461062113497323069970866657";
+ "3223415582396100811749718836855028104928416515236239249071829048255916532185741487948072584341519903713918326301135";
+ "3682126611207831212310201819657665427809296346090344016066649599364174095299298762483592987469818157989734232939857";
+ "1350350826667854275057334687660534971455319159947207878924976406309061336504357452346590883878730254593697158913399";
+ "2486364747653101657306704833360712823201299556169280757882865190162919666627645426290188904278660748092056268744369";
+ "1615429309095368427137050356678981375951561384670799935192898670305508950053725720249524621420395227999560990386034";
+ "485555330932470122639034055733320699175008602546225368389195384633967594821038350260245866636580552683463223464005";
+ |]));
Alcotest.(check fp12)
"equals" Fp12.zero
(Fp12.div
(f
- "2363095163847131454975167851617986026737599557880578661124850689113964885453223688395116630767021081071861181923384"
- "603730799793826726418275010088472602074783832643744332283635509909458807205331337394866376596471524093229001264001"
- "468280384918428881309534413155999744540798384749005987590963756021655141222823418191220262201621882943300938983522"
- "3531967301631406423135320989786899549878860332140476451698049944658024523778751586015243193559362530400101760521047"
- "3328304605311853921199900198543165990884781662436100871445779045643983518867920209644497734859723122592756134964592"
- "1705357535555824874328863505240453699271685052327246065134812663169822635879254751692466868718919685541722500307553"
- "1943162376863013487975764682713653412656066573367251902046789065188971130502469488995800280459140695452496695113013"
- "577564390313055436293383452509271549231018927510471100349442569739931728983831439647811621690255225862401826847692"
- "1363712630403203093135964563411368345118664271008137801123819674077813980993708066842046609086405074439025674212952"
- "476292231642492692401964083527458570753957231499794532035187199649731575181835012328774344557854564086912070179718"
- "355737467024789378626103721103250809692871887649120960319877490924413542062808880331179181598955424666257053945034"
- "356372965698149812539584039654274766468102724556855527351368208179947933904344169138032198394319512433308318932125")
+ [|
+ "2363095163847131454975167851617986026737599557880578661124850689113964885453223688395116630767021081071861181923384";
+ "603730799793826726418275010088472602074783832643744332283635509909458807205331337394866376596471524093229001264001";
+ "468280384918428881309534413155999744540798384749005987590963756021655141222823418191220262201621882943300938983522";
+ "3531967301631406423135320989786899549878860332140476451698049944658024523778751586015243193559362530400101760521047";
+ "3328304605311853921199900198543165990884781662436100871445779045643983518867920209644497734859723122592756134964592";
+ "1705357535555824874328863505240453699271685052327246065134812663169822635879254751692466868718919685541722500307553";
+ "1943162376863013487975764682713653412656066573367251902046789065188971130502469488995800280459140695452496695113013";
+ "577564390313055436293383452509271549231018927510471100349442569739931728983831439647811621690255225862401826847692";
+ "1363712630403203093135964563411368345118664271008137801123819674077813980993708066842046609086405074439025674212952";
+ "476292231642492692401964083527458570753957231499794532035187199649731575181835012328774344557854564086912070179718";
+ "355737467024789378626103721103250809692871887649120960319877490924413542062808880331179181598955424666257053945034";
+ "356372965698149812539584039654274766468102724556855527351368208179947933904344169138032198394319512433308318932125";
+ |])
Fp12.zero)
let test_neg () =
Alcotest.(check fp12)
"equals"
(f
- "3239016682797318685312208982528307830172802538201642963600043396394832879722910379590968867830840935131031900043317"
- "3316038793989753908571740206096060941727103212792388906703728120542085172528115130585397465339510398334734129411689"
- "3357295947947428750797875951523040991297856178658428300568137974581540870728043828339177627553146775126133031283698"
- "3567976935861330059298612795341805547834764304660787129519245303497771596167467391720755408530196349862783108290491"
- "2445650416160796961403637763709895351193054475902059348755902313520489259893661399593635632193390173859657188640229"
- "3610497391498930888615065924582074283508545064142386323512527153957393455707077329761314789089101265786887578144482"
- "3589721763488203139404385680541349261261989278408893195672284347139129229101382380760913715230886365608535849527204"
- "2778204787525050919644284985114187680759605423708903374245942501811486358282974409669013992430271345558444913612161"
- "1230519620266756695697652504847058612962080294010175955178467015082305671262155988462080859479913781149026452107381"
- "886176932117428879649099925925308847718649044800815717037071716335947041678497415529440658441347478453638038087367"
- "2887111936704023752478188750772227065214720424150139981491903072650356763615004307799929002447126451849190724989712"
- "1682046371583137799485170506948051010786599812304576451543936485337302185465632275557970031518260231147006483255452")
+ [|
+ "3239016682797318685312208982528307830172802538201642963600043396394832879722910379590968867830840935131031900043317";
+ "3316038793989753908571740206096060941727103212792388906703728120542085172528115130585397465339510398334734129411689";
+ "3357295947947428750797875951523040991297856178658428300568137974581540870728043828339177627553146775126133031283698";
+ "3567976935861330059298612795341805547834764304660787129519245303497771596167467391720755408530196349862783108290491";
+ "2445650416160796961403637763709895351193054475902059348755902313520489259893661399593635632193390173859657188640229";
+ "3610497391498930888615065924582074283508545064142386323512527153957393455707077329761314789089101265786887578144482";
+ "3589721763488203139404385680541349261261989278408893195672284347139129229101382380760913715230886365608535849527204";
+ "2778204787525050919644284985114187680759605423708903374245942501811486358282974409669013992430271345558444913612161";
+ "1230519620266756695697652504847058612962080294010175955178467015082305671262155988462080859479913781149026452107381";
+ "886176932117428879649099925925308847718649044800815717037071716335947041678497415529440658441347478453638038087367";
+ "2887111936704023752478188750772227065214720424150139981491903072650356763615004307799929002447126451849190724989712";
+ "1682046371583137799485170506948051010786599812304576451543936485337302185465632275557970031518260231147006483255452";
+ |])
(Fp12.neg
(f
- "763392872424348708105580843207596326384080281737364921732014739729198770767927484851718761298174728906862372516470"
- "686370761231913484846049619639843214829779607146618978628330015581946477962722733857290163789505265703160143148098"
- "645113607274238642619913874212863165259026641280579584763920161542490779762794036103510001575868888911761241276089"
- "434432619360337334119177030394098608722118515278220755812812832626260054323370472721932220598819314175111164269296"
- "1556759139060870432014152062026008805363828344036948536576155822603542390597176464849051996935625490178237083919558"
- "391912163722736504802723901153829873048337755796621561819530982166638194783760534681372840039914398251006694415305"
- "412687791733464254013404145194554895294893541530114689659773788984902421389455483681773913898129298429358423032583"
- "1224204767696616473773504840621716475797277396230104511086115634312545292207863454773673636698744318479449358947626"
- "2771889934954910697720137320888845543594802525928831930153591121041725979228681875980606769649101882888867820452406"
- "3116232623104238513768689899810595308838233775138192168294986419788084608812340448913246970687668185584256234472420"
- "1115297618517643640939601074963677091342162395788867903840155063473674886875833556642758626681889212188703547570075"
- "2320363183638529593932619318787853145770283007634431433788121650786729465025205588884717597610755432890887789304335"));
+ [|
+ "763392872424348708105580843207596326384080281737364921732014739729198770767927484851718761298174728906862372516470";
+ "686370761231913484846049619639843214829779607146618978628330015581946477962722733857290163789505265703160143148098";
+ "645113607274238642619913874212863165259026641280579584763920161542490779762794036103510001575868888911761241276089";
+ "434432619360337334119177030394098608722118515278220755812812832626260054323370472721932220598819314175111164269296";
+ "1556759139060870432014152062026008805363828344036948536576155822603542390597176464849051996935625490178237083919558";
+ "391912163722736504802723901153829873048337755796621561819530982166638194783760534681372840039914398251006694415305";
+ "412687791733464254013404145194554895294893541530114689659773788984902421389455483681773913898129298429358423032583";
+ "1224204767696616473773504840621716475797277396230104511086115634312545292207863454773673636698744318479449358947626";
+ "2771889934954910697720137320888845543594802525928831930153591121041725979228681875980606769649101882888867820452406";
+ "3116232623104238513768689899810595308838233775138192168294986419788084608812340448913246970687668185584256234472420";
+ "1115297618517643640939601074963677091342162395788867903840155063473674886875833556642758626681889212188703547570075";
+ "2320363183638529593932619318787853145770283007634431433788121650786729465025205588884717597610755432890887789304335";
+ |]));
let a =
f
- "2674558880713508459106932371829324741448390140653164261219319038425967521792347569735421320255051555408127538024015"
- "1914723839108830765501130412748560724031028943530932535891511671410855782791457159429778693319997311838427348346378"
- "3021973199857248001042125312750465993235517612274584564622791388866663313917106430659996196237919521405386843462441"
- "3761958525158545572974997634091967142510400252155830344612188100969775348634350061099793454227378256560196009908443"
- "3618734350748331834526994589505038579770921366815827658550850282532958723895236679190825120046817084128189749265250"
- "488365730138835632910385460035400647546564592760382101839256044839585728519725036243750547131502053120566329146944"
- "2119646654779707056589738808274831187534166025276869384226648001479446094360244733779046613609347706465404873145183"
- "2109322561472002509234198537752063171525572756955153278721066909767387890382129255374889767835518536381876879064150"
- "2450430019100289140572386801682598523440075744249597570754470315214309867432755926641266067266701184192347340619326"
- "3352475614513689261233943415274904340597894417713417066363229302051596280805260004926141273265080428045835405419808"
- "69266478339261496228055134969514420300702979045657486091933776002846046696437437849394365115164989340639838867842"
- "2843981689624126130615870214705260595090587151890382137278946280653679908751415441829465678567867845269130967508296"
+ [|
+ "2674558880713508459106932371829324741448390140653164261219319038425967521792347569735421320255051555408127538024015";
+ "1914723839108830765501130412748560724031028943530932535891511671410855782791457159429778693319997311838427348346378";
+ "3021973199857248001042125312750465993235517612274584564622791388866663313917106430659996196237919521405386843462441";
+ "3761958525158545572974997634091967142510400252155830344612188100969775348634350061099793454227378256560196009908443";
+ "3618734350748331834526994589505038579770921366815827658550850282532958723895236679190825120046817084128189749265250";
+ "488365730138835632910385460035400647546564592760382101839256044839585728519725036243750547131502053120566329146944";
+ "2119646654779707056589738808274831187534166025276869384226648001479446094360244733779046613609347706465404873145183";
+ "2109322561472002509234198537752063171525572756955153278721066909767387890382129255374889767835518536381876879064150";
+ "2450430019100289140572386801682598523440075744249597570754470315214309867432755926641266067266701184192347340619326";
+ "3352475614513689261233943415274904340597894417713417066363229302051596280805260004926141273265080428045835405419808";
+ "69266478339261496228055134969514420300702979045657486091933776002846046696437437849394365115164989340639838867842";
+ "2843981689624126130615870214705260595090587151890382137278946280653679908751415441829465678567867845269130967508296";
+ |]
in
Alcotest.(check fp12) "equals" Fp12.zero (Fp12.add a (Fp12.neg a))
@@ -288,46 +307,52 @@ let test_inv () =
Alcotest.(check fp12)
"equals"
(f
- "1547319709794669291105429180299582165003006608953164424633137062061940120223896065736698269606199927463220884999258"
- "2229043319885080125966458766562809098808970927864341323462479235857714537012516233189229849451799838681367686171307"
- "1980274252624688015134481064209114532028847100768727191977892931021655209304333319806229181953416610279953385689067"
- "1948290523106701151503209932124501084773933042706460502698986147627963103342770392074740246981217822228805152386972"
- "522633451827910717214069798171839632324964227981942625500365625992561034846979785542487047252109174193627509714092"
- "1244053992071895450467490323919864998680089193720663303110097628761750124906567322727867537406466019596688807924278"
- "3476701950080900029803275488221106535824844690090772206016679533425021841071305380076286619524329127415515567054333"
- "3065850315308290754435371266738032144868130262782483539178816046641998452348105495939997221589229661912588379674066"
- "2392491300711489422370748577220666945538613353002735797782418460438049930733920617970213613898822014210835944834040"
- "1173137184917550579787317192980011551320012099102485803075850833795097962214090106348862499493761112552319932918820"
- "3406347090157530227104698471818164619480373110731540070686223372928278377689489890330832774676223610700660150476974"
- "3017743790597235667250653583289611819318563679226746319993832881306778651947200069220317772337394197851536681648266")
+ [|
+ "1547319709794669291105429180299582165003006608953164424633137062061940120223896065736698269606199927463220884999258";
+ "2229043319885080125966458766562809098808970927864341323462479235857714537012516233189229849451799838681367686171307";
+ "1980274252624688015134481064209114532028847100768727191977892931021655209304333319806229181953416610279953385689067";
+ "1948290523106701151503209932124501084773933042706460502698986147627963103342770392074740246981217822228805152386972";
+ "522633451827910717214069798171839632324964227981942625500365625992561034846979785542487047252109174193627509714092";
+ "1244053992071895450467490323919864998680089193720663303110097628761750124906567322727867537406466019596688807924278";
+ "3476701950080900029803275488221106535824844690090772206016679533425021841071305380076286619524329127415515567054333";
+ "3065850315308290754435371266738032144868130262782483539178816046641998452348105495939997221589229661912588379674066";
+ "2392491300711489422370748577220666945538613353002735797782418460438049930733920617970213613898822014210835944834040";
+ "1173137184917550579787317192980011551320012099102485803075850833795097962214090106348862499493761112552319932918820";
+ "3406347090157530227104698471818164619480373110731540070686223372928278377689489890330832774676223610700660150476974";
+ "3017743790597235667250653583289611819318563679226746319993832881306778651947200069220317772337394197851536681648266";
+ |])
(Fp12.inv
(f
- "1066191393679157186707843782051189795202804303471471356012317309373237976010857447807331244600689281404118732720147"
- "753294877122124702466251517057371154665171085030386866043649010161854535245979686863130228117275163812848081871401"
- "886566903832042606674724679912862710846499242777068730080835673252912500400028170713071004839135039984643138460876"
- "658200382089078840575771577494391841520083861514392781529525824935640632454096656712137944876117974116204118697106"
- "1183978516593322586363599350906068179900722774061030457309879697391349269870026908217421181592364329737352869389689"
- "1946928416933944132589965348968615256315821474187900596913502511936717875608751629236563781006294687855876561767169"
- "1249631166116600052962820896700453582677375439104493105102825905588560663631803960549367536439622707780650550564546"
- "63632093830057160223602690892969802263563020427366974647497230658520946774736415658749391367225787900071853983109"
- "2570948575383773011575976710959847035212095732731231075623317581301368347106876766957200960715335828838071035611160"
- "1506142752724262259445751072821307942893924549254798204919026959551954497518486564947410351229100287104962536882857"
- "578672450059892855276008711721559049708792194100323752623613112905842590085833660168948006422975904828320438023386"
- "2076603552112451030180447061945851308784183837427998418875612110088729657242386906133974913226866321849639097656040"));
+ [|
+ "1066191393679157186707843782051189795202804303471471356012317309373237976010857447807331244600689281404118732720147";
+ "753294877122124702466251517057371154665171085030386866043649010161854535245979686863130228117275163812848081871401";
+ "886566903832042606674724679912862710846499242777068730080835673252912500400028170713071004839135039984643138460876";
+ "658200382089078840575771577494391841520083861514392781529525824935640632454096656712137944876117974116204118697106";
+ "1183978516593322586363599350906068179900722774061030457309879697391349269870026908217421181592364329737352869389689";
+ "1946928416933944132589965348968615256315821474187900596913502511936717875608751629236563781006294687855876561767169";
+ "1249631166116600052962820896700453582677375439104493105102825905588560663631803960549367536439622707780650550564546";
+ "63632093830057160223602690892969802263563020427366974647497230658520946774736415658749391367225787900071853983109";
+ "2570948575383773011575976710959847035212095732731231075623317581301368347106876766957200960715335828838071035611160";
+ "1506142752724262259445751072821307942893924549254798204919026959551954497518486564947410351229100287104962536882857";
+ "578672450059892855276008711721559049708792194100323752623613112905842590085833660168948006422975904828320438023386";
+ "2076603552112451030180447061945851308784183837427998418875612110088729657242386906133974913226866321849639097656040";
+ |]));
let a =
f
- "1208966610438465338305389577023182898477810750073179153177193479414956729633609159004857811454106784276506729547971"
- "878117770070592886292851651285756003086947577201631030994180684887176394897698780758224530257083732256620268399253"
- "548196222937805369043152681944575146709916830808914429680607869555582475847707614178025431399396440947081154824656"
- "120361898306611803235948449800937268776271657170546616625010657073903311070901802070685247720941506976164148116041"
- "3964636105168373611333255357861614192436971141483140416935414390820244461762503816156256779876668577147472156490209"
- "2392093471959448428928572333380043862138927289251828500295961424616922247930393751398948013241811775753517425589689"
- "2313367322768114403468619467839971138575666376558527747639381694440360798797866017560151588773556227064940467796470"
- "1208381860711933470736945041380525333495094437324245697710669671036306045819919163619533369357722960726957896456492"
- "2227820701107578290372462312147333757161380867430446354901322687892665157518793755620366301150191448063025386430447"
- "1411863135366961368181181760640483990438018759158132983046914387827694179968324546478953773237400394923749152695783"
- "3323709210754140447864882614412202218853338035811625935497215960147856051658231463810236408935190367064958795421190"
- "143983650378758285583688397712444406640456446054354147618017894683334939480068047602380254998161328315616611277083"
+ [|
+ "1208966610438465338305389577023182898477810750073179153177193479414956729633609159004857811454106784276506729547971";
+ "878117770070592886292851651285756003086947577201631030994180684887176394897698780758224530257083732256620268399253";
+ "548196222937805369043152681944575146709916830808914429680607869555582475847707614178025431399396440947081154824656";
+ "120361898306611803235948449800937268776271657170546616625010657073903311070901802070685247720941506976164148116041";
+ "3964636105168373611333255357861614192436971141483140416935414390820244461762503816156256779876668577147472156490209";
+ "2392093471959448428928572333380043862138927289251828500295961424616922247930393751398948013241811775753517425589689";
+ "2313367322768114403468619467839971138575666376558527747639381694440360798797866017560151588773556227064940467796470";
+ "1208381860711933470736945041380525333495094437324245697710669671036306045819919163619533369357722960726957896456492";
+ "2227820701107578290372462312147333757161380867430446354901322687892665157518793755620366301150191448063025386430447";
+ "1411863135366961368181181760640483990438018759158132983046914387827694179968324546478953773237400394923749152695783";
+ "3323709210754140447864882614412202218853338035811625935497215960147856051658231463810236408935190367064958795421190";
+ "143983650378758285583688397712444406640456446054354147618017894683334939480068047602380254998161328315616611277083";
+ |]
in
Alcotest.(check fp12) "equals" Fp12.one (Fp12.mul a (Fp12.inv a));
Alcotest.(check fp12) "equals" Fp12.zero (Fp12.inv Fp12.zero)
diff --git a/test/test_fp2.ml b/test/test_fp2.ml
index c108cfc..83e7581 100644
--- a/test/test_fp2.ml
+++ b/test/test_fp2.ml
@@ -1,14 +1,16 @@
module Fp = Plonkers.Fields.Fp
module Fp2 = Plonkers.Fields.Fp2
-let fp2 = Testable.make Fp2.to_string Fp2.equal
-let f c0 c1 = Fp2.of_coeffs Fp.(of_string c0, of_string c1)
+let fp2 = Primitives.Testables.fp2
+let f = Primitives.Literals.fp2
let test_strconv () =
let a =
f
- "3216159770949743003016282596382810410524821318260601360202344327568616081946682522800622973525694628320886337554707"
- "3042776432360195460319296407183823967792916594876398306463713661277272294244991791711647871371679651495395139475044"
+ [|
+ "3216159770949743003016282596382810410524821318260601360202344327568616081946682522800622973525694628320886337554707";
+ "3042776432360195460319296407183823967792916594876398306463713661277272294244991791711647871371679651495395139475044";
+ |]
in
Alcotest.(check string)
"equals"
@@ -23,79 +25,111 @@ let test_add () =
Alcotest.(check fp2)
"equals"
(f
- "1510922689064524402660706287794383764925405808912063605538062764260624404168626064439638568280286334446426980599265"
- "1496432034719009204104939852773510654757730640471573422565456754717202107187391202678306935556569591898047519241723")
+ [|
+ "1510922689064524402660706287794383764925405808912063605538062764260624404168626064439638568280286334446426980599265";
+ "1496432034719009204104939852773510654757730640471573422565456754717202107187391202678306935556569591898047519241723";
+ |])
(Fp2.add
(f
- "2704945784483088396721340837125430974578228372397373052449492346866782679603876968318204562585444722881993787072969"
- "3352713865626504319356760967861765786693715633606160360950371888464145243153004345983441305675063325004158251106532")
+ [|
+ "2704945784483088396721340837125430974578228372397373052449492346866782679603876968318204562585444722881993787072969";
+ "3352713865626504319356760967861765786693715633606160360950371888464145243153004345983441305675063325004158251106532";
+ |])
(f
- "2808386459803103399357155276404856946904060256453698438420628553517873375055586960564121634823857275602327466086083"
- "2146127724314172278165968710647649024620897826804420946947143002377088514525224721137553259010521930931783540694978"))
+ [|
+ "2808386459803103399357155276404856946904060256453698438420628553517873375055586960564121634823857275602327466086083";
+ "2146127724314172278165968710647649024620897826804420946947143002377088514525224721137553259010521930931783540694978";
+ |]))
let test_sub () =
Alcotest.(check fp2)
"equals"
(f
- "2746233490314206119922872871732785027444344635498924519980558228449368171837071387946659139045523440232024909392314"
- "2448129066313268798189916410701811180368378842353203391514920640569880371240863965817664159595772806445686456192024")
+ [|
+ "2746233490314206119922872871732785027444344635498924519980558228449368171837071387946659139045523440232024909392314";
+ "2448129066313268798189916410701811180368378842353203391514920640569880371240863965817664159595772806445686456192024";
+ |])
(Fp2.sub
(f
- "3718052663769508561298229087440516584831920387492170643569413395812990566524218001757670372308077205706322080181599"
- "2341793402065270422967665886452846002018783895673345084011697286747619532326972232127106898002302648025798998240672")
+ [|
+ "3718052663769508561298229087440516584831920387492170643569413395812990566524218001757670372308077205706322080181599";
+ "2341793402065270422967665886452846002018783895673345084011697286747619532326972232127106898002302648025798998240672";
+ |])
(f
- "971819173455302441375356215707731557387575751993246123588855167363622394687146613811011233262553765474297170789285"
- "3896073890973669018195539301486938978207287873259149577828834782301770811576946130752130367535545505618006814608435"))
+ [|
+ "971819173455302441375356215707731557387575751993246123588855167363622394687146613811011233262553765474297170789285";
+ "3896073890973669018195539301486938978207287873259149577828834782301770811576946130752130367535545505618006814608435";
+ |]))
let test_mul () =
Alcotest.(check fp2)
"equals"
(f
- "1885423083277797471109639559263547433578030928072896554966830817836333890642646249004478238507722056220637045498600"
- "3207243584937107335460533661085834171833693638143693295511055862451917226660443578426964769719700546772951496395996")
+ [|
+ "1885423083277797471109639559263547433578030928072896554966830817836333890642646249004478238507722056220637045498600";
+ "3207243584937107335460533661085834171833693638143693295511055862451917226660443578426964769719700546772951496395996";
+ |])
(Fp2.mul
(f
- "803369954224906884563405258732068127499444124373729560274472206073891173218445424518997451866034346092384213329883"
- "503859036923320084991265627572913800252671955497792544998415381318131015579573065357816625000610831510288652298964")
+ [|
+ "803369954224906884563405258732068127499444124373729560274472206073891173218445424518997451866034346092384213329883";
+ "503859036923320084991265627572913800252671955497792544998415381318131015579573065357816625000610831510288652298964";
+ |])
(f
- "1859749334750628929451690227707687335137511133983531364679291438693098079713802711484547274759649760701831974491385"
- "319479918179863684323943763511758417353324391274148720422945903908894556320269100349817409794148843141967413849647"))
+ [|
+ "1859749334750628929451690227707687335137511133983531364679291438693098079713802711484547274759649760701831974491385";
+ "319479918179863684323943763511758417353324391274148720422945903908894556320269100349817409794148843141967413849647";
+ |]))
let test_div () =
Alcotest.(check fp2)
"equals"
(f
- "2325686290754200682121145718202670986494244660819308027034132423071687323315606671884154529323382987150473976768330"
- "3239216598855324114836362759253541458361602150483475976924117760584009168234436493512552837300363568825071136536608")
+ [|
+ "2325686290754200682121145718202670986494244660819308027034132423071687323315606671884154529323382987150473976768330";
+ "3239216598855324114836362759253541458361602150483475976924117760584009168234436493512552837300363568825071136536608";
+ |])
(Fp2.div
(f
- "2688262090907385109797388649018262997913625856978785865546511105491589076903808300443238242582958974774562346365422"
- "620412794822327085382870755739471012462590600882879640428242176258125002321042095639472359615918267969245549940520")
+ [|
+ "2688262090907385109797388649018262997913625856978785865546511105491589076903808300443238242582958974774562346365422";
+ "620412794822327085382870755739471012462590600882879640428242176258125002321042095639472359615918267969245549940520";
+ |])
(f
- "117974554526362724345489824744262248121856237810884003402927315860807227932189517320482013911923392063068425858030"
- "2142419467175775193318602789320722018616077971991495171114531437934768498979157636382154413194108550314043215582110"));
+ [|
+ "117974554526362724345489824744262248121856237810884003402927315860807227932189517320482013911923392063068425858030";
+ "2142419467175775193318602789320722018616077971991495171114531437934768498979157636382154413194108550314043215582110";
+ |]));
Alcotest.(check fp2)
"equals" Fp2.zero
(Fp2.div
(f
- "2856688501118144969553652456291973087251256250655576140296976320844142067655542164500037157598802323742365765731618"
- "91558039329695554504260627328728230183446829018778898668517468830173959679663774362827298058047294625048351979470")
+ [|
+ "2856688501118144969553652456291973087251256250655576140296976320844142067655542164500037157598802323742365765731618";
+ "91558039329695554504260627328728230183446829018778898668517468830173959679663774362827298058047294625048351979470";
+ |])
Fp2.zero)
let test_neg () =
Alcotest.(check fp2)
"equals"
(f
- "1652265803669885112428961827998763844356192502384525464729566587325430585803412442963299000002746518202319166455569"
- "3148086661203569599939489297515929514901363299142047909817073525316870145634606314218990062256965667072857382426277")
+ [|
+ "1652265803669885112428961827998763844356192502384525464729566587325430585803412442963299000002746518202319166455569";
+ "3148086661203569599939489297515929514901363299142047909817073525316870145634606314218990062256965667072857382426277";
+ |])
(Fp2.neg
(f
- "2350143751551782280988827997737140312200690317554482420602491548798601064687425421479388629126269145835575106104218"
- "854322894018097793478300528219974641655519520796959975514984610807161504856231550223697566872049996965036890133510"));
+ [|
+ "2350143751551782280988827997737140312200690317554482420602491548798601064687425421479388629126269145835575106104218";
+ "854322894018097793478300528219974641655519520796959975514984610807161504856231550223697566872049996965036890133510";
+ |]));
let a =
f
- "3755242969290908447416997081739091519087375707422634859355840356380094840094873991320874195734523076514815397321243"
- "1849949402789644720627099830974848465908019020270918322229375845176468537369459245375868854333718071380139986243176"
+ [|
+ "3755242969290908447416997081739091519087375707422634859355840356380094840094873991320874195734523076514815397321243";
+ "1849949402789644720627099830974848465908019020270918322229375845176468537369459245375868854333718071380139986243176";
+ |]
in
Alcotest.(check fp2) "equals" Fp2.zero (Fp2.add a (Fp2.neg a))
@@ -103,16 +137,22 @@ let test_inv () =
Alcotest.(check fp2)
"equals"
(f
- "3171328058141487552606964490094256865782521411579367440944677919764391101552560722992448953525776730005333301011061"
- "117788241764364141558165207260211125711335775044260038750142676288749728539425977597521263176199168588971967704898")
+ [|
+ "3171328058141487552606964490094256865782521411579367440944677919764391101552560722992448953525776730005333301011061";
+ "117788241764364141558165207260211125711335775044260038750142676288749728539425977597521263176199168588971967704898";
+ |])
(Fp2.inv
(f
- "3132683201126346359997649079543944507328912651674927308673497534307262164772016129965211842871422381557518724206099"
- "135021294749983899985272892787067246478709822352712818248214312648840971448796031511036377049998504006594698872092"));
+ [|
+ "3132683201126346359997649079543944507328912651674927308673497534307262164772016129965211842871422381557518724206099";
+ "135021294749983899985272892787067246478709822352712818248214312648840971448796031511036377049998504006594698872092";
+ |]));
let a =
f
- "1091358140339556525084474003788455245476134161423421088817134261365285167798938852556734938868755532003979871690585"
- "3020178740353647556832143367266239362247768279656392658297101610073850568065890310189767257933036353291058805033028"
+ [|
+ "1091358140339556525084474003788455245476134161423421088817134261365285167798938852556734938868755532003979871690585";
+ "3020178740353647556832143367266239362247768279656392658297101610073850568065890310189767257933036353291058805033028";
+ |]
in
Alcotest.(check fp2) "equals" Fp2.one (Fp2.mul a (Fp2.inv a));
Alcotest.(check fp2) "equals" Fp2.zero (Fp2.inv Fp2.zero)
diff --git a/test/test_pairing.ml b/test/test_pairing.ml
new file mode 100644
index 0000000..8b9f9d6
--- /dev/null
+++ b/test/test_pairing.ml
@@ -0,0 +1,115 @@
+module Pairing = Plonkers.Pairing
+module G1 = Plonkers.Pairing.G1
+module G2 = Plonkers.Pairing.G2
+module Gt = Plonkers.Pairing.Gt
+
+let gt = Primitives.Testables.gt
+let f1 = Primitives.Literals.g1
+let f2 = Primitives.Literals.g2
+let ft = Primitives.Literals.gt
+
+let test_generator () =
+ Alcotest.(check gt)
+ "equals"
+ Pairing.(e G1.g G2.g)
+ (ft
+ [|
+ "3408834164464458755751340723502736743445402614640994055433339214424916442641449510670327077303074893591740399366532";
+ "1017299873256115394687936133146817339783508925356207904663165117501336940438300180831508525168135575931758510829235";
+ "1919447955347661378578718469488414822573562393353397544098339472673901193098010131520945815709482515519580400649694";
+ "233557331756520805040932826416017142246700002714928636467514104620558679338483625829873520553081791155104026612174";
+ "2882199334237819327910933128503231887000342950792587449681715803095618652567681747054312179958427092970985872417068";
+ "579878855790610229145575079003483905368886712027403088810647643659132674704592975818766405092658613973478871626949";
+ "3268798540077874559188095304926415053902298079662269128631117894259354335713488241073281881110999874366368799440511";
+ "2688711983546324406847903726099677850388169649284572370749691792743294691894680263880362424577638309433508620982332";
+ "3520140447471844017044610248175793726488927385800919015247604269617056365166670232096113218155158979455637700602719";
+ "1555267885602801620621747613743921378408444002839854792606782732724136830563310004098024452104661167182680744848589";
+ "2626389147790168154036854297373352480470342009417426750876875476996308393122833154115295241935326582225976246741447";
+ "873321072950766150592434764742436722571574260472569072177205897167854308426485977134306337249021436737462538398830";
+ |])
+
+let test_pairing () =
+ Alcotest.(check gt)
+ "equals"
+ (ft
+ [|
+ "448697226789963268348912232951073713452968894642929214443994147359412138639526655164503406978236522025734912852606";
+ "151261630108668103390829365027365404889205408289235816621708275624780812413761415129004835746255625267607732639563";
+ "2909423043708809630024534763367123821438139353180175913125076930835302419897651130667995073651726848611333745205986";
+ "952434542917010958697197601576391780800301526127664682598671275809818228531516224262590129674712650458795890584553";
+ "1478486475752483299362722402760792915820803227192648258365429143818886181422874016577411765850893129689832973264031";
+ "652834415768413017856200607794773610957395062979681182931987046704660733141291027961343651372030380321651719802520";
+ "951656253138365825024367899445523415181713017704780705176410361641958854486267870078190603032432549582347900417624";
+ "1991042670420833845569811948628174796662344145916123310837646809687525541032370298949411402142207368319354069329317";
+ "2920440541157943770850967007055029075931555684879417457120436377239540586798148490244301682350449674796660182631922";
+ "3554199917981379540114579517242213458150684556713432050906212290132174074734340424484104596198947386114933622334567";
+ "1091458823916905664137346388296576506864216891159041434853650685402092824487985812791698734521558868411023155785769";
+ "43181594668188258041148789943396863898539176535733231639633582884332884962913532441125648697214326572900496337037";
+ |])
+ (Pairing.e
+ (f1
+ ( "1759244594739438101652572364306631993712897577542654736932660460743445183171945408603399266474637228371219384150089",
+ "2746850152127019659862408918732227356169104535991470589122155020934454571292242598343702169898773975726309716165198"
+ ))
+ (f2
+ ( [|
+ "1256740661954421835404627287451128275298916640367011495362432993289541383031490867768256365295187693751267667845404";
+ "3717522504942038420636575612519050548073203872805747528897870222147344374794751097864928254417486766328132878640824";
+ |],
+ [|
+ "2512342532199657251630152291613780551312453521116783301133995957210838938697636876773382152437204041044762830468417";
+ "77870636695957247485070729371505785036022507830356763789646790529980989972767478012625350608049848760401081873614";
+ |] )))
+
+let test_bilinearity () =
+ let a =
+ f1
+ ( "3155009934535908241854382503496913376741892294245863405401597462641760243133882235624423397847127767716934062555793",
+ "2234019121465620231805578079882835966262487276444547332538208418002132978001247983358670643174241518454728236294862"
+ )
+ in
+ let b =
+ f2
+ ( [|
+ "2647899611276867777535497861408512411465691530078703925817898320530901433230690986081010166625858940444369794593258";
+ "2888256862829316108006975470566918581509317636890719189755447540552883010802407709863131290915043648752253159925232";
+ |],
+ [|
+ "2192519177806038492881176172205451311854538798364777947095907984617867826862323453026127520221274922616271304335259";
+ "3004620411053362146054721503134832661166005188461559731409518090929136380431931464671889917597096234887634360879239";
+ |] )
+ in
+ let t = Pairing.e a b in
+ let tt = Gt.dot t t in
+ Alcotest.(check (pair gt gt))
+ "equals" (tt, tt)
+ (Pairing.e G1.(add a a) b, Pairing.e a G2.(add b b))
+
+let test_inverse () =
+ let a =
+ f1
+ ( "91452683776864857297317878636149143411849300822645600833640900844653175011086096281183060418629991226462334719230",
+ "2771533846423619448760061452592233431921571821664938471039058787579168163258312047422278741446979265860731259685588"
+ )
+ in
+ let b =
+ f1
+ ( "1370766558783140535152500693223113089394078759152774320389619861811343135317811753270627096528148539713374385472074",
+ "1158300532618179468953717893171547786621985273328026665132493211269013369890783422334256435364557531790375173858380"
+ )
+ in
+ let ta = Pairing.e a G2.g in
+ let tb = Pairing.e b G2.g in
+ Alcotest.(check gt)
+ "equals"
+ Gt.(dot ta (inverse tb))
+ (Pairing.e (G1.sub a b) G2.g)
+
+let tests =
+ Alcotest.
+ [
+ test_case "Generator" `Quick test_generator;
+ test_case "Pairing" `Quick test_pairing;
+ test_case "Bilinearity" `Quick test_bilinearity;
+ test_case "Inverse" `Quick test_inverse;
+ ]
diff --git a/test/test_plonkers.ml b/test/test_plonkers.ml
index 90e94db..4e20fba 100644
--- a/test/test_plonkers.ml
+++ b/test/test_plonkers.ml
@@ -8,4 +8,5 @@ let () =
("E2", Test_e2.tests);
("E12", Test_e12.tests);
("Curves", Test_curves.tests);
+ ("Pairing", Test_pairing.tests);
]