diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-27 08:37:10 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2018-05-27 08:37:10 +0800 |
commit | 5c3db4036b1012a650a0f9d9f438f1b587c93e4b (patch) | |
tree | 0ab9c9e3c45ac9d3d11f37c1b90028a87e90a988 | |
parent | e879a8389e964c0c00ad6598f71d9a1fb77a0a97 (diff) | |
download | dexon-mcl-5c3db4036b1012a650a0f9d9f438f1b587c93e4b.tar.gz dexon-mcl-5c3db4036b1012a650a0f9d9f438f1b587c93e4b.tar.zst dexon-mcl-5c3db4036b1012a650a0f9d9f438f1b587c93e4b.zip |
rename vector.hpp to array.hpp
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | include/mcl/bn.hpp | 8 | ||||
-rw-r--r-- | include/mcl/op.hpp | 4 | ||||
-rw-r--r-- | include/mcl/vector.hpp | 77 | ||||
-rw-r--r-- | include/mcl/vint.hpp | 2 | ||||
-rw-r--r-- | test/array_test.cpp (renamed from test/vector_test.cpp) | 4 |
6 files changed, 10 insertions, 87 deletions
@@ -5,7 +5,7 @@ EXE_DIR=bin SRC_SRC=fp.cpp bn_c256.cpp bn_c384.cpp bn_c512.cpp she_c256.cpp TEST_SRC=fp_test.cpp ec_test.cpp fp_util_test.cpp window_method_test.cpp elgamal_test.cpp fp_tower_test.cpp gmp_test.cpp bn_test.cpp bn384_test.cpp glv_test.cpp paillier_test.cpp she_test.cpp vint_test.cpp bn512_test.cpp ecdsa_test.cpp conversion_test.cpp TEST_SRC+=bn_c256_test.cpp bn_c384_test.cpp bn_c512_test.cpp she_c256_test.cpp she_c384_test.cpp -TEST_SRC+=aggregate_sig_test.cpp vector_test.cpp +TEST_SRC+=aggregate_sig_test.cpp array_test.cpp TEST_SRC+=bls12_test.cpp TEST_SRC+=ecdsa_c_test.cpp ifeq ($(CPU),x86-64) diff --git a/include/mcl/bn.hpp b/include/mcl/bn.hpp index cb357a6..318ec83 100644 --- a/include/mcl/bn.hpp +++ b/include/mcl/bn.hpp @@ -107,7 +107,7 @@ void Frobenius3(G2& D, const G2& S); namespace local { -typedef mcl::Vector<int8_t> SignVec; +typedef mcl::Array<int8_t> SignVec; inline size_t getPrecomputeQcoeffSize(const SignVec& sv) { @@ -1713,7 +1713,7 @@ inline void precomputeG2(std::vector<Fp6>& Qcoeff, const G2& Q) Qcoeff.resize(BN::param.precomputedQcoeffSize); precomputeG2(Qcoeff.data(), Q); } -inline bool precomputeG2(mcl::Vector<Fp6>& Qcoeff, const G2& Q) +inline bool precomputeG2(mcl::Array<Fp6>& Qcoeff, const G2& Q) { bool b = Qcoeff.resize(BN::param.precomputedQcoeffSize); if (!b) return false; @@ -1760,7 +1760,7 @@ inline void precomputedMillerLoop(Fp12& f, const G1& P, const std::vector<Fp6>& { precomputedMillerLoop(f, P, Qcoeff.data()); } -inline void precomputedMillerLoop(Fp12& f, const G1& P, const mcl::Vector<Fp6>& Qcoeff) +inline void precomputedMillerLoop(Fp12& f, const G1& P, const mcl::Array<Fp6>& Qcoeff) { precomputedMillerLoop(f, P, Qcoeff.data()); } @@ -1822,7 +1822,7 @@ inline void precomputedMillerLoop2(Fp12& f, const G1& P1, const std::vector<Fp6> { precomputedMillerLoop2(f, P1, Q1coeff.data(), P2, Q2coeff.data()); } -inline void precomputedMillerLoop2(Fp12& f, const G1& P1, const mcl::Vector<Fp6>& Q1coeff, const G1& P2, const mcl::Vector<Fp6>& Q2coeff) +inline void precomputedMillerLoop2(Fp12& f, const G1& P1, const mcl::Array<Fp6>& Q1coeff, const G1& P2, const mcl::Array<Fp6>& Q2coeff) { precomputedMillerLoop2(f, P1, Q1coeff.data(), P2, Q2coeff.data()); } diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index b947284..8110808 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -8,7 +8,7 @@ */ #include <mcl/gmp_util.hpp> #include <memory.h> -#include <mcl/vector.hpp> +#include <mcl/array.hpp> #ifndef MCL_MAX_BIT_SIZE #define MCL_MAX_BIT_SIZE 521 @@ -180,7 +180,7 @@ struct Op { Unit one[maxUnitSize]; Unit R2[maxUnitSize]; Unit R3[maxUnitSize]; - mcl::Vector<Unit> invTbl; + mcl::Array<Unit> invTbl; size_t N; size_t bitSize; bool (*fp_isZero)(const Unit*); diff --git a/include/mcl/vector.hpp b/include/mcl/vector.hpp deleted file mode 100644 index eb0fb07..0000000 --- a/include/mcl/vector.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once -/** - @file - @brief tiny vector class - @author MITSUNARI Shigeo(@herumi) - @license modified new BSD license - http://opensource.org/licenses/BSD-3-Clause -*/ -#include <malloc.h> -#include <stddef.h> -#include <algorithm> - -namespace mcl { -template<class T> -class Vector { - T *p_; - size_t n_; - Vector(const Vector&); - void operator=(const Vector&); -public: - Vector() : p_(0), n_(0) {} - ~Vector() - { - free(p_); - } - bool resize(size_t n) - { - if (n <= n_) { - n_ = n; - if (n == 0) { - free(p_); - p_ = 0; - } - return true; - } - T *q = (T*)malloc(sizeof(T) * n); - if (q == 0) return false; - for (size_t i = 0; i < n_; i++) { - q[i] = p_[i]; - } - free(p_); - p_ = q; - n_ = n; - return true; - } - bool copy(const Vector<T>& rhs) - { - if (this == &rhs) return true; - if (n_ < rhs.n_) { - clear(); - if (!resize(rhs.n_)) return false; - } - for (size_t i = 0; i < rhs.n_; i++) { - p_[i] = rhs.p_[i]; - } - n_ = rhs.n_; - return true; - } - void clear() - { - free(p_); - p_ = 0; - n_ = 0; - } - size_t size() const { return n_; } - void swap(Vector<T>& rhs) - { - std::swap(p_, rhs.p_); - std::swap(n_, rhs.n_); - } - T& operator[](size_t n) { return p_[n]; } - const T& operator[](size_t n) const { return p_[n]; } - T* data() { return p_; } - const T* data() const { return p_; } -}; -} // mcl - diff --git a/include/mcl/vint.hpp b/include/mcl/vint.hpp index 1ffeba2..d327268 100644 --- a/include/mcl/vint.hpp +++ b/include/mcl/vint.hpp @@ -7,7 +7,7 @@ #include <assert.h> #include <cmath> #include <iostream> -#include <mcl/vector.hpp> +#include <mcl/array.hpp> #include <mcl/util.hpp> #include <mcl/randgen.hpp> #include <mcl/conversion.hpp> diff --git a/test/vector_test.cpp b/test/array_test.cpp index d593e4c..1a3a3e4 100644 --- a/test/vector_test.cpp +++ b/test/array_test.cpp @@ -1,9 +1,9 @@ -#include <mcl/vector.hpp> +#include <mcl/array.hpp> #include <cybozu/test.hpp> CYBOZU_TEST_AUTO(resize) { - mcl::Vector<int> a, b; + mcl::Array<int> a, b; CYBOZU_TEST_EQUAL(a.size(), 0); CYBOZU_TEST_EQUAL(b.size(), 0); |