Lattice Klepto: Turning Post-Quantum Crypto Against Itself
Lattice Klepto: Turning Post-Quantum Crypto Against Itself
1 Introduction
The attacks studied in cryptanalysis can typically be classified into mathemat-
ical, algorithmic attacks and side-channel attacks. The former tries to tackle
the hard problem the system is based on or to find ways to circumvent the
hard problem altogether; the latter uses information gathered during execution
of algorithms (possibly after introducing faults or cache flushes) to learn secret
information. Typically the analysis assumes that the attacker has full knowledge
of the algorithm implemented and typically also of the implementation itself.
In the mid 90’s, Young and Yung invented [15,16,17] the concept of Cryptovi-
rology or Kleptography and studied how easily systems lend themselves to being
backdoored. Their setups typically include a black-box implementation whose
output should be indistinguishable from the output of a legitimate implementa-
tion for anybody but the owner of the backdoor key. The klepto implementation
of a regular algorithm leaks (parts of) the secret message, a private key, or the
This work was supported by the European Communities through the
Horizon 2020 program under project number 645622 (PQCRYPTO) and
project number 645421 (ECRYPT-CSA). Permanent ID of this document:
e14bc1779799664cf160742e72d7fa50. Date: 2017.08.11.
2 Robin Kwant, Tanja Lange, and Kimberley Thissen
– exclusivity,
– indistinguishability, and
– forward secrecy.
This implies that the backdoor encryption must use a public-key system and
that only the public part of the backdoor key is stored on the device.
The study of kleptopgraphy has gained topicality in the wake of the Snowden
revelations which mention “subversion of standards” as one of the targets of NSA
and news articles [13] strongly indicating that the elliptic-curve based random-
number generator DualEC [10] was designed with a backdoor. This backdoor
is closely related to the “repeated DH Setup” by Young and Yung. Subsequent
research has shown that this backdoor can be exploited in the wild [2] in TLS
implementations and turned up more evidence about the origin [1] of DualEC
and how it got incorporated into standards.
While the overall lesson is clear: do not accept black-box implementations
of cryptographic algorithms and request justification for all choices made, the
power of klepto schemes differs noticeably between RSA, finite field DH, and
elliptic-curve cryptography (ECC). The most powerful backdoor against RSA
produces keys that are indistinguishable from random keys but include an ECC-
based encryption to a backdoor key of the same cryptographic security as the
RSA key that allows instant factorization [18].
This raises the question how other public-key schemes can be turned into
kleptographic schemes. Post-quantum cryptography has received a lot of interest
in recent years and NIST calls for submissions of post-quantum algorithms by the
end of 2017. So far schemes have been evaluated purely for security, functionality,
speed, and at best for implementation security (side-channel countermeasures).
We are not aware of any study of kleptographic attacks against these schemes.
This paper studies lattice-based encryption, in particular the NTRU [7] fam-
ily of encryption schemes and signature schemes and shows how to turn them
into klepto schemes with an ECC-based backdoor.
2 Background
This section briefly describes the NTRU encryption system and fixes parameters
for our klepto scheme. For the NTRU encryption scheme we follow the original
NTRU paper [7].
Lattice Klepto 3
2.1. Background on Kleptography. Young and Yung call their the core of
their klepto schemes a SETUP. SETUP is an abbreviation of “Secretly Embed-
ded Trapdoor with Universal Protection”.
Definition 2.1 (SETUP). Let S be a publicly known cryptosystem. A SETUP
mechanism is an algorithmic modification made to S to get S 0 such that:
The parameters (df , dg , dr ) specify the sets (Lf , Lg , Lr , Lm ), which are sets
of polynomials of degree at most N − 1 with a fixed number of (small) nonzero
coefficients. Concrete parameter choices are included in Table 5.1.
Definition 2.2 (Message space). The message space Lm is defined as
The key and randomness spaces (Lf , Lg , andLr ) are defined as:
Lf = L(df , df − 1)
Lg = L(dg , dg )
Lr = L(dr , dr )
c ≡ p · r ~ h + m mod q, (3)
is computed.
2.7. NTRU decryption. To obtain message m, first the quantity a ≡ f ~
c mod q is computed. Because
a ≡ f ~ (p · r ~ h + m) ≡ f ~ (p · r ~ Fq ~ g + m) ≡ p · r ~ g + f ~ m mod q, (4)
PN −1
Definition 2.4 (Width). Let l = i=0 li X i ∈ R. The width of l is defined as
c0 = c + k · p, (5)
0
with k a polynomial in R with coefficients in Zρ such that c ≡ C mod ρ. This
polynomial k can be obtained by solving the integer equation Ci ≡ ci +ki ·p mod ρ
for every coefficient of k. Having the gcd(ρ, p) = 1 by definition, ensures the
existence of these solutions.
3.3. Decryption by the attacker. The attacker reduces c0 mod ρ and recovers
the polynomial C, since C ≡ c0 mod ρ. The attacker interprets C as a bitstring
and decrypts it with his private key (as in Section 2.3) to obtains the leaked
information.
Lattice Klepto 7
a0 ≡ f ~ (p · k + p · r ~ h + m)
≡ f ~ (p · k + p · r ~ Fq ~ g + m) (6)
≡ p · k ~ f + p · r ~ g + f ~ m mod q,
reducing a0 modulo p still yields f ~ m if the coefficients are not too large (see
the comment on decryption failures above). Thus m ≡ a0 ~ Fp mod p.
T = p · k ~ f + p · r ~ g + f ~ m,
has a width larger than q, as generally |T |∞ > |S|∞ . Because for a single coeffi-
cient of T it applies that
X
Tl = Sl + p · ki · fj ,
i+j≡l mod N
5 Practical implementation
Parameters
# keys # trials per key # failures
N pq df dg dr
20000 1 0
613 3 2048 55 204 55
100 10000 0
10000 1 0
887 3 2048 81 295 81
100 10000 0
5000 1 0
1171 3 2048 106 390 106
100 10000 0
|S|∞ |T |∞
µ 164.0471 190.7234
σ 13.81889 15.95371
min 116 139
max 251 294
Fig. 5.1. (N, p, q, df , dg , dr ) = (613, 3, 2048, 55, 204, 55), 10 keys, 10000 trials per key.
than the |S|∞ values. This phenomena gives rise to some questions explained in
Section 10.2.
6 Countermeasures
There are ways to find out that the ciphertext was tampered with. One of those
being the recovery of the randomness. From Equation (3) we obtain
c − m = r ~ h mod q,
r = (c − m) ~ h−1 mod q
|S|∞ |T |∞
µ 163.9682 190.6541
σ 13.79992 15.95437
min 117 140
max 257 300
Fig. 5.2. (N, p, q, df , dg , dr ) = (613, 3, 2048, 55, 204, 55), 100 keys, 10000 trials per key
|S|∞ |T |∞
µ 206.3269 239.786
σ 16.43092 18.94655
min 157 182
max 298 358
Fig. 5.3. (N, p, q, df , dg , dr ) = (887, 3, 2048, 81, 295, 81), 10 keys, 10000 trials per key.
7.3. Encryption. Bob takes the secret message M , generates C, uses the func-
tion φ to map C to an element r ∈ Lr and encrypts m by computing c using
Equation (3) with this choice of r. Bob now sends c to Alice.
7.4. Decryption. Alice receives c and recovers m using Equation (4). She now
computes h−1 and uses this to recover r ≡ (c−m)~h−1 mod q. She now recovers
C as the preimage of r using φ−1 . For efficiency it is possible to precompute h−1 .
7.5. Encoding messages. In this section an example for the injective map
φ mentioned earlier is described. It is somewhat similar to Algorithm 2.2 in
[12]. Let C,the encryption of ahmessage M , be represented
i as a unique number
chosen in the discrete interval 0, dNr · N d−d
r
r
− 1 . Then φ is an injective map
h i
0, dNr · N d−d
r
r
− 1 → Lr that encodes an encrypted message C to an r ∈ Lr .
The inverse φ−1 gives preimage C from the image r.
The set Lr can be represented as a tree, with every level representing one
coefficient. We now describe how this tree is constructed, see Figure 7.1 for a
visualization. The root is defined as representing r0 , the level of the leaves rn .
Every leaf corresponds to a unique element of Lr , and is defined by the unique
path from the root to the leaf. Every node has at most 3 branches depending on
whether it can still be completed, because left and right branches are limited:
The leftmost branch corresponds to choosing a −1, the middle branch a 0 and
the right branch a 1 on that level. Now the set Lr can be indexed by counting
the leaves from left to right, where the leftmost leaf has index 0.
Lattice Klepto 13
|S|∞ |T |∞
µ 242.3299 281.6776
σ 18.47012 21.31923
min 182 218
max 365 435
Fig. 5.4. (N, p, q, df , dg , dr ) = (1171, 3, 2048, 106, 390, 106), 10 keys, 10000 trials per
key
7.6. Why does it work?. As pointed out in Section 6 the randomness r can
be recovered by the receiver if g is chosen to be invertible. This phenomenon is
exploited by putting a message in r rather than choosing r randomly.
This subliminal channel changes the choice of r to being deterministic in C
but does not change the range for r, hence it does not introduce any extra de-
cryption errors and is completely undetectable from the observable distribution,
even to Eve who obtained the NTRU key. For properly chosen elliptic curves, C
is indistinguishable from random bitstrings and thus r is indistinguishable from
a randomly chosen element from Lr .
8 pqNTRUSign
This section briefly describes pqNTRUSign, also known as NTRU-MLS, which
is short for NTRU Modular Lattice Signature. For this we follow the original
paper [6] from PQCrypto 2014. Though other NTRU signature schemes, such as
NSS [8] and NTRUSign [5], have been broken, this scheme has no known attacks
against the currently proposed parameters.
8.1. pqNTRUSign parameters. The signature scheme works in NTRU lat-
tices, so the set up is very similar to NTRU (Section 2.4). pqNTRUSign is
specified by five parameters, the integers (N, p, q, Bs , Bt ), where gcd(p, q) = 1,
q is much larger than p and Bs and Bt are some bounds on the norms of some
elements; typically p = 3 and q has 15 or more bits. Similar to NTRU, all com-
putations take place in the ring R = Z[X]/(X N − 1) and polynomials are often
reduced modulo q or p. Unlike NTRU, only the size of the polynomial coefficients
is limited but there is no limit on the number of non-zero coefficients. We write
Rp to denote elements of R with coefficients in Zp ; we consider elements auto-
matically lifted to Z using integers in (−p/2, p/2]; all integer modular reductions
are made explicit.
Lattice Klepto 15
details see Section 2.3). As in the NTRU backdoor we choose reduction modulo
2 because the typical choice of p is 3 which is coprime to 2 and larger moduli
increase the chance of resampling.
The most obvious target to leak in a signature scheme is the signing key.
In pqNTRUSign this would be F ∈ R3 , needing bN log2 3c + 1 bits in optimal
packing. Alternatively, an evil implementer could point to the importance of
short secret keys and generate F deterministically from a short random seed
that can be leaked in a shorter message.
Unlike in NTRU we will not be able to transmit N bits at once but only a
small number (in order to keep resampling rates acceptable). This means that C
needs to be transmitted over multiple signatures and then concatenated at the
receiver end. The GCM part of the encryption then also serves as a check for
correctness. In the following, C will be a ciphertext to be leaked, encoded as a
binary polynomial of degree less than d ≤ N .
In line with the paper topic we chose to exploit the flexibility in random
choices for a klepto scheme but would like to point out that it could as well be
used as a subliminal channel to hide encrypted messages. Because the signer can
validate the signature himself there no distinction between the capacity of the
klepto/covert channel and the subliminal channel.
There are no modification to the key generation or verification algorithm
and the owner of the klepto backdoor obtains and deciphers the ciphertext as
for NTRU (apart from sorting and arranging partial ciphertexts).
9.2. Modified signature. To avoid too many rejections we will now modify
the signature generation. As a warm up put d = 1, i.e. we will leak 1 bit.
Changing s to s0 = s + p, i.e., adding p to the constant will change the
parity of the constant but not affect s ≡ sp mod p. This change implies choosing
s00 = s0 + p instead of s0 and r0 = r + 1 instead of r which only minimally affects
the distribution of the randomness. There is a minimal chance that s will violate
Bs if s was valid.
However, t ≡ h ~ s mod q may no longer hold. If t00 ≡ s00 ~ h ≡ s0 ~ h +
ph mod q equals t0 modulo p, i.e., t0 had small enough coefficients that adding
ph did not cause a reduction in it, then a0 = a and verification will work for
t0 = t00 + a ~ g and s0 (provided that they also satisfy Bs and Bt ). Note that
h is a full-size polynomial, i.e. its coefficients can range over the full interval
(−q/2, q/2], and the equivalence has to hold in all N coefficients. If either of
these checks fails, a possible fix is to use s0 = s − p instead, otherwise a new r
needs to be sampled.
Lattice Klepto 17
Pd−1 Pd−1
Now let c(X) = i=0 ci X i ∈ R2 for some larger d and let k(X) = i=0 ki X i
with ki ∈ {0, ±1} such that s0 = s + pk ≡ c mod 2 on the bottom d coefficients.
As for NTRU this is possible because gcd(2, p) = 1. Then r0 = r + k and
s00 = s0 + pk, which still likely pass the size test for s since p is much smaller
than q.
However, for increasing d, t00 ≡ t0 + ph ~ k mod q will increasingly likely
invoke a reduction modulo q when adding ph ~ k.
Again we can vary the sign on the ki to reduce the size of h ~ k mod q.
For small d this can be done exhautively to find the minimum and for larger d
randomizing signs to reach roughly as many +1 as −1 seems beneficial.
A final optimization is to skip validity tests on (s, t) before including the
backdoor and choosing signs in k such that (s0 , t0 ) is smaller.
We plan on providing experimental results in the very near future to deter-
mine acceptable rejection rates and good sizes for d.
10 Final Remarks
As shown in Sections 3, 7, and 9 it is feasible and practical to modify NTRU
and pqNTRUSign in such a way that they contains a backdoor or subliminal
channel. Countermeasures against the NTRU backdoor have been described in
Section 6.
10.1. Minimization of decryption failures. In Section 4 some optimizations
have been given in order to reduce the increased probability of decryption failures
with the backdoor added. In Section 5 some experimental results are given. By
doing more experiments and with more parameter sets, the increased probability
of decryption failures might be estimated and parameters can be selected which
allow for more information to be leaked without increasing the failure probability
too much. Research can also be done to find the theoretical probability instead of
an estimation. With this estimation parameters can be computed that preserve
global security, but at the same time minimize the probability of decryption
failures.
10.2. Statistical countermeasures. In Section 5 experimental results were
given on the width of the polynomial T with respect to the width of S. These
results showed that the width of T is less predictable but still small. The stan-
dard deviation was larger for the values of T . This occurs because adding an
extra message to the ciphertext means adding some randomness. This yields the
question, whether a receiver of messages could distinguish the ones that were
tampered with from the ones that were not and alert the sender? How many
messages would it need to be able to do so? These are questions that might be
worthwhile looking into.
10.3. Potential biases in pqNTRUSign klepto signatures. The result of
the modified signatures of the pqNTRUSign scheme in Section 9 could poten-
tially be biased as the random generation is influenced. If the user would collect
a set of signatures generated by this black box algorithm, it will likely show that
18 Robin Kwant, Tanja Lange, and Kimberley Thissen
the signatures are not as random as the user would expect. This behavior could
be analyzed.
10.4. Further research. For backdoors in NTRUSign [5] and NSS [8] see
the thesis by Kimberley Thissen http://repository.tue.nl/854465. For full
details and further considerations on NTRU see the thesis by Robin Kwant
http://repository.tue.nl/854433.
References
1. Daniel J. Bernstein, Tanja Lange, and Ruben Niederhagen. Dual EC: A stan-
dardized back door. In Peter Y. A. Ryan, David Naccache, and Jean-Jacques
Quisquater, editors, The New Codebreakers - Essays Dedicated to David Kahn on
the Occasion of His 85th Birthday, volume 9100 of Lecture Notes in Computer
Science, pages 256–281. Springer, 2016.
2. Stephen Checkoway, Ruben Niederhagen, Adam Everspaugh, Matthew Green,
Tanja Lange, Thomas Ristenpart, Daniel J. Bernstein, Jake Maskiewicz, Hovav
Shacham, and Matthew Fredrikson. On the practical exploitability of dual EC in
TLS implementations. In Kevin Fu and Jaeyeon Jung, editors, Proceedings of the
23rd USENIX Security Symposium, San Diego, CA, USA, August 20-22, 2014.,
pages 319–335. USENIX Association, 2014.
3. The Sage Developers. SageMath, the Sage Mathematics Software System, 2017.
http://www.sagemath.org.
4. Philip S. Hirschhorn, Jeffrey Hoffstein, Nick Howgrave-Graham, and William
Whyte. Choosing NTRUEncrypt parameters in light of combined lattice reduc-
tion and MITM approaches. In Michel Abdalla, David Pointcheval, Pierre-Alain
Fouque, and Damien Vergnaud, editors, Applied Cryptography and Network Secu-
rity, 7th International Conference, ACNS 2009, Paris-Rocquencourt, France, June
2-5, 2009. Proceedings, volume 5536 of Lecture Notes in Computer Science, pages
437–455, 2009.
5. Jeffrey Hoffstein, Nick Howgrave-Graham, Jill Pipher, Joseph H. Silverman, and
William Whyte. NTRUSIGN: digital signatures using the NTRU lattice. In Marc
Joye, editor, Topics in Cryptology - CT-RSA 2003, The Cryptographers’ Track the
RSA Conference 2003, San Francisco, CA, USA, April 13-17, Proceedings, volume
2612 of Lecture Notes in Computer Science, pages 122–140. Springer, 2003.
6. Jeffrey Hoffstein, Jill Pipher, John M. Schanck, Joseph H. Silverman, and William
Whyte. Transcript secure signatures based on modular lattices. In Michele Mosca,
editor, Post-Quantum Cryptography - 6th International Workshop, PQCrypto
2014, Waterloo, ON, Canada, October 1-3, 2014. Proceedings, volume 8772 of Lec-
ture Notes in Computer Science, pages 142–159. Springer, 2014.
7. Jeffrey Hoffstein, Jill Pipher, and Joseph H. Silverman. NTRU: A ring-based
public key cryptosystem. In Joe Buhler, editor, Algorithmic Number Theory, Third
International Symposium, ANTS-III, Portland, Oregon, USA, June 21-25, 1998,
Proceedings, volume 1423 of Lecture Notes in Computer Science, pages 267–288.
Springer, 1998.
8. Jeffrey Hoffstein, Jill Pipher, and Joseph H. Silverman. NSS: an NTRU lattice-
based signature scheme. In Birgit Pfitzmann, editor, Advances in Cryptology -
EUROCRYPT 2001, International Conference on the Theory and Application of
Cryptographic Techniques, Innsbruck, Austria, May 6-10, 2001, Proceeding, volume
2045 of Lecture Notes in Computer Science, pages 211–228. Springer, 2001.
Lattice Klepto 19
9. Jeffrey Hoffstein, Jill Pipher, William Whyte, and Zhenfei Zhang. pqNTRUSign:
update and recent results, 2017. http://2017.pqcrypto.org/conference/
slides/recent-results/zhang.pdf.
10. National Institute of Standards and Technology. Special Publication 800-90:
Recommendation for random number generation using deterministic random bit
generators, 2012. First version June 2006, second version March 2007, http:
//csrc.nist.gov/publications/PubsSPs.html#800-90A.
11. National Security Agency. Suite B cryptography / cryptographic interoperability,
2005. https://web.archive.org/web/20150724150910/https://www.nsa.gov/
ia/programs/suiteb_cryptography/.
12. Raphael Overbeck and Nicolas Sendrier. Code-based cryptography. In Daniel J.
Bernstein, Johannes Buchmann, and Erik Dahmen, editors, Post-Quantum Cryp-
tography, pages 95–145. Springer, Berlin, 2008.
13. Nicole Perlroth, Jeff Larson, and Scott Shane. N.S.A. able to foil basic safeguards
of privacy on web. International New York Times, September 2013. http://www.
nytimes.com/2013/09/06/us/nsa-foils-much-internet-encryption.html.
14. Gustavus J. Simmons. Subliminal channels; past and present. European Transac-
tions on Telecommunications, 5(4):459–474, 1994.
15. Adam L. Young and Moti Yung. Cryptovirology: Extortion-based security threats
and countermeasures. In 1996 IEEE Symposium on Security and Privacy, May
6-8, 1996, Oakland, CA, USA, pages 129–140. IEEE Computer Society, 1996.
16. Adam L. Young and Moti Yung. Kleptography: Using cryptography against cryp-
tography. In Walter Fumy, editor, Advances in Cryptology - EUROCRYPT ’97,
International Conference on the Theory and Application of Cryptographic Tech-
niques, Konstanz, Germany, May 11-15, 1997, Proceeding, volume 1233 of Lecture
Notes in Computer Science, pages 62–74. Springer, 1997.
17. Adam L. Young and Moti Yung. Malicious cryptography - exposing cryptovirology.
Wiley, 2004.
18. Adam L. Young and Moti Yung. Kleptography from standard assumptions and
applications. In Juan A. Garay and Roberto De Prisco, editors, Security and
Cryptography for Networks, 7th International Conference, SCN 2010, Amalfi, Italy,
September 13-15, 2010. Proceedings, volume 6280 of Lecture Notes in Computer
Science, pages 271–290. Springer, 2010.