#11565: RSA Cryptosystem
-------------------------------------+-------------------------------------
       Reporter:  ajeeshr            |        Owner:  mvngu
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.6
      Component:  cryptography       |   Resolution:
       Keywords:  RSA, crypto,       |    Merged in:
  public key encryption              |    Reviewers:
        Authors:  Peter Story,       |  Work issues:
  Ajeesh Ravindran                   |       Commit:
Report Upstream:  N/A                |  3c8e43ae07f14dbc6c42f42c5e91cfee5b3f2e45
         Branch:                     |     Stopgaps:
  u/peter.story/rsa_cryptosystem     |
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by peter.story):

 @vdelecroix, thanks for bringing the `__init__` and `__eq__` methods to my
 attention. I copied the implementations from ajeeshr, who had copied them
 from `BlumGoldwasser`, the other `PublicKeyCryptosystem`. The reason
 `BlumGoldwasser` implements them is to override the
 `PublicKeyCryptosystem` implementations, which is necessary because
 `BlumGoldwasser` doesn't initialize its superclass properly (it may be
 helpful to read the code for the Cryptosystem class's `__init__` and
 `__eq__`, which can be found on lines 104-212 in cryptosystem.py).

 I modified `__eq__` to fix the issue you identified. Now, the method just
 compares the class of the two objects being compared. This is a change
 that should also be made to `BlumGoldwasser`.

 However,  `__init__` will be trickier to fix properly. According to the
 `Cryptosystem` class, which `RSACryptosystem` inherits through
 `PublicKeyCryptosystem`, I should be passing the following arguments to my
 superclass's `__init__` method: `plaintext_space, ciphertext_space,
 key_space, block_length=1, period=None`. Without fixing this, inherited
 methods like the following will fail:
 {{{
   sage: rc = RSACryptosystem()
   sage: rc.key_space()
   AttributeError: 'RSACryptosystem' object has no attribute '_key_space'
 }}}
 The following values seem to make the most sense to me, but I'm not
 certain:
  * plaintext_space = group of all integers
  * ciphertext_space = group of all integers
  * key_space: I have no idea how to specify this one as a group.

 Ideally, I would give plaintext_space and ciphertext_space as integers mod
 n, instead of the group of all integers. However, this would require
 giving the RSACryptosystem class state, recording public and private keys
 internally. This would have the effect of making it more opaque, since
 users wouldn't need to explicitly pass keys to encrypt and decrypt. Thus,
 I think it makes sense to keep plaintext_space and ciphertext_space as the
 groups of all integers. Comments on this would be appreciated.

 Side note: `__init__` will also need to be fixed in `BlumGoldwasser`:
 {{{
   sage: from sage.crypto.public_key.blum_goldwasser import BlumGoldwasser
   sage: bs = BlumGoldwasser()
   sage: bs.key_space()
   AttributeError: 'BlumGoldwasser' object has no attribute '_key_space'
 }}}

 Also, as suggested by kcrisman, I corrected several formatting issues with
 the documentation. Thanks to vdelecroix, I removed unnecessary
 redeclarations of variables in my tests, except where redeclaring improved
 readability.

--
Ticket URL: <http://trac.sagemath.org/ticket/11565#comment:23>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to