3

I'm investigating this function:

$a := ((b\cdot c) \bmod k) - (b \cdot c)/k$

where $/$ indicates integer division.

Two things I've noticed:

  1. It's equivalent to multiplying a·b, and then subtracting the high digits from the low digits (in a radix which divides k)
  2. It's completely linear and can be inverted (that is, given a and b, determine c) in constant time.

Is there any background on this function? Does anyone discuss it, or similar functions? Does it belong to a known family? Does it have any known applications?

In short: Where can I look to find out more about it? I'm especially interested in applications for cryptography.

Paŭlo Ebermann
  • 22,946
  • 7
  • 82
  • 119
S. Robert James
  • 329
  • 4
  • 8

2 Answers2

3

As discovered by D.W., this is in fact part of recommended IDEA implementation. IDEA uses $a\cdot b \bmod (2^{16}+1)$, with a special case of handling $0$ as $2^{16}$. From the Handbook of Applied Cryptography, note 7.016:

Note (implementing $ab \bmod 2^{n}+1$) Multiplication $\bmod 2^{16}+1$ may be efficiently implemented as follows, for $0 \leq a, b \leq 2^{16}$ (cf. §14.3.4). Let $c = ab = c_0·2^{32} +c_H·2^{16} +c_L$, where $c_0 \in \{ 0, 1\}$ and $0 \leq c_L, c_H < 2^{16}$. To compute $c' = c \bmod (2^{16} + 1)$, first obtain $c_L$ and $c_H$ by standard multiplication. For $a = b = 2^{16}$, note that $c_0 = 1$, $c_L = c_H = 0$, and $c' = (−1)(−1) = 1$, since $2^{16} \equiv −1 \mod (2^{16}+1)$; otherwise, $c_0 = 0$. Consequently, $c' = c_L − c_H + c_0$ if $c_L \geq c_H$, while $c' = c_L − c_H + (2^{16} + 1)$ if $c_L < c_H$ (since then $−2^{16} < c_L − c_H < 0$).

Which is exactly consistent.

This of course leaves me with some greater questions, such as how IDEA is secure with only linear operations, and where I can read more about it (there's precious little deep discussion online), but those are for a different post. One other interesting thing is that, unlike other ciphers with constant tables, it's not trivial to look at binary code and recognize IDEA. You can scan for $2^{16}+1$, but that's not as certain as for instance finding the md5 table.

Paŭlo Ebermann
  • 22,946
  • 7
  • 82
  • 119
S. Robert James
  • 329
  • 4
  • 8
2

At first glance, it doesn't look like that interesting of a function. If we define:

$$f(b, c) = (b\cdot c)\%k - (b\cdot c)/k$$

then we always have:

$$f(b, c) \equiv bc \mod k+1$$

In other words, largely it's just an odd way of doing a modular multiplication. Of course, $f(b, c)$ is not always $(bc) \% (k+1)$; sometimes it is negative. At first glance, I don't see any interesting pattern to that.

wythagoras
  • 207
  • 1
  • 6
poncho
  • 154,064
  • 12
  • 239
  • 382