Signature Algorithms: RSA and DSA

17 Dec 2021


§ Motivation

Until now, we have focused on cryptosystems that are used in encrypting and decrypting messages. With signature algorithms, we can post a message publicly along with a digital signature that certifies the authenticity of the message.

§ Hashing Algorithms

One-way Hash Function

A hash function takes an input and generates an output that is typically more efficient, i.e. smaller.

H(x):NNH(x) : \mathbb{N} \to \mathbb{N}

A hash function does not need to be a bijective function, but for a given input xx it must be difficult to construct a yy such that H(x)=H(y)H(x) = H(y). The function must also be difficult to reconstruct the input xx given the output H(x)H(x).

If two inputs map to the same output, we call this a hash collision.

§ RSA Signature Algorithm

The RSA signature algorithm works very similiarly to the cryptosystem.

RSA Signature

Signing: Suppose Samantha wants to sign a message gg with an RSA signature. Then, Samantha chooses two large primes p,qp, q such that m=pqm = pq, and she chooses a kk such that (k,φ(m))=1(k, \varphi(m)) = 1. Next, she computes the multiplicative inverse of kk, k\overline{k}. Now she computes the signaure of her message by computing

sgk(modm),s \equiv g^{\overline{k}} \pmod{m},

she then makes public the signature ss, the message gg, and the values kk and mm.

Verifying: If Victor wants to validate the authenticity of Samantha's message, all he has to do is compute

ssk(modm)s' \equiv s^{k} \pmod{m}

if smgs' \equiv_m g, then Victor can be assured that the message is authentic.

Typically, we use a hashing function on the message and find the signature of the hash, instead of the whole message. The onus is on the verifier to use the same hashing algorithm and compute the hash of the message, then verifying that the signature matches this hash.

§ Digital Signature Algorithm (DSA)

The Digital Signature Algorithm is an alternative to the RSA signature algorithm, and one of its key benefits is that it is generally faster. Like Diffie-Hellman and Elgama, DSA relies on the difficulty of the DLP rather than factorization.

DSA

Signing: Suppose Samantha wants to sign a message mm with DSA. First, Samantha computes the hash of the document DD. Then, she chooses two large primes p,qp, q such that q>Dq \gt D, pkp \sim k (i.e. pp is a kk-bit prime), and qlq \sim l for (k,l)(k, l) in (1024,160)(1024, 160), (2048,224)(2048, 224), (2048,256)(2048, 256), (3072,256)(3072, 256)[^1]. The primes p,qp, q must also satisfy the following congruence

p1(modq)    q(p1).p \equiv 1 \pmod{q} \iff q \vert (p-1).

Samantha also chooses an element gFpg \in \mathbb{F}_p such that ordp(g)=q\text{ord}_p(g) = q. Given a primitive root g1Fpg_1 \in \mathbb{F}_p, she can choose gpg1(p1)/qg \equiv_p g_1^{(p-1)/q}.

Next, Samantha chooses a secret aa and computes ApgaA \equiv_p g^a. Her public signature is composed of the 44-tuple (p,q,g,A)(p, q, g, A). Samantha then chooses a random element k[1q]k \in [1\dots q] and computes

S1(gk(modp))(modq)S2(D+aS1)k1(modq).\begin{align*} S_1 &\equiv \left(g^k \pmod{p}\right) \pmod{q}\\\\ S_2 &\equiv \left(D + aS_1\right)k^{-1} \pmod{q}. \end{align*}

Finally, Samantha's signature is given by the pair (S1,S2)(S_1, S_2).

Verifying: Victor begins by computing the values

V1=DS21(modq)V2=S1S21(modq).\begin{align*} V_1 = DS_2^{-1} \pmod{q}\\ V_2 = S_1S_2^{-1} \pmod{q}. \end{align*}

Next, Victor checks the following congruence

(gV1AV2(modp))(modq)S1.\left(g^{V_1}A^{V_2}\pmod{p}\right) \pmod{q} \equiv S_1.

If the congruence holds, the message is certified to be authentic.

By choosing our qq such that ordp(g)=q\text{ord}_p(g) = q strengthens the DSA. We've discussed Shank's Baby-Step Giant-Step algorithm to solve the DLP when the order of a group element is a prime. It takes O(N)\mathcal{O}(N) memory, where NqN \sim \sqrt{q}, so using the smallest recommended bit-size qq of 160160, we can expect around 2802^{80} bytes of memory to solve using Shank's.