diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bls.cpp | 38 | ||||
-rw-r--r-- | src/bls_if.cpp | 20 |
2 files changed, 35 insertions, 23 deletions
diff --git a/src/bls.cpp b/src/bls.cpp index 98f0888..8358c0f 100644 --- a/src/bls.cpp +++ b/src/bls.cpp @@ -90,6 +90,18 @@ struct WrapPointer { size_t size() const { return k; } }; +template<class T, class G> +struct WrapArray { + const T *v; + size_t k; + WrapArray(const T *v, size_t k) : v(v), k(k) {} + const G& operator[](size_t i) const + { + return v[i].getInner().get(); + } + size_t size() const { return k; } +}; + struct Polynomial { FrVec c; // f[x] = sum_{i=0}^{k-1} c[i] x^i void init(const Fr& s, int k) @@ -268,10 +280,10 @@ void Sign::recover(const SignVec& signVec, const IdVec& idVec) LagrangeInterpolation(getInner().sHm, signW, idW); } -void Sign::recover(const Sign* const *signVec, const Id *const *idVec, size_t n) +void Sign::recover(const Sign* signVec, const Id *idVec, size_t n) { - WrapPointer<Sign, G1> signW(signVec, n); - WrapPointer<Id, Fr> idW(idVec, n); + WrapArray<Sign, G1> signW(signVec, n); + WrapArray<Id, Fr> idW(idVec, n); LagrangeInterpolation(getInner().sHm, signW, idW); } @@ -301,9 +313,9 @@ void PublicKey::set(const PublicKeyVec& mpk, const Id& id) evalPoly(getInner().sQ, id.getInner().v, w); } -void PublicKey::set(const PublicKey *const *mpk, size_t k, const Id& id) +void PublicKey::set(const PublicKey *mpk, size_t k, const Id& id) { - WrapPointer<PublicKey, G2> w(mpk, k); + WrapArray<PublicKey, G2> w(mpk, k); evalPoly(getInner().sQ, id.getInner().v, w); } @@ -313,10 +325,10 @@ void PublicKey::recover(const PublicKeyVec& pubVec, const IdVec& idVec) Wrap<Id, Fr> idW(idVec); LagrangeInterpolation(getInner().sQ, pubW, idW); } -void PublicKey::recover(const PublicKey *const *pubVec, const Id *const *idVec, size_t n) +void PublicKey::recover(const PublicKey *pubVec, const Id *idVec, size_t n) { - WrapPointer<PublicKey, G2> pubW(pubVec, n); - WrapPointer<Id, Fr> idW(idVec, n); + WrapArray<PublicKey, G2> pubW(pubVec, n); + WrapArray<Id, Fr> idW(idVec, n); LagrangeInterpolation(getInner().sQ, pubW, idW); } @@ -386,9 +398,9 @@ void SecretKey::set(const SecretKeyVec& msk, const Id& id) Wrap<SecretKey, Fr> w(msk); evalPoly(getInner().s, id.getInner().v, w); } -void SecretKey::set(const SecretKey *const *msk, size_t k, const Id& id) +void SecretKey::set(const SecretKey *msk, size_t k, const Id& id) { - WrapPointer<SecretKey, Fr> w(msk, k); + WrapArray<SecretKey, Fr> w(msk, k); evalPoly(getInner().s, id.getInner().v, w); } @@ -398,10 +410,10 @@ void SecretKey::recover(const SecretKeyVec& secVec, const IdVec& idVec) Wrap<Id, Fr> idW(idVec); LagrangeInterpolation(getInner().s, secW, idW); } -void SecretKey::recover(const SecretKey *const *secVec, const Id *const *idVec, size_t n) +void SecretKey::recover(const SecretKey *secVec, const Id *idVec, size_t n) { - WrapPointer<SecretKey, Fr> secW(secVec, n); - WrapPointer<Id, Fr> idW(idVec, n); + WrapArray<SecretKey, Fr> secW(secVec, n); + WrapArray<Id, Fr> idW(idVec, n); LagrangeInterpolation(getInner().s, secW, idW); } diff --git a/src/bls_if.cpp b/src/bls_if.cpp index c64e868..1611e74 100644 --- a/src/bls_if.cpp +++ b/src/bls_if.cpp @@ -131,14 +131,14 @@ void blsSecretKeySign(const blsSecretKey *sec, blsSign *sign, const char *m, siz ((const bls::SecretKey*)sec)->sign(*(bls::Sign*)sign, std::string(m, size)); } -void blsSecretKeySet(blsSecretKey *sec, const blsSecretKey* const *msk, size_t k, const blsId *id) +void blsSecretKeySet(blsSecretKey *sec, const blsSecretKey* msk, size_t k, const blsId *id) { - ((bls::SecretKey*)sec)->set((const bls::SecretKey *const *)msk, k, *(const bls::Id*)id); + ((bls::SecretKey*)sec)->set((const bls::SecretKey *)msk, k, *(const bls::Id*)id); } -void blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey* const *secVec, const blsId *const *idVec, size_t n) +void blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, size_t n) { - ((bls::SecretKey*)sec)->recover((const bls::SecretKey *const *)secVec, (const bls::Id *const *)idVec, n); + ((bls::SecretKey*)sec)->recover((const bls::SecretKey *)secVec, (const bls::Id *)idVec, n); } void blsSecretKeyGetPop(const blsSecretKey *sec, blsSign *sign) @@ -176,13 +176,13 @@ void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs) { ((bls::PublicKey*)pub)->add(*(const bls::PublicKey*)rhs); } -void blsPublicKeySet(blsPublicKey *pub, const blsPublicKey *const *mpk, size_t k, const blsId *id) +void blsPublicKeySet(blsPublicKey *pub, const blsPublicKey *mpk, size_t k, const blsId *id) { - ((bls::PublicKey*)pub)->set((const bls::PublicKey* const *)mpk, k, *(const bls::Id*)id); + ((bls::PublicKey*)pub)->set((const bls::PublicKey*)mpk, k, *(const bls::Id*)id); } -void blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *const *pubVec, const blsId *const *idVec, size_t n) +void blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, size_t n) { - ((bls::PublicKey*)pub)->recover((const bls::PublicKey* const *)pubVec, (const bls::Id* const *)idVec, n); + ((bls::PublicKey*)pub)->recover((const bls::PublicKey*)pubVec, (const bls::Id*)idVec, n); } blsSign *blsSignCreate() @@ -215,9 +215,9 @@ void blsSignAdd(blsSign *sign, const blsSign *rhs) { ((bls::Sign*)sign)->add(*(const bls::Sign*)rhs); } -void blsSignRecover(blsSign *sign, const blsSign *const *signVec, const blsId *const *idVec, size_t n) +void blsSignRecover(blsSign *sign, const blsSign *signVec, const blsId *idVec, size_t n) { - ((bls::Sign*)sign)->recover((const bls::Sign* const *)signVec, (const bls::Id* const *)idVec, n); + ((bls::Sign*)sign)->recover((const bls::Sign*)signVec, (const bls::Id*)idVec, n); } int blsSignVerify(const blsSign *sign, const blsPublicKey *pub, const char *m, size_t size) |