Notes - MCS
Applied Cryptography
Notes - MCS
Applied Cryptography
  • Applied Cryptography
  • Classical (Symmetric) Cryptography
    • Terminology
    • The Players
    • Use Cases
    • Information-Theoretic Security
    • Computational Security
    • Cryptanalysis
    • Practical Approaches
    • Cryptographic Robustness
    • Ciphers
      • Mono-Alphabetic
      • Polylphabetic
    • Rotor Machines
    • Stream Ciphers
  • Modern Symmetric Cryptography
    • Types
    • Symmetric Ciphers
    • Symmetric Block Ciphers
    • Feistel Networks
    • DES (Data Encryption Standard)
    • AES (Advanced Encryption Standard)
    • Stream Ciphers
    • Uniform Random Access
    • Linear Feedback Shift Register (LFSR)
  • Cipher Modes
    • Deployment of (Symmetric) Block Ciphers
    • Stream Cipher Modes
    • Security Reinforcement
  • Cryptographic Hashing
    • Digest functions
    • Rainbow Tables
    • Message Authentication Codes (MAC)
    • Authenticated Encryption
    • Encryption + Authentication
  • RSA & Related Subjects
    • Modular Arithmetic
    • Fast Modular Multiplication
    • The Extended Euclid's Algorithm
    • Linear Maps
    • Fermat's Little Theorem
    • Chinese Remainder Theorem
    • Fermat's Little Theorem
    • Modular Exponentiation
    • Multiplicative Order
    • The Discrete Logarithm Problem
    • Primality tests
    • The Diffie-Hellman Key Exchange Protocol
    • ElGamal Public Key Cryptosystem
    • The Rivest-Shamir-Adleman Cryptosystem
    • Finite Fields
    • Elliptic Curves
    • Diffie-Hellman using elliptic curves
    • Can we do RSA-like things with elliptic curves?
    • The discrete logarithm problem for elliptic curves
    • Secret sharing
    • Quadratic Residues
    • Zero-Knowledge proofs
      • One of two oblivious transfer
      • Coin flipping
      • Zero-knowledge proofs of identity
    • Homomorphic encryption
  • Asymmetric Key Management
    • Design Principles
    • Exploitation of private keys
    • Distribution of public keys
    • Public key (digital) certificates
    • Key pair usage
    • Certification Authorities (CA)
    • Certification Hierarchies
    • Refreshing of asymmetric key pairs
    • Certificate revocation lists (CRL)
    • Validity of signatures
    • Distribution of public key certificates
    • Time Stamping Authority (TSA)
    • PKI (Public Key Infrastructure)
  • Digital Signatures
    • Fundamental Approach
    • Signature Schemes
    • Key Elements
    • The document to sign
    • The signature date
    • The identity of the signatory
    • Optional elements of a digital signature
    • Algorithms
    • RSA signatures
    • ASN.1 digest algorithm prefixes
    • Digital Signature Standard (DSS)
    • Blind Signatures
    • Chaum Blind Signatures
    • Qualified electronic signature
      • Signature devices
    • PKCS #11
    • Microsoft Cryptographic API (CAPI)
    • Long-Term Validation (LTV)
    • LTV Advanced Electronic Signatures (AdES)
Powered by GitBook
On this page
  • A Failed Cryptosystem
  • Merkle-Hellman Knapsack Example
  1. RSA & Related Subjects

Linear Maps

When working modulo mmm it suffices to work with integers in the range 0,1,...,m−10, 1, ..., m-10,1,...,m−1.

Let f(x;m,a)=(ax)modmf(x;m,a) = (ax)modmf(x;m,a)=(ax)modm be the linear map xxx-> (ax)modm(ax) mod m(ax)modm from Zm\mathbb{Z}_mZm​ into itself.

Recall that a function f(x)f(x)f(x) is said to be linear if f(αx∗βy)=αf(x)+βf(y)f( \alpha x * \beta y) = \alpha f(x) + \beta f(y)f(αx∗βy)=αf(x)+βf(y) for all α,β,x\alpha , \beta , xα,β,x and yyy.

For example, for m=4m=4m=4 the linear map with a=2a = 2a=2 (on the left) is not invertible, but the linear map with a=3a = 3a=3 (on the right) is invertible.

map for m=4 and a=2
map for m=4 and a=3

0 -> 0

0 -> 0

1 -> 2

1 -> 3

2 -> 0

2 -> 2

3 -> 2

3 -> 1

Why are we interested in inverting the map? Because the map scambles the elements of Zm\mathbb{Z}_mZm​ and we may be interested in unscrambling them (think in cryptographic terms).

So, what is the inverse map?

It turns out that the inverse map if it exists, is also linear.

More specifically, the inverse map of f(x,m,amodm)f(x, m, a mod m)f(x,m,amodm) is f(x,m,a−1modm)f(x, m, a^{-1} mod m)f(x,m,a−1modm), where a−1modma^{-1} mod ma−1modm is the modular inverse of amodma mod mamodm. Indeed, if y=f(x;m,a)=axmodmy = f(x; m,a) = ax mod my=f(x;m,a)=axmodm then x=a−1ymodmx = a^{-1}y mod mx=a−1ymodm.

Since the modular inverse of aaa modulo mmm only exists when gcd(a,m)=1gcd(a, m) = 1gcd(a,m)=1 the linear map is invertible if and only if gcd(a,m)=1gcd(a,m) = 1gcd(a,m)=1.

Keep in mind that we wish to devise a way to encrypt information by providing public data to do so (in this case it would be mmm and aaa).

Alas, this way of scrambling information is very easy to unscramble, so useless from a cryptography point of view.

Modular multiplication scrambles the information but it is easy to undo if we know mmm and aaa. What about modular exponentiation?

A Failed Cryptosystem

The Merklw-Hellman knapsack cryptosystem keeps the following information secret:

  • a set W={w1,w2,...,wn}W = \lbrace w_1, w_2, ..., w_n \rbrace W={w1​,w2​,...,wn​} of nnn positive integers, such that wkw_kwk​ is a super-increasing sequence. i.e: wk>∑i=1k−1wiw_k \gt \sum^{k-1}_{i=1}w_ iwk​>∑i=1k−1​wi​ for 2≤k≤n2 \le k \le n2≤k≤n.

  • a modulus mmm such that m>∑i=1nwim \gt \sum^n_{i=1} w_im>∑i=1n​wi​

  • a scrambling integer aaa such that gcd(a,m)=1gcd(a,m) = 1gcd(a,m)=1.

and publishes the following information: set W′={w1′,w2′,...,wn′}W' = \lbrace w'_1, w'_2, ..., w'_n \rbraceW′={w1′​,w2′​,...,wn′​}, where wi′=(awi)modmw'_i = (aw_i)mod mwi′​=(awi​)modm, for 1≤i≤n1 \le i \le n1≤i≤n.

It is much better to publish a random permutation of W′W'W′. To send a message composed by the nnn bits αk,1≤k≤n\alpha_k, 1 \le k \le nαk​,1≤k≤n, compute and send.

C=∑k=1nakwk′C = \sum^n_{k=1}a_kw'_kC=k=1∑n​ak​wk′​

This is a hard knapsack problem (in this case a subset sum problem). To decipher transform it into a trivial knapsack problem by computing a−1Cmodma^{-1}C mod ma−1Cmodm, which is equal to ∑k=1nakwk\sum^n_{k=1}a_kw_k∑k=1n​ak​wk​ and so can be solved by a greedy algorithm.

Merkle-Hellman Knapsack Example

The following example shows the Merklw-Hellman cryptosystem in action.

  • Secret data: W={1,3,5,12,22,47},m=100W = \lbrace 1, 3, 5, 12, 22, 47 \rbrace, m = 100W={1,3,5,12,22,47},m=100 and a=13a = 13a=13.

  • Public data: W′={13,39,65,56,86,11}W' = \lbrace 13, 39, 65, 56, 86, 11 \rbraceW′={13,39,65,56,86,11}.

  • Unencrypted message to be sent: A={0,0,1,1,0,1}A = \lbrace 0, 0, 1, 1, 0, 1 \rbrace A={0,0,1,1,0,1}

  • Encrypted message sent: C=0∗13+0∗39+1∗65+1∗56+0∗86+1∗11=132C = 0*13 + 0*39 + 1*65 + 1*56 + 0*86 + 1*11 = 132C=0∗13+0∗39+1∗65+1∗56+0∗86+1∗11=132

  • To decrypt compute 132∗13−1mod100=32∗77mod100=64132 * 13^{-1} mod 100 = 32 * 77 mod 100 = 64132∗13−1mod100=32∗77mod100=64 and then reason as follows [greedy algorithm for the easy subset sum problem]:

    • 474747 must be used to form the sum because 64>4764 \gt 4764>47. Hence α6=1\alpha_6 = 1α6​=1. The rest of the sum is 64−47=1764-47=1764−47=17.

    • 222222 cannot be used to form the sum because 17<2217 \lt 2217<22. Hence α5=0\alpha_5 = 0α5​=0.

    • 121212 must be used to form the sum because 17>1217 \gt 1217>12. Hence α4=1\alpha_4 = 1α4​=1. The rest of the sum is 17−12=517-12=517−12=5.

    • As so on. In this particular case, the next iteration finishes the deciphering process.

Last updated 1 year ago