Applied Cryptography Course Notes
Applied Cryptography Course Notes
❖ Basic Probability
❖ Perfect Secrecy
❖ Crypto Requirements
❖ Crypto Taxonomy
0 0 0
00 01 10 11 00 01 10 11 00 01 10 11
Pr 00 = 1/4 Pr 00 = 1/4 Pr 00 =0
Pr 01 = 1/4 Pr 01 = 1/8 Pr 01 =1
Pr 10 = 1/4 Pr 10 = 1/2 Pr 10 =0
Pr 11 = 1/4 Pr 11 = 1/8 Pr 11 =0
Uniform distribution Point distribution
Perfectly Secret Encryption ENCS4320 – Applied Cryptography © Ahmed Shawahna – slide 3
Discrete Probability
❖ A subset 𝐸 ⊆ 𝒰 is called an event, and Pr 𝐸 = σe ∈ 𝐸 Pr 𝑒
𝒰
𝐸
Solution:
Pr 𝐸 = Pr 1100 0000 + Pr[1100 0001] + ⋯ + Pr 1111 1111
= 26 / 28
= 1/22
= 1/4
𝒰
𝐸1
𝐸2
𝒰
𝐸1
𝐸2
= Pr 𝐹 | 𝐸𝑖 ⋅ Pr 𝐸𝑖
𝑖=1
Perfectly Secret Encryption ENCS4320 – Applied Cryptography © Ahmed Shawahna – slide 10
Random Numbers
❖ Random numbers used to generate keys
E.g., independent, unbiased (i.e., uniform) bits for symmetric keys
❖ Random numbers used for nonces (used only-once values)
Sometimes a sequence is OK
But sometimes nonces must be random
❖ Random numbers also used in simulations, statistics, etc.
Such numbers need to be “statistically” random
❖ Two distinct and not necessarily compatible requirements for a
sequence of random numbers are:
Randomness (irreproducible)
Unpredictability
RNG
❖ Solving:
Request 300 bit of output, i.e., s1, s2 and s3
s2 = (A * s1 + B) mod m
s3 = (A * s2 + B) mod m
… directly reveals A and B. All si can be computed easily!
❖ Bad cryptographic properties due to the linearity of most PRNGs
Bottom line: “The use of pseudo-random processes to generate
secret quantities can result in pseudo-security”
Perfectly Secret Encryption ENCS4320 – Applied Cryptography © Ahmed Shawahna – slide 17
Cryptographically Secure PRNG (CSPRNG)
❖ Special PRNG with additional property:
Output must be unpredictable
❖ More precisely: Given n consecutive bits of output si, the
following output bits sn+1 cannot be predicted (in polynomial
time)
❖ Needed in cryptography, in particular for stream ciphers
❖ Remark: There are almost no other applications that need
unpredictability, whereas many, many (technical) systems
need PRNGs
𝒰 𝒱
❖ Example: 00000 0
𝒰 𝒱 00001 1
00010 𝒳 2
𝒳 ∶ 0,1 5 → {0,1, 2, … , 10}
⋮ ⋮
def
𝒳 𝑥 = 𝑥0 + 𝑥1 + 𝑥2 + 𝑥3 + 𝑥4 11111 10
Pr 𝑋 = 0 = 1/32
Pr 𝑋 = 1 = 5/32
Uniform distribution on 𝒰
5
Pr 𝑋 = 2 = / 32 = 10/32 but not on 𝒱!
⋮ 2
Pr 𝑋 = 10 = 0
Perfectly Secret Encryption ENCS4320 – Applied Cryptography © Ahmed Shawahna – slide 19
Deterministic and Randomized Algorithms
Inputs Outputs
❖ Deterministic algorithm:
𝑦 ← 𝐴(𝑥)
𝑥
𝐴(𝑥)
❖ Randomized algorithm:
$ 𝐴(𝑥)
𝑦 ← 𝐴(𝑥, 𝑟) where 𝑟 ← 0,1 𝑛 𝑥
𝐴(𝑥′)
$
𝑦 ← 𝐴(𝑥′) 𝑥′
Pr 𝑀 = "boo" ⋂ 𝐾 = 2 = Pr 𝑀 = "boo" ⋅ Pr 𝐾 = 2
= 0.3 ⋅ 1/26
Therefore,
Pr 𝑀 = "ann" | 𝐶 = "DQQ"
Pr 𝐶 = "DQQ" | 𝑀 = "ann" ⋅ Pr 𝑀 = "ann"
=
Pr 𝐶 = "DQQ"
Pr 𝐶 = "DQQ" | 𝑀 = "ann" ⋅ 0.2
=
1/52
❖ Basic Probability
❖ Perfect Secrecy
❖ Crypto Requirements
❖ Crypto Taxonomy
Solution:
The probability distribution over ℳ, for every message 𝑚 ∈ ℳ, is
Pr 𝑀 = 𝑚 = 1/ 26 2
Consider the message is “hi“ and the ciphertext is “XX” (i.e., 𝑚 =
"hi" and 𝑐 = "XX"). Then, clearly Pr 𝑀 = "hi" | 𝐶 = "XX" = 0, as
there is no way that “XX” can ever result from the encryption of
“hi“ (In the shift cipher, the relative shift between characters is
preserved). Therefore,
Pr 𝑀 = "hi" | 𝐶 = "XX" ≠ Pr 𝑀 = "hi"
2 # the scheme is not
0 ≠ 1/ 26
perfectly secret
Perfectly Secret Encryption ENCS4320 – Applied Cryptography © Ahmed Shawahna – slide 27
Perfectly Secret
❖ Basic Probability
❖ Perfect Secrecy
❖ Crypto Requirements
❖ Crypto Taxonomy
❖ Decryption: 𝒦×𝒞 →ℳ
𝑀←𝐶𝐾
Deck(c1 ··· cL) = m1 ··· mL , where mi = ci ki
h e i l h i t l e r
Plaintext: 001 000 010 100 001 010 111 100 000 101
Key: 111 101 110 101 111 100 000 101 110 000
Ciphertext: 110 101 100 001 110 110 111 001 110 101
s r l h s s t h s r
s r l h s s t h s r
Ciphertext: 110 101 100 001 110 110 111 001 110 101
Key: 111 101 110 101 111 100 000 101 110 000
Plaintext: 001 000 010 100 001 010 111 100 000 101
h e i l h i t l e r
s r l h s s t h s r
Ciphertext: 110 101 100 001 110 110 111 001 110 101
Key: 101 111 000 101 111 100 000 101 110 000
Plaintext: 011 010 100 100 001 010 111 100 000 101
k i l l h i t l e r
s r l h s s t h s r
Ciphertext: 110 101 100 001 110 110 111 001 110 101
Key: 111 101 000 011 101 110 001 011 101 101
Plaintext: 001 000 100 010 011 000 110 010 011 000
h e l i k e s i k e
Solution:
Encryption: Plaintext Key = Ciphertext
0 1 2 3 4 5
Plaintext: 0000 0001 0010 0011 0100 0101
Key: 1111 1111 1110 1110 1101 1101
Ciphertext: 1111 1110 1100 1101 1001 1000
F E C D 9 8
Perfectly Secret Encryption ENCS4320 – Applied Cryptography © Ahmed Shawahna – slide 39
One-Time Pad – Security
Pr Enc𝐾 (𝑚) = 𝑐 = Pr 𝐾 ⊕ 𝑚 = 𝑐
1
= Pr 𝐾 = 𝑚 ⊕ 𝑐 = Pr 𝐾 = 𝑘1 =
2𝑛
Pr Enc𝐾 (𝑚′ ) = 𝑐 = Pr 𝐾 ⊕ 𝑚′ = 𝑐
1
= Pr 𝐾 = 𝑚′ ⊕ 𝑐 = Pr 𝐾 = 𝑘2 =
2𝑛
Solution:
This is not true. Consider modifying the one-time pad so encryption
appends a bit that is 0 with probability 1/4 and 1 with probability
3/4. This scheme will still be perfect secret, but ciphertexts ending
with 1 are more likely that ciphertexts ending with 0.
❖ Basic Probability
❖ Perfect Secrecy
❖ Crypto Requirements
❖ Crypto Taxonomy
❖ Basic Probability
❖ Perfect Secrecy
❖ Crypto Requirements
❖ Crypto Taxonomy
Message Integrity /
Message Privacy
Authentication
Asymmetric Encryption
Asymmetric Keys Digital Signatures
(public-key encryption)
Message Integrity /
Message Privacy
Authentication
Asymmetric Encryption
Asymmetric Keys
(public-key encryption)
Digital Signatures Part II
❖ Zero-knowledge proofs
❖ Fully-homomorphic encryption
𝐸𝑛𝑐 𝐾, 𝑀1 + 𝑀2 = 𝐸𝑛𝑐 𝐾, 𝑀1 + 𝐸𝑛𝑐 𝐾, 𝑀2
❖ Multi-party computation
❖ Blockchain