From c715624c6b71327fbeb336654666899300a484cb Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 18 Oct 2010 23:30:32 +0000 Subject: BigInt::get_substring really shouldn't return size_t. Revert to u32bit. Maybe should be word? But that would restrict window sizes more than might be desirable (we couldn't use more than 8 bit window on the assumption that the lib might be using byte limbs). Messy. --- src/math/numbertheory/point_gfp.cpp | 6 +++--- src/math/numbertheory/powm_fw.cpp | 3 +-- src/math/numbertheory/powm_mnt.cpp | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/math/numbertheory') diff --git a/src/math/numbertheory/point_gfp.cpp b/src/math/numbertheory/point_gfp.cpp index 5da1959bc..8cb40270c 100644 --- a/src/math/numbertheory/point_gfp.cpp +++ b/src/math/numbertheory/point_gfp.cpp @@ -324,12 +324,12 @@ PointGFp operator*(const BigInt& scalar, const PointGFp& point) while(bits_left >= window_size) { - size_t nibble = scalar.get_substring(bits_left - window_size, - window_size); - for(size_t i = 0; i != window_size; ++i) H.mult2(ws); + const u32bit nibble = scalar.get_substring(bits_left - window_size, + window_size); + if(nibble) H.add(Ps[nibble-1], ws); diff --git a/src/math/numbertheory/powm_fw.cpp b/src/math/numbertheory/powm_fw.cpp index afc53f233..3348e55cd 100644 --- a/src/math/numbertheory/powm_fw.cpp +++ b/src/math/numbertheory/powm_fw.cpp @@ -45,8 +45,7 @@ BigInt Fixed_Window_Exponentiator::execute() const for(size_t k = 0; k != window_bits; ++k) x = reducer.square(x); - size_t nibble = exp.get_substring(window_bits*(j-1), window_bits); - if(nibble) + if(u32bit nibble = exp.get_substring(window_bits*(j-1), window_bits)) x = reducer.multiply(x, g[nibble-1]); } return x; diff --git a/src/math/numbertheory/powm_mnt.cpp b/src/math/numbertheory/powm_mnt.cpp index 038ce14da..4f626ac9d 100644 --- a/src/math/numbertheory/powm_mnt.cpp +++ b/src/math/numbertheory/powm_mnt.cpp @@ -90,8 +90,7 @@ BigInt Montgomery_Exponentiator::execute() const x.get_reg().set(&z[0], mod_words + 1); } - size_t nibble = exp.get_substring(window_bits*(i-1), window_bits); - if(nibble) + if(u32bit nibble = exp.get_substring(window_bits*(i-1), window_bits)) { const BigInt& y = g[nibble-1]; -- cgit v1.2.3