Sorry, I was overlooked it. Thank you for your answering. Masaya
2014-05-30 15:32 GMT+09:00 Nelson Bolyard <nel...@bolyard.me>: > > On 2014-05-19 08:16, ???? wrote: > >> Hi All, >> >> Recently, I read NSS code and have a question about this line >> <http://dxr.mozilla.org/mozilla-central/source/ >> security/nss/lib/freebl/mpi/mpprime.c#380> >> >> ) >> In this line, offset is "offset = prime - (rem / 2)". But I think offset >> is >> "offset = prime - rem" because "trial + prime - rem" is multiple of prime >> (I give detail later). >> >> Why offset is "offset = prime - (rem / 2)" ? >> >> Thanks for any help. >> > > Please re-read the comment at the beginning of the function. Remember that > the array "siece" (into which offset is an index) does not represent the > values "trial+0", "trial+1", "trial+2", but rather represents trial+0, > trial+2, trial+4, etc. This is because trial is always odd, and we're not > interested in even values. As the comment says: > > |After this function is finished,||if sieve[i] is non-zero, then >> (trial + 2*i) is composite.| >> > > But I think this computation is still flawed because of the effect it has > when rem is odd. So I might change the code to look like this: > > | if (rem == 0) {| >> | offset = 0;| >> | }else if (rem & 1) {| >> | offset = (prime -rem) / 2;| >> | } else { >> offset = prime - (rem / 2); >> }| >> > This issue doesn't mean that the prime number generator generates bad > primes. > It simply means the generator is less efficient than it should be because > it > marks some primes as composits. > > /Nelson > > 123456789012345678901234567890123456789012345678901234567890 > 12345678901234567890 > > -- > dev-tech-crypto mailing list > dev-tech-crypto@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-tech-crypto > -- --------------------------------------- 井関正也(東京工業大学総合理工学研究科物理情報システム) メール:masaya.is...@ms.pi.titech.ac.jp 電話番号:080-5541-6261 -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto