Day 5: Key Exchange & Public Key Encryption
Lecture Topics
- notes
- key exchange
- the story
- Diffie-Hellman key exchange
- public key encryption
- Merkle puzzles
Background information
We’ll be working in the main.py
file. The following files are also
available:
cryptoy.py
- note:
IntMod
is now included incryptoy
- note:
hashing.py
symmetric.py
The group you’ll be using for Diffie-Hellman is in the cryptoy
library: the
class Ed25519
represents a group element. Information about this
class/group:
Ed25519.generator()
returns the generator for the groupEd25519.identity()
returns the identity for the groupEd25519.order
is the group’s order: an integer- The following operators are defined for
Ed25519
:*
: multiplies two group elements**
: raises a group element to an integer power==
/!=
: checks for equalityG.inverse()
: gets the inverse ofG
G.to_bytes()
: representsG
as a (unique) byte sequence
- fun fact: “Ed25519” roughly translates as “the twisted edwards elliptic curve over base field of order $ 2^{255}-19 $”. This group is defined in the internet standard RFC7748, section 4.2.
Problems
-
required:
- Diffie-Hellman key exchange:
diffie_hellman_key_gen
diffie_hellman_derive_shared
- Diffie-Hellman-based public key encryption:
public_key_encrypt
public_key_decrypt
- Diffie-Hellman key exchange:
-
bonus:
- Merkle puzzles key exchange:
int_hash
merkle_key_gen
merkle_derive_shared
merkle_prob_estimate
- attacking Diffie-Hellman key exchange:
- written question 1: describe your attack
- implement your attack as a class with:
- a constructor:
AttackDH.__init__
- a message handler:
AttackDH.handle_msg
- the class’s docstring contains the test for the attack
- a constructor:
- Merkle puzzles key exchange: