aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bls.cpp21
-rw-r--r--src/bls_c.cpp14
2 files changed, 16 insertions, 19 deletions
diff --git a/src/bls.cpp b/src/bls.cpp
index 71bcb3b..5bfb744 100644
--- a/src/bls.cpp
+++ b/src/bls.cpp
@@ -31,7 +31,7 @@ static void HashAndMapToG1(G1& P, const std::string& m)
{
Fp t;
t.setHashOf(m);
- BN::mapToG1(P, t);
+ mapToG1(P, t);
}
template<class T, class G, class Vec>
@@ -172,10 +172,7 @@ void init(int curve, int maxUnitSize)
default:
throw cybozu::Exception("bls:init:bad curve") << curve;
}
- BN::init(cp);
- G1::setCompressedExpression();
- G2::setCompressedExpression();
- Fr::init(BN::param.r);
+ initPairing(cp);
assert(sizeof(Id) == sizeof(impl::Id));
assert(sizeof(SecretKey) == sizeof(impl::SecretKey));
assert(sizeof(PublicKey) == sizeof(impl::PublicKey));
@@ -187,11 +184,11 @@ void init(int curve, int maxUnitSize)
Fp2("13891744915211034074451795021214165905772212241412891944830863846330766296736", "7937318970632701341203597196594272556916396164729705624521405069090520231616")
);
} else {
- BN::mapToG2(Q, 1);
+ mapToG2(Q, 1);
}
static std::vector<Fp6> Qcoeff;
- BN::precomputeG2(Qcoeff, Q);
+ precomputeG2(Qcoeff, Q);
g_pQ = &Q;
g_pQcoeff = &Qcoeff;
}
@@ -289,14 +286,14 @@ bool Signature::verify(const PublicKey& pub, const std::string& m) const
*/
Fp12 e;
std::vector<Fp6> Q2coeff;
- BN::precomputeG2(Q2coeff, pub.getInner().sQ);
- BN::precomputedMillerLoop2(e, getInner().sHm, getQcoeff(), -Hm, Q2coeff);
- BN::finalExp(e, e);
+ precomputeG2(Q2coeff, pub.getInner().sQ);
+ precomputedMillerLoop2(e, getInner().sHm, getQcoeff(), -Hm, Q2coeff);
+ finalExp(e, e);
return e.isOne();
#else
Fp12 e1, e2;
- BN::pairing(e1, getInner().sHm, getQ()); // e(s Hm, Q)
- BN::pairing(e2, Hm, pub.getInner().sQ); // e(Hm, sQ)
+ pairing(e1, getInner().sHm, getQ()); // e(s Hm, Q)
+ pairing(e2, Hm, pub.getInner().sQ); // e(Hm, sQ)
return e1 == e2;
#endif
}
diff --git a/src/bls_c.cpp b/src/bls_c.cpp
index 568a49d..2135a8a 100644
--- a/src/bls_c.cpp
+++ b/src/bls_c.cpp
@@ -29,8 +29,8 @@ int blsInitNotThreadSafe(int curve, int maxUnitSize)
try
{
if (mclBn_init(curve, maxUnitSize) != 0) return -1;
- BN::mapToG2(g_Q, 1);
- BN::precomputeG2(g_Qcoeff, getQ());
+ mapToG2(g_Q, 1);
+ precomputeG2(g_Qcoeff, getQ());
return 0;
} catch (std::exception&) {
return -1;
@@ -77,10 +77,10 @@ static inline const mclBnG2 *cast(const G2* x) { return (const mclBnG2*)x; }
bool isEqualTwoPairings(const G1& P1, const Fp6* Q1coeff, const G1& P2, const G2& Q2)
{
std::vector<Fp6> Q2coeff;
- BN::precomputeG2(Q2coeff, Q2);
+ precomputeG2(Q2coeff, Q2);
Fp12 e;
- BN::precomputedMillerLoop2(e, P1, Q1coeff, -P2, Q2coeff.data());
- BN::finalExp(e, e);
+ precomputedMillerLoop2(e, P1, Q1coeff, -P2, Q2coeff.data());
+ finalExp(e, e);
return e.isOne();
}
@@ -131,7 +131,7 @@ void blsGetPublicKey(blsPublicKey *pub, const blsSecretKey *sec)
void blsSign(blsSignature *sig, const blsSecretKey *sec, const void *m, mclSize size)
{
G1 Hm;
- BN::hashAndMapToG1(Hm, m, size);
+ hashAndMapToG1(Hm, m, size);
mclBnG1_mulCT(&sig->v, cast(&Hm), &sec->v);
}
int blsSecretKeyShare(blsSecretKey *sec, const blsSecretKey* msk, mclSize k, const blsId *id)
@@ -169,7 +169,7 @@ int blsSignatureRecover(blsSignature *sig, const blsSignature *sigVec, const bls
int blsVerify(const blsSignature *sig, const blsPublicKey *pub, const void *m, mclSize size)
{
G1 Hm;
- BN::hashAndMapToG1(Hm, m, size);
+ hashAndMapToG1(Hm, m, size);
/*
e(sHm, Q) = e(Hm, sQ)
e(sig, Q) = e(Hm, pub)