12.07.2015 Views

Sage Developer's Guide - Mirrors

Sage Developer's Guide - Mirrors

Sage Developer's Guide - Mirrors

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sage</strong> Developer’s <strong>Guide</strong>, Release 6.1.1ALGORITHM:The following algorithm is adapted from page 89 of [Nat2000]_.Let ‘p‘ be an odd (positive) prime and let ‘g‘ be a generatormodulo ‘p‘. Then ‘g^k‘ is a generator modulo ‘p‘ if and only if‘\gcd(k, p-1) = 1‘. Since ‘p‘ is an odd prime and positive, then‘p - 1‘ is even so that any even integer between 1 and ‘p - 1‘,inclusive, is not relatively prime to ‘p - 1‘. We have nownarrowed our search to all odd integers ‘k‘ between 1 and ‘p - 1‘,inclusive.So now start with a generator ‘g‘ modulo an odd (positive) prime‘p‘. For any odd integer ‘k‘ between 1 and ‘p - 1‘, inclusive,‘g^k‘ is a generator modulo ‘p‘ if and only if ‘\gcd(k, p-1) = 1‘.REFERENCES:.. [Nat2000] M.B. Nathanson. Elementary Methods in Number Theory.Springer, 2000.You can also number the steps in your algorithm using the hash-dot symbol. This way, the actual numbering ofthe steps are automatically taken care of when you build the documentation:ALGORITHM:The Blum-Goldwasser decryption algorithm is described in Algorithm8.56, page 309 of [MenezesEtAl1996]_. The algorithm works as follows:#. Let ‘C‘ be the ciphertext ‘C = (c_1, c_2, \dots, c_t, x_{t+1})‘.Then ‘t‘ is the number of ciphertext sub-blocks and ‘h‘ is thelength of each binary string sub-block ‘c_i‘.#. Let ‘(p, q, a, b)‘ be the private key whose correspondingpublic key is ‘n = pq‘. Note that ‘\gcd(p, q) = ap + bq = 1‘.#. Compute ‘d_1 = ((p + 1) / 4)^{t+1} \bmod{(p - 1)}‘.#. Compute ‘d_2 = ((q + 1) / 4)^{t+1} \bmod{(q - 1)}‘.#. Let ‘u = x_{t+1}^{d_1} \bmod p‘.#. Let ‘v = x_{t+1}^{d_2} \bmod q‘.#. Compute ‘x_0 = vap + ubq \bmod n‘.#. For ‘i‘ from 1 to ‘t‘, do:#. Compute ‘x_i = x_{t-1}^2 \bmod n‘.#. Let ‘p_i‘ be the ‘h‘ least significant bits of ‘x_i‘.#. Compute ‘m_i = p_i \oplus c_i‘.#. The plaintext is ‘m = m_1 m_2 \cdots m_t‘.• A NOTE block for special notes (optional). Include information such as purpose etc. A NOTE block shouldstart with .. NOTE::. You can also use the lower-case version .. note::, but do not mix lower-casewith upper-case. However, you are encouraged to use the upper-case version .. NOTE::. If you want toput anything within the NOTES block, you should indent it at least 4 spaces (no tabs). Here’s an example of aNOTE block:.. NOTE::You should note that this sentence is indented at least 4spaces. Avoid tab characters as much as possible whenwriting code or editing the <strong>Sage</strong> documentation. You should4.1. General Conventions 23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!