# Rabin signature algorithm

In cryptography, the Rabin signature algorithm is a method of digital signature originally proposed by Michael O. Rabin in 1978.

The Rabin signature algorithm was one of the first digital signature schemes proposed. By introducing the use of hashing as an essential step in signing, it was the first design to meet what is now the modern standard of security against forgery, existential unforgeability under chosen-message attack, assuming suitably scaled parameters.

Rabin signatures resemble RSA signatures with 'exponent $e=2$ ', but this leads to qualitative differences that enable more efficient implementation and a security guarantee relative to the difficulty of integer factorization, which has not been proven for RSA. However, Rabin signatures have seen relatively little use or standardization outside IEEE P1363 in comparison to RSA signature schemes such as RSASSA-PKCS1-v1_5 and RSASSA-PSS.

## Definition

The Rabin signature scheme is parametrized by a randomized hash function $H(m,u)$ of a message $m$ and $k$ -bit randomization string $u$ .

Public key
A public key is a pair of integers $(n,b)$ with $0\leq b and $n$ odd.
Signature
A signature on a message $m$ is a pair $(u,x)$ of a $k$ -bit string $u$ and an integer $x$ such that
$x(x+b)\equiv H(m,u){\pmod {n}}.$ Private key
The private key for a public key $(n,b)$ is the secret odd prime factorization $p\cdot q$ of $n$ , chosen uniformly at random from some space of large primes. Let $d=(b/2){\bmod {n}}$ , $d_{p}=(b/2){\bmod {p}}$ , and $d_{q}=(b/2){\bmod {q}}$ . To make a signature on a message $m$ , the signer picks a $k$ -bit string $u$ uniformly at random, and computes $c:=H(m,u)$ . If $c+d^{2}$ is a quadratic nonresidue modulo $n$ , then the signer throws away $u$ and tries again. Otherwise, the signer computes
{\begin{aligned}x_{p}&:={\Bigl (}-d_{p}\pm {\sqrt {c+{d_{p}}^{2}}}{\Bigr )}{\bmod {p}}\\x_{q}&:={\Bigl (}-d_{q}\pm {\sqrt {c+{d_{q}}^{2}}}{\Bigr )}{\bmod {q}},\end{aligned}} using a standard algorithm for computing square roots modulo a prime—picking $p\equiv q\equiv 3{\pmod {4}}$ makes it easiest. Square roots are not unique, and different variants of the signature scheme make different choices of square root; in any case, the signer must ensure not to reveal two different roots for the same hash $c$ . The signer then uses the Chinese remainder theorem to solve the system
{\begin{aligned}x&\equiv x_{q}{\pmod {n}}\\x&\equiv x_{p}{\pmod {n}}\end{aligned}} for $x$ . The signer finally reveals $(u,x)$ .

Correctness of the signing procedure follows by evaluating $x(x+b)-H(m,u)$ modulo $p$ and $q$ with $x$ as constructed. For example, in the simple case where $b=0$ , $x$ is simply a square root of $H(m,u)$ modulo $n$ . The number of trials for $u$ is geometrically distributed with expectation around 4, because about 1/4 of all integers are quadratic residues modulo $n$ .

## Security

Security against any adversary defined generically in terms of a hash function $H$ (i.e., security in the random oracle model) follows from the difficulty of factoring $n$ : Any such adversary with high probability of success at forgery can, with nearly as high probability, find two distinct square roots $x_{1}$ and $x_{2}$ of a random integer $c$ modulo $n$ . If $x_{1}\pm x_{2}\not \equiv 0{\pmod {n}}$ then $\gcd(x_{1}\pm x_{2},n)$ is a nontrivial factor of $n$ , since ${x_{1}}^{2}\equiv {x_{2}}^{2}\equiv c{\pmod {n}}$ so $n\mid {x_{1}}^{2}-{x_{2}}^{2}=(x_{1}+x_{2})(x_{1}-x_{2})$ but $n\nmid x_{1}\pm x_{2}$ . Formalizing the security in modern terms requires filling in some additional details, such as the codomain of $H$ ; if we set a standard size $K$ for the prime factors, $2^{K-1} , then we might specify $H\colon \{0,1\}^{*}\times \{0,1\}^{k}\to \{0,1\}^{K}$ .

Randomization of the hash function was introduced to allow the signer to find a quadratic residue, but randomized hashing for signatures later became relevant in its own right for tighter security theorems and resilience to collision attacks on fixed hash functions.

## Variants

The quantity $b$ in the public key adds no security, since any algorithm to solve congruences $x(x+b)\equiv c{\pmod {n}}$ for $x$ given $b$ and $c$ can be trivially used as a subroutine in an algorithm to compute square roots modulo $n$ and vice versa, so implementations can safely set $b=0$ for simplicity; $b$ was discarded altogether in treatments after the initial proposal.

The Rabin signature scheme was later tweaked by Williams in 1980 to choose $p\equiv 3{\pmod {8}}$ and $q\equiv 7{\pmod {8}}$ , and replace a square root $x$ by a tweaked square root $(e,f,x)$ , with $e=\pm 1$ and $f\in \{1,2\}$ , so that a signature instead satisfies

$efx^{2}\equiv H(m,u){\pmod {n}},$ which allows the signer to create a signature in a single trial without sacrificing security. This variant is known as Rabin–Williams. Further variants allow tradeoffs between signature size and verification speed, partial message recovery, signature compression, and public key compression.

Variants without the hash function have been published in textbooks, crediting Rabin for exponent 2 but not for the use of a hash function. These variants are trivially broken—for example, the signature $x=2$ can be forged by anyone as a valid signature on the message $m=4$ if the signature verification equation is $x^{2}\equiv m{\pmod {n}}$ instead of $x^{2}\equiv H(m,u){\pmod {n}}$ .

In the original paper, the hash function $H(m,u)$ was written with the notation $C(MU)$ , with C for compression, and using juxtaposition to denote concatenation of $M$ and $U$ as bit strings:

By convention, when wishing to sign a given message, $M$ , [the signer] $P$ adds as suffix a word $U$ of an agreed upon length $k$ . The choice of $U$ is randomized each time a message is to be signed. The signer now compresses $M_{1}=MU$ by a hashing function to a word $C(M_{1})=c$ , so that as a binary number $c\leq n$ This notation has led to some confusion among some authors later who ignored the $C$ part and misunderstood $MU$ to mean multiplication, giving the misapprehension of a trivially broken signature scheme.