aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-06-10 08:48:31 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-06-10 08:48:31 +0800
commit55e7cdec8325e993800ffb448b74a90690f9d324 (patch)
tree2348f692b52debebc8a55ebb5579f87c7bf45b03
parent0c3c963d64f42c9dc30b71d6b7d5f13c56611ec0 (diff)
downloadtangerine-mcl-55e7cdec8325e993800ffb448b74a90690f9d324.tar.gz
tangerine-mcl-55e7cdec8325e993800ffb448b74a90690f9d324.tar.zst
tangerine-mcl-55e7cdec8325e993800ffb448b74a90690f9d324.zip
add lagrange test
-rw-r--r--test/bn384_test.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/bn384_test.cpp b/test/bn384_test.cpp
index 11f1690..7b536c2 100644
--- a/test/bn384_test.cpp
+++ b/test/bn384_test.cpp
@@ -5,6 +5,7 @@
#include <cybozu/xorshift.hpp>
#include <mcl/bn384.hpp>
#include <mcl/bn.hpp>
+#include <mcl/lagrange.hpp>
using namespace mcl::bn384;
@@ -12,6 +13,23 @@ mcl::fp::Mode g_mode;
#include "bench.hpp"
+void testLagrange()
+{
+ puts("testLagrange");
+ const int k = 7;
+ Fr c[k], x[k], y[k];
+ for (size_t i = 0; i < k; i++) {
+ c[i].setByCSPRNG();
+ x[i].setByCSPRNG();
+ }
+ for (size_t i = 0; i < k; i++) {
+ mcl::evaluatePolynomial(y[i], c, k, x[i]);
+ }
+ Fr s;
+ mcl::LagrangeInterpolation(s, x, y, k);
+ CYBOZU_TEST_EQUAL(s, c[0]);
+}
+
void testCurve(const mcl::CurveParam& cp)
{
initPairing(cp, g_mode);
@@ -34,6 +52,7 @@ void testCurve(const mcl::CurveParam& cp)
GT::pow(e1, e1, a * b);
CYBOZU_TEST_EQUAL(e1, e2);
testBench(P, Q);
+ testLagrange();
}
CYBOZU_TEST_AUTO(pairing)