JP

Cryptography Unit 3 - Comprehensive Study Notes

What is Cryptography?

  • Cryptography is the practice and study of techniques for secure communication in the presence of third parties.
  • Aim: ensure that a given message is read by the reader and the receiver exclusively.

Historical Context and Importance

  • During war, secure communication was crucial (World War II).
  • Notable examples: Nazi Enigma machine and Alan Turing's Colossus computer.

Modern Relevance and Applications

  • In modern applications it is crucial to communicate securely, such as:
    • transferring funds electronically,
    • storing users' information in databases (e.g., Facebook, Twitter).
  • With blockchain technologies (Bitcoin, Ethereum), secure communication remains essential.

Plaintext and Ciphertext: Core Concepts

  • Plaintext:
    • Any readable data, including binary files.
    • It is the input into a crypto system.
    • Plaintext can be utilized without the need for decryption algorithms (or a key).
  • Ciphertext:
    • The result of encryption performed on plaintext using an algorithm.
    • Ciphertext is not human readable.
    • We need a decryption algorithm (and usually a key) to recover plaintext.

Encryption, Decryption, and Keys

  • Encryption: the process of encoding a given message so that only authorized parties can access it.
  • Decryption: the inverse operation, decoding a message to recover the plaintext.
  • Key: a sequence required for both encryption and decryption.

Mathematical View: Encryption and Decryption Functions

  • Encryption: ciphertext = f(plaintext, key)
  • Decryption: plaintext = f^{-1}(ciphertext, key)
  • Represented as:
    • \text{ciphertext} = f(\text{plaintext}, \text{key})
    • \text{plaintext} = f^{-1}(\text{ciphertext}, \text{key})

Symmetric Encryption (Private Key Cryptosystem)

  • Uses a single key for both encryption and decryption:
    • \text{ciphertext} = f(\text{plaintext}, \text{key})
  • Why called a "private key" or "symmetric" cryptosystem.
  • Main problem: the private key must be exchanged securely, and there are many keys in a network (one per pair of communicating users).

Key Management in a Network (Illustrative Question)

  • If there are N users in a network and each pair uses a unique private key to communicate, how many unique private keys are needed?
  • Options:
    • A. N/2
    • B. N
    • C. N+N
    • D. NXN
    • E. I don’t want to let you know my answer.
  • Correct count (theoretically): \binom{N}{2} = \frac{N(N-1)}{2}
  • Note: None of the given options in the slide match this, highlighting the complexity of key management in symmetric networks.

Asymmetric (Public-Key) Encryption

  • Uses different keys for encryption and decryption:
    • Ciphertext = f(plaintext, public_key)
    • Decryption uses the private key: plaintext = f^{-1}(ciphertext, private_key)
  • This is why it is called a public key cryptosystem or asymmetric cryptosystem.

Public and Private Keys: How They are Used

  • Private key: must be kept private by the owner.
  • Public key: can be known by anyone in the network.
  • Example workflow:
    • Alice wants to send a message to Bob.
    • Alice encrypts the message using Bob's public key.
    • Bob decrypts the message using his own private key.

Quiz Highlights (From the Slides)

  • Q1: What is a key in cryptography?
    • Options (summary): The encrypted message; A sequence needed for encryption and decryption; The decrypted message.
    • Correct notion: The key is a sequence needed for both encryption and decryption.
  • Q2: A cryptosystem that uses the same key for encryption and decryption is called:
    • Symmetric (private key) cryptography.
  • Q3: The cryptosystem that uses two keys (private and public) is:
    • Public key cryptography (asymmetric encryption).

Lab 1: Symmetric Encryption and Decryption with XOR

  • Objective: Create a Python program to perform encryption and decryption using XOR.
  • Encryption rule: To encrypt, XOR a plaintext message M with a private key K: E = M^K
  • Decryption rule: To decrypt, XOR the encrypted message E with the same key K: M = E^K
  • Important: the same operation (XOR) can be used for both encryption and decryption.
  • Operation details:
    • XOR (exclusive OR) is a binary operation that yields true when the inputs differ.
    • In Python, XOR is represented by the caret symbol: ^.
    • The operation can be performed between elements from bytearrays, not just strings.
  • Practical notes for Lab 1:
    • Example syntax reference: A ^ B, where A and B are elements from bytearrays.
    • Encoding: 'I am the king of the north'.encode('utf-8') converts a string to a bytearray.
    • Decoding: bytearray_value.decode('utf-8') converts a bytearray back to a string.
    • Pay attention to indentation in Python programs.

Additional Context and Terminology

  • plaintext as input to a cryptosystem corresponds to data intended for secure handling.
  • ciphertext as output of encryption corresponds to protected data.
  • Plaintext can be binary or text; ciphertext is not human-readable until decrypted.
  • The security of symmetric systems heavily depends on secure key exchange and key secrecy.

Practical Implications and Real-World Relevance

  • Cryptography underpins secure online transactions, data privacy, and authentication.
  • In real-world systems, hybrid approaches are common: symmetric encryption for data at rest or in bulk, with asymmetric crypto used for secure key exchange (e.g., TLS).
  • Public-key cryptography enables digital signatures and identity verification in addition to confidentiality.

Ethical, Philosophical, and Practical Considerations

  • The balance between strong cryptographic protections and user accessibility.
  • Trade-offs between performance (speed of symmetric vs asymmetric) and key management complexity.
  • Implications for surveillance, privacy rights, and security governance.

Notation Recap and Formulas

  • Encryption function and decryption function: \text{ciphertext} = f(\text{plaintext}, \text{key}), \text{plaintext} = f^{-1}(\text{ciphertext}, \text{key})
  • Symmetric key concept: single key for both encryption and decryption; key must be kept secret and shared securely only with intended recipients.
  • Asymmetric key concept: pairs of keys (publickey, privatekey) where the public key is distributed openly and the private key is kept secret.

References to Transcript Details (for exam-style recall)

  • World War II cryptography: Enigma and Colossus illustrate the historical importance of secure communications.
  • Modern secure communications include financial transactions and social media data protection.
  • Blockchain technologies reinforce the importance of secure communication channels.
  • Lab 1 emphasizes XOR-based symmetric encryption and Python-related implementation notes, including byte-level operations and string encoding/decoding.