Skip to main content
Mathematics LibreTexts

7.8: Sage Exercises

  • Page ID
    81082
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    1

    Construct a keypair for Alice using the first two primes greater than \(10^{12}\text{.}\) For your choice of \(E\text{,}\) use a single prime number and use the smallest possible choice.

    Output the values of \(n\text{,}\) \(E\text{,}\) and \(D\) for Alice. Then use Sage commands to verify that Alice's encryption and decryption keys are multiplicative inverses.

    2

    Construct a keypair for Bob using the first two primes greater than \(2\cdot 10^{12}\text{.}\) For your choice of \(E\text{,}\) use a single prime number and use the smallest possible choice. Output the values of \(n\text{,}\) \(E\text{,}\) and \(D\) for Alice.

    Encode the word Math using ASCII values in the same manner as described in this section (keep the capitalization as shown). Create a signed message of this word for communication from Alice to Bob. Output the three integers: the message, the signed message and the signed, encrypted message.

    3

    Demonstrate how Bob converts the message received from Alice back into the word Math. Output the value of the intermediate computations and the final human-readable message.

    4

    Create a new signed message from Alice to Bob. Simulate the message being tampered with by adding \(1\) to the integer Bob receives, before he decrypts it. What result does Bob get for the letters of the message when he decrypts and unsigns the tampered message?

    5. Classroom Exercise

    Organize a class into several small groups. Have each group construct key pairs with some minimum size (digits in \(n\)). Each group should keep their private key to themselves, but make their public key available to everybody in the room. It could be written on the board (error-prone) or maybe pasted in a public site like pastebin.com. Then each group can send a signed message to another group, where the groups could be arranged logically in a circular fashion for this purpose. Of course, messages should be posted publicly as well. Expect a success rate somewhere between 50% and 100%.

    If you do not do this in class, grab a study buddy and send each other messages in the same manner. Expect a success rate of 0%, 50% or 100%.


    This page titled 7.8: Sage Exercises is shared under a GNU Free Documentation License 1.3 license and was authored, remixed, and/or curated by Thomas W. Judson (Abstract Algebra: Theory and Applications) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?