4
$\begingroup$

This is a theoretical question to solve an argument with a friend..

Is there a working cryptographic system that do square root operations during the encryption process?

"Working" means that it is really implemented, and not just an academic research.

Hint: I suspect that it is not possible as computer hardware has floating point limitations as it is based on binary, causing infinitely small numbers to truncate, hence doing sqrt during encryption loses information, and cannot be undone during the decryption.

Please help me win the bet :)

$\endgroup$
5
  • 9
    $\begingroup$ You can definitely use non-reversible functions to construct reversible ones, e.g. in a Feistel cipher. Also, if square roots in a finite field count, those can be reversible. (Also, the Rabin cryptosystem probably merits at least a passing mention, even though it only requires computing (modular) square roots for decryption, not for encryption.) $\endgroup$ – Ilmari Karonen Apr 8 '19 at 14:53
  • $\begingroup$ There's some relevant rounding stuff at Could there be a floating point CSPRNG? $\endgroup$ – Paul Uszak Apr 8 '19 at 15:05
  • 2
    $\begingroup$ The initialization vectors of the SHA-2 functions are the binary expansions of the fractional parts of the (real number) square roots of small prime numbers. The SHA-2 functions are often used with encryption, e.g. in a key derivation function for a public-key encryption scheme. Does that count? $\endgroup$ – Squeamish Ossifrage Apr 8 '19 at 15:39
  • 2
    $\begingroup$ Actually, if your CPU does IEEE math (universal nowadays), that places very strict requirements on the accuracy of the floating sqrt operation. Of course, you still have to account for the varying degrees of precision that various implementations provide, but it would be possible (however, I haven't heard of anyone actually doing it) $\endgroup$ – poncho Apr 8 '19 at 15:49
  • $\begingroup$ I think there's also some cipher that uses the middle square method for diffusion, but I forget if it was a block cipher or stream cipher or hash. Granted, squaring is not the same as taking a square root, but still. $\endgroup$ – forest Apr 9 '19 at 23:04
5
$\begingroup$

I'm not aware of any cipher which uses square root as a primitive operation, and I suspect that none exist. Cipher designers tend to prefer a large number of simple operations to a lesser number of complex ones. The most complex operation used in practice is multiplication, and even that is not extremely common. The most complex mathematical operations I know of used in a cipher are exponentiation and logarithms. From a quote by James Massey on the use of complex functions:

I have many times used the discrete exponential or the discrete logarithm as nonlinear cryptographic functions and they have never let me down.


There is no reason why a square root operation would need to return a floating point value (for example, in 8-bit integer arithmetic, $\sqrt50=7$, though it's likely that taking the fractional part of the square root would be more beneficial for causing diffusion and promoting nonlinearity), so it is possible to use, technically. It's perfectly possible to return an integer and still achieve diffusion. I have a few guesses as to why no cipher uses square roots as a cryptographic mixing operation:

  • It's difficult to write a fast constant time implementation, which is necessary to avoid side-channels.

  • The nonlinear properties it provides are not well-researched compared to other operations.

  • It is a complex and slow function, and cryptographers often prefer many simple and fast functions.

  • Unless done in a finite field, it is impossible to reverse the operation (which is often useful).


If you loosen your requirements, then the Rabin cryptosystem may fit the bill. It's an asymmetric cipher and is very similar to RSA, but with the public exponent fixed to $2$. This means that decryption involves computing modular square roots. It's very possible that there is other asymmetric cryptography which makes use of square root operations, but I can't think of any off the top of my head.

If you can expand your requirements to any $n^\text{th}$-root operations, then the broken KN-Cipher from 1995 may be relevant. Its round function is based on the cube root operation in $\operatorname{GF}(2^{33})$. Computing cube roots is also a simpler and faster process than computing square roots.

$\endgroup$
4
  • $\begingroup$ Nothing inherently wrong with floating-point sqrt as a reliably computed function from bit strings to bit strings! It's one of the mandatory correctly rounded IEEE 754 operations. (But its cryptographic value is limited.) $\endgroup$ – Squeamish Ossifrage Apr 8 '19 at 19:21
  • $\begingroup$ Yes of course and there is no "decryption" by square roots :-) $\endgroup$ – kodlu Apr 8 '19 at 20:31
  • 2
    $\begingroup$ @PaulUszak I'm not talking about IEEE floating point. And your statement is incorrect. $\forall x$ means for all $x$, but it's easy to create an $x$ whose square root is the same regardless of the bus width (e.g. $x=64$). $\endgroup$ – forest Apr 9 '19 at 0:19
  • $\begingroup$ Well spotted - lazy copy & paste. $\endgroup$ – Paul Uszak Apr 9 '19 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.