diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2016-08-10 18:32:28 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2016-08-10 18:32:28 +0800 |
commit | bc8beb99461abb26cd7f07b5209b6e2ab6c12823 (patch) | |
tree | 8718eb036fcbc3ba74b4dd1c02aaf7bed74ad46e /src/bls.cpp | |
parent | 4e76cc6a94dcc8b5de913eed5a9a944ce74da647 (diff) | |
download | dexon-bls-bc8beb99461abb26cd7f07b5209b6e2ab6c12823.tar dexon-bls-bc8beb99461abb26cd7f07b5209b6e2ab6c12823.tar.gz dexon-bls-bc8beb99461abb26cd7f07b5209b6e2ab6c12823.tar.bz2 dexon-bls-bc8beb99461abb26cd7f07b5209b6e2ab6c12823.tar.lz dexon-bls-bc8beb99461abb26cd7f07b5209b6e2ab6c12823.tar.xz dexon-bls-bc8beb99461abb26cd7f07b5209b6e2ab6c12823.tar.zst dexon-bls-bc8beb99461abb26cd7f07b5209b6e2ab6c12823.zip |
add bls_smpl
Diffstat (limited to 'src/bls.cpp')
-rw-r--r-- | src/bls.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/bls.cpp b/src/bls.cpp index c85ce61..d017930 100644 --- a/src/bls.cpp +++ b/src/bls.cpp @@ -65,7 +65,7 @@ struct Polynomial { FrVec c; // f[x] = sum_{i=0}^{k-1} c[i] x^i void init(const Fr& s, int k) { - if (k < 2) throw cybozu::Exception("Polynomial:init:bad k") << k; + if (k < 2) throw cybozu::Exception("bls:Polynomial:init:bad k") << k; c.resize(k); c[0] = s; for (size_t i = 1; i < c.size(); i++) { @@ -75,8 +75,8 @@ struct Polynomial { // y = f(id) void eval(Fr& y, int id) const { - if (id == 0) throw cybozu::Exception("Polynomial:calc_f:i is zero"); - if (c.size() < 2) throw cybozu::Exception("Polynomial:calc_f:bad size") << c.size(); + if (id == 0) throw cybozu::Exception("bls:Polynomial:eval:id is zero"); + if (c.size() < 2) throw cybozu::Exception("bls:Polynomial:eval:bad size") << c.size(); const Fr x(id); y = c[c.size() - 1]; for (int i = (int)c.size() - 2; i >= 0; i--) { @@ -93,7 +93,7 @@ struct Polynomial { static void calcDelta(FrVec& delta, const IntVec& S) { const size_t k = S.size(); - if (k < 2) throw cybozu::Exception("BLS:calcDelta:bad size") << k; + if (k < 2) throw cybozu::Exception("bls:calcDelta:bad size") << k; delta.resize(k); Fr a = S[0]; for (size_t i = 1; i < k; i++) { @@ -364,6 +364,7 @@ void PrivateKey::sign(Sign& sign, const std::string& m) const void PrivateKey::share(std::vector<PrivateKey>& prvVec, int n, int k) { if (id_ != 0) throw cybozu::Exception("bls:PrivateKey:share:already shared") << id_; + if (n <= 0 || k <= 0 || k > n) throw cybozu::Exception("bls:PrivateKey:share:bad n, k") << n << k; Polynomial poly; poly.init(self_->s, k); prvVec.resize(n); |