aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Rodrigues Lordello <[email protected]>2024-07-25 21:07:06 +0200
committerNicholas Rodrigues Lordello <[email protected]>2024-07-25 21:07:06 +0200
commitfd50c91473eda09db01c63421fbb7084ed896494 (patch)
tree4b5ac77e77c9bcfc0e15f526df24c69bbe3a2826
parentba751d469d6ae3a1e3f728726a1972d16d9bf1e4 (diff)
Cleaned Up Tests
-rw-r--r--docs/journal/pages/finite-fields.md2
-rw-r--r--lib/field.ml2
-rw-r--r--test/test_fp.ml17
-rw-r--r--test/test_fp12.ml1
-rw-r--r--test/test_fp2.ml1
5 files changed, 20 insertions, 3 deletions
diff --git a/docs/journal/pages/finite-fields.md b/docs/journal/pages/finite-fields.md
index 43518f7..4e71672 100644
--- a/docs/journal/pages/finite-fields.md
+++ b/docs/journal/pages/finite-fields.md
@@ -18,7 +18,7 @@ The BLS12-381 curve as it has some nicer properties over BN254, and may show up
# Resources
-- [BN256 For The Rest Of Us](https://hackmd.io/@jpw/bn254)
+- [BN254 For The Rest Of Us](https://hackmd.io/@jpw/bn254)
- [BLS12-381 For The Rest Of Us](https://hackmd.io/@benjaminion/bls12-381)
- [`ethereum/py_ecc`](https://github.com/ethereum/py_ecc)
diff --git a/lib/field.ml b/lib/field.ml
index 80cc753..df59673 100644
--- a/lib/field.ml
+++ b/lib/field.ml
@@ -3,7 +3,7 @@
(** Module signature for a finite field. *)
module type S = sig
type t
- (** A type representing an element in the finite field *)
+ (** A type representing an element in the finite field. *)
val zero : t
(** The zero value, i.e. the additive identity. *)
diff --git a/test/test_fp.ml b/test/test_fp.ml
index ca8f9e4..feefb5d 100644
--- a/test/test_fp.ml
+++ b/test/test_fp.ml
@@ -3,6 +3,20 @@ module Fp = Plonkers.Fields.Fp
let fp = Testable.make Fp.to_string Fp.equal
let f = Fp.of_string
+let test_strconv () =
+ let a =
+ f
+ "15962132676900570984155932908734860654156982678903386073610512073739915079794"
+ in
+ Alcotest.(check string)
+ "equals"
+ "15962132676900570984155932908734860654156982678903386073610512073739915079794"
+ (Fp.to_string a);
+ Alcotest.(check fp)
+ "equals" a
+ (Fp.of_string
+ "15962132676900570984155932908734860654156982678903386073610512073739915079794")
+
let test_add () =
Alcotest.(check fp)
"equals"
@@ -47,7 +61,7 @@ let test_sub () =
"equals"
(f
"1550460075629904631277637708383660261580971272511193857451434052003108082807")
- (Fp.add
+ (Fp.sub
(f
"1550460075629904631277637708383660261580971272511193857451434052003108082807")
Fp.zero)
@@ -133,6 +147,7 @@ let test_inv () =
let tests =
Alcotest.
[
+ test_case "String Conversion" `Quick test_strconv;
test_case "Addition" `Quick test_add;
test_case "Subtraction" `Quick test_sub;
test_case "Multiplication" `Quick test_mul;
diff --git a/test/test_fp12.ml b/test/test_fp12.ml
index 2ded117..e8ee6e9 100644
--- a/test/test_fp12.ml
+++ b/test/test_fp12.ml
@@ -331,6 +331,7 @@ let test_inv () =
let tests =
Alcotest.
[
+ test_case "String Conversion" `Quick test_strconv;
test_case "Addition" `Quick test_add;
test_case "Subtraction" `Quick test_sub;
test_case "Multiplication" `Quick test_mul;
diff --git a/test/test_fp2.ml b/test/test_fp2.ml
index 50a3dd8..828583f 100644
--- a/test/test_fp2.ml
+++ b/test/test_fp2.ml
@@ -116,6 +116,7 @@ let test_inv () =
let tests =
Alcotest.
[
+ test_case "String Conversion" `Quick test_strconv;
test_case "Addition" `Quick test_add;
test_case "Subtraction" `Quick test_sub;
test_case "Multiplication" `Quick test_mul;