Skip to main content

On Constant-Time QC-MDPC Decoders with Negligible Failure Rate

  • Conference paper
  • First Online:
Code-Based Cryptography (CBCrypto 2020)

Abstract

The QC-MDPC code-based KEM Bit Flipping Key Encapsulation (BIKE) is one of the Round-2 candidates of the NIST PQC standardization project. It has a variant that is proved to be IND-CCA secure. The proof models the KEM with some black-box (“ideal”) primitives. Specifically, the decapsulation invokes an ideal primitive called “decoder”, required to deliver its output with a negligible Decoding Failure Rate (DFR). The concrete instantiation of BIKE substitutes this ideal primitive with a new decoding algorithm called “Backflip”, that is shown to have the required negligible DFR. However, it runs in a variable number of steps and this number depends on the input and on the key. This paper proposes a decoder that has a negligible DFR and also runs in a fixed (and small) number of steps. We propose that the instantiation of BIKE uses this decoder with our recommended parameters. We study the decoder’s DFR as a function of the scheme’s parameters to obtain a favorable balance between the communication bandwidth and the number of steps that the decoder runs. In addition, we build a constant-time software implementation of the proposed instantiation, and show that its performance characteristics are quite close to the IND-CPA variant. Finally, we discuss a subtle gap that needs to be resolved for every IND-CCA secure KEM (BIKE included) where the decapsulation has nonzero failure probability: the difference between average DFR and “worst-case” failure probability per key and ciphertext.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    This decoder appears in the pre-Round-1 submission “CAKE” (the BIKE-1 ancestor). It is due to N. Sendrier and R. Misoczki. The decoder was adapted to use the improved thresholds published in [3].

  2. 2.

    Theorems 3.1 and 3.4 appear only in the ePrint version [13] of [12]. In [12] they appear as Theorems 1 and 4, respectively.

  3. 3.

    In BIKE-1, the secret key (sk) and public key (pk) are h and f, respectively.

  4. 4.

    In BIKE-1, \(n=2r\), the parity-check matrix H is formed by the two circulant blocks \((h_0, h_1)\), the vectors c, e, and f are defined as \(c=(c_0,c_1)\), \(e=(e_0,e_1)\), and \(mf=(m \cdot f_0,m \cdot f_1)\).

  5. 5.

    See discussion with some extrapolation methodologies in Appendix C.

  6. 6.

    Recall that different decoders have different definition for the term “iterations”, see Sect. 2.3.

  7. 7.

    Here, KEM\(^{\not \perp }\) refers to a KEM with implicit rejection, and qG is the number of invocation of the random oracle G (H in the case of BIKE-1).

  8. 8.

    Our definition of weak keys is different form that of [4], where a weak key is a secret key that can be exposed from the public key alone.

  9. 9.

    The recommendations given here are the opinion of the authors of this paper.

  10. 10.

    BIKE specification [3, Section 2.4.5] states: “An interesting consequence is that if w and t are fixed, a moderate modification of r (say plus or minus \(50\%\)) will not significantly affect the resistance against the best known key and message attacks”.

References

  1. C library for quantum-safe cryptography (2019). https://github.com/open-quantum-safe/liboqs/pull/554

  2. Melchor, C.A., et al.: Hamming Quasi-Cyclic (HQC) (2017). https://pqc-hqc.org/doc/hqc-specification_2017-11-30.pdf

  3. Aragon, N., et al.: BIKE: Bit Flipping Key Encapsulation (2017). https://bikesuite.org/files/round2/spec/BIKE-Spec-2019.06.30.1.pdf

  4. Bardet, M., Dragoi, V., Luque, J.G., Otmani, A.: Weak keys for the quasi-cyclic MDPC public key encryption scheme. In: Pointcheval, D., Nitaj, A., Rachidi, T. (eds.) AFRICACRYPT 2016. LNCS, vol. 9646, pp. 346–367. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-31517-1_18

    Chapter  Google Scholar 

  5. Chaulet, J., Sendrier, N.: Worst case QC-MDPC decoder for McEliece cryptosystem. In: 2016 IEEE International Symposium on Information Theory (ISIT), pp. 1366–1370 (2016). https://doi.org/10.1109/ISIT.2016.7541522

  6. Drucker, N., Gueron, S.: A toolbox for software optimization of QC-MDPC code-based cryptosystems. J. Cryptogr. Eng. 9(4), 341–357 (2019). https://doi.org/10.1007/s13389-018-00200-4

    Article  Google Scholar 

  7. Drucker, N., Gueron, S.: Additional implementation of BIKE (2019). https://bikesuite.org/additional.html

  8. Eaton, E., Lequesne, M., Parent, A., Sendrier, N.: QC-MDPC: a timing attack and a CCA2 KEM. In: Lange, T., Steinwandt, R. (eds.) PQCrypto 2018. LNCS, vol. 10786, pp. 47–76. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-79063-3_3

    Chapter  Google Scholar 

  9. Fujisaki, E., Okamoto, T.: Secure integration of asymmetric and symmetric encryption schemes. In: Wiener, M. (ed.) CRYPTO 1999. LNCS, vol. 1666, pp. 537–554. Springer, Heidelberg (1999). https://doi.org/10.1007/3-540-48405-1_34

    Chapter  Google Scholar 

  10. Gallager, R.: Low-density parity-check codes. IRE Trans. Inf. Theory 8(1), 21–28 (1962). https://doi.org/10.1109/TIT.1962.1057683

    Article  MathSciNet  MATH  Google Scholar 

  11. Guo, Q., Johansson, T., Stankovski, P.: A key recovery attack on MDPC with CCA security using decoding errors. In: Cheon, J.H., Takagi, T. (eds.) ASIACRYPT 2016. LNCS, vol. 10031, pp. 789–815. Springer, Heidelberg (2016). https://doi.org/10.1007/978-3-662-53887-6_29

    Chapter  Google Scholar 

  12. Hofheinz, D., Hövelmanns, K., Kiltz, E.: A modular analysis of the Fujisaki-Okamoto transformation. In: Kalai, Y., Reyzin, L. (eds.) TCC 2017. LNCS, vol. 10677, pp. 341–371. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-70500-2_12

    Chapter  MATH  Google Scholar 

  13. Hofheinz, D., Hövelmanns, K., Kiltz, E.: A modular analysis of the Fujisaki-Okamoto transformation. Cryptology ePrint Archive, Report 2017/604 (2017). https://eprint.iacr.org/2017/604

  14. Maurich, I.V., Oder, T., Güneysu, T.: Implementing QC-MDPC McEliece encryption. ACM Trans. Embed. Comput. Syst. 14(3), 44:1–44:27 (2015). https://doi.org/10.1145/2700102. http://doi.acm.org/10.1145/2700102

    Article  Google Scholar 

  15. Nilsson, A., Johansson, T., Wagner, P.S.: Error amplification in code-based cryptography. IACR Trans. Cryptogr. Hardw. Embed. Syst. 1, 238–258 (2019). https://doi.org/10.13154/tches.v2019.i1.238-258

    Article  Google Scholar 

  16. NIST: Post-Quantum Cryptography (2019). https://csrc.nist.gov/projects/post-quantum-cryptography. Accessed 20 Aug 2019

  17. Gaudry, P., Brent, R.P.Z., Thome, E.: gf2x-1.2 (2017). https://gforge.inria.fr/projects/gf2x/

  18. Samardjiska, S., Santini, P., Persichetti, E., Banegas, G.: A reaction attack against cryptosystems based on LRPC codes. In: Schwabe, P., Thériault, N. (eds.) LATINCRYPT 2019. LNCS, vol. 11774, pp. 197–216. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-30530-7_10

    Chapter  Google Scholar 

  19. Santini, P., Battaglioni, M., Chiaraluce, F., Baldi, M.: Analysis of reaction and timing attacks against cryptosystems based on sparse parity-check codes. In: Baldi, M., Persichetti, E., Santini, P. (eds.) CBC 2019. LNCS, vol. 11666, pp. 115–136. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-25922-8_7

    Chapter  Google Scholar 

  20. Sendrier, N., Vasseur, V.: On the decoding failure rate of QC-MDPC bit-flipping decoders. In: Ding, J., Steinwandt, R. (eds.) PQCrypto 2019. LNCS, vol. 11505, pp. 404–416. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-25510-7_22

    Chapter  Google Scholar 

  21. Shoup, V.: Number theory C++ library (NTL) version 11.3.4 (2019). http://www.shoup.net/ntl

  22. Wafo-Tapa, G., Bettaieb, S., Bidoux, L., Gaborit, P.: A practicable timing attack against HQC and its countermeasure. Technical report 2019/909 (2019). https://eprint.iacr.org/2019/909

Download references

Acknowledgments

This research was partly supported by: NSF-BSF Grant 2018640; The BIU Center for Research in Applied Cryptography and Cyber Security, and the Center for Cyber Law and Policy at the University of Haifa, both in conjunction with the Israel National Cyber Directorate in the Prime Minister’s Office.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Nir Drucker .

Editor information

Editors and Affiliations

Appendices

A Black-Gray Decoder

figure m

B Implementing Backflip\(^+\) in Constant-Time

Here, we show how to define and implement a constant-time Backflip\(^+\) decoder, based on a constant-time Black-Gray decoder. The Backflip\(^+\) decoder differs from the Black-Gray decoder in two aspects: a) it uses a new mechanism called TTL; b) it uses new equations for calculating the thresholds. The TTL mechanism is a “smart queue” where the decoder flips back some error bits when it believes that they were mistakenly flipped in previous iterations. It does so unconditionally and it can flip bits even after 5 iterations. The Black-Gray decoder uses a different type of TTL, where the black and gray lists serve as the “smart queue”. However, the error bits are flipped back after only 1 iteration, conditionally, through checking certain thresholds. Indeed, as we report below the differences are observed in cases where the Black-Gray decoder failed to decode after 4 iterations and then w.h.p fails completely. The Backflip decoder shows better recovery capabilities in such cases. Implementing the new TTL queue in constant-time relies mostly on common constant-time techniques.

Handling the New Threshold Function. The Backflip decoder thresholds are a function of two variables [3][Section 2.4.3]: a) the syndrome weight wt(s) as in the Black-Gray decoder; b) the number of error bits that the decoder believes it flipped (denoted \(\bar{e}\)). This function outputs higher thresholds compared to the Black-Gray decoder. This is a conservative approximation. We believe that the design of the Backflip decoder tends to avoid flipping the “wrong” bits so that the decoder would have better recovery capabilities and a lower DFR (assuming that it can execute an un-bounded number of iterations). We point out that evaluating the function involves computing logarithms, exponents, and function minimization, and it is not clear how this can be implemented in constant-time (the reference code [3] is not implemented in constant-time).

One way to address this issue is to pre-calculate the finite number of pairs \((wt(s), \bar{e})\) and their function evaluation, store them in a table, and read them from the table in constant-time. This involves very high latencies.

Similarly to the Black-Gray decoder (in BIKE-1-CPA [3]), we approximate the thresholds function - which is here a function of two variables. A first attempt is shown in Fig. 4. We compute the function over all the valid/relevant inputs and then compute an approximation by fitting it to a plane. Unfortunately, this approximation is not sufficiently accurate, an experiment with \(r=11,779\) (as in BIKE-1-CCA [3]) gave an estimated DFR of \(10^{-4}\) .

Fig. 4.
figure 4

Approximating the Backflip decoder thresholds function.

To improve the approximation we project the function onto the plane \(\bar{e}=e1\) (\(0 \le e1 \le t\)). Then, for every valid e1, we compute the linear approximation and tabulate the coefficients. Figure 5, Panel (a) illustrates the linear approximation for \(e1=25\). These thresholds improve the DFR but it is still too high.

A refinement can be obtained by partitioning the approximation into five regions. The projection graph in Fig. 5 can be partitioned in five intervals as follows: a) \([a_0,a_1]\), \([a_2,a_3]\), where the threshold is fixed to some minimum value (min); b) \([a_4,a_5]\) where the threshold is d; c) \([a_1, a_2]\) and \([a_3, a_4]\) where the threshold (th) is approximated using \(th = b_0 wt(s) + b_1\) and \(th = c_0 wt(s) + c_1\), respectively. For \(r=11,779\) the values we use are \(a_0=0\), \(a_1=1,578\), \(a_2=1,832\) \(a_3=3,526\), \(a_4=9,910\) \(a_5=r\). The results is shown Fig. 5 Panel (b) for \(\bar{e}=25\). We use these values to define the table (T) with t rows and 8 columns. Every row contains the \(a_1\), \(a_2\), \(a_3\), \(a_4\), \(b_0\), \(b_1\), \(c_0\), \(c_1\) values that correspond to the projection on the plane \(\bar{e}\).

Fig. 5.
figure 5

Approximating the threshold function when \(\bar{e}=25\) is fixed.

For every \((s1,e1) = (wt(s),\bar{e})\) the threshold is computed by

figure n

To evaluate the thresholds in constant-time we used a constant-time function that compares two integers jk and returns the mask if \(j<k\) and the mask otherwise. The threshold computation is now:

figure r

With this we can implement Backflip\(^+\) in constant-time, provided that we fix a-priori the number of iterations.

C Achieving the Same DFR Bounds as of [20]

We ran experiments with Backflip\(^+\) and \(X_{BF}=100\) for BIKE-1 Level-1, scanning all the 34 legitimate \(r \in [8500,9340]\) (prime r values such that \(x^r - 1\) is a primitive polynomial) with 4.8M tests for every value. Applying our extrapolation methodology (see Sect. 4) to the acquired data leads to the results illustrated in Fig. 6 Panels (a) and (b). The figure highlights the pairs (DFR; r) for DFR \(2^{-64}\) and \(2^{-128}\) with the smallest possible r. For example, with \(r=12,539\) the linear extrapolation gives DFR of \(2^{-128}\). Note that [3] claims a DFR of \(2^{-128}\) for a smaller \(r=11,779\). For comparison, with \(r=11,779\) our methodology gives a DFR of \(2^{-104}\). We can guess that either different TTL values were used for every r, or that other r values were used, or that a different extrapolation methodology was applied.

We show one possible methodology (“Last-Linear”) that gives a DFR of \({\sim }2^{-128}\) with \(r=11,779\) when applied to the acquired data: a) Ignore the points from the data-set for which \(100-\)DFR is too low to be calculated reliably (e.g., the five lower points in Fig. 6); b) Draw a line through the last two remaining data points with the highest values of r. The rationale is that the “linear regime” of the DFR evolution starts for values of r that are beyond those that can be estimated in an experiment. Thus, a line drawn through two data points where r is smaller than the starting point of the linear regime leads to an extrapolation that is lower-bounded by the “real” linear evolution. With this approach, the question is how to choose the two points for which experimental data is obtained and the DFR is extrapolated from.

This shows that different ways to acquire and interpret the data give different upper bounds for the DFR. Since the extrapolation shoots over a large gap of r values, the results are sensitive to the chosen methodology. It is interesting to note that if we take our data points for Black-Gray and \(X_{BG}=5\) and use the Last-Linear extrapolation, we can find two points that would lead to \(2^{-128}\) and \(r=11,779\), while more conservative methodology gives only \(2^{-101}\).

Fig. 6.
figure 6

BIKE-1 Level-1 Backflip\(^+\) different extrapolation methods. See the text for details. The sub-captions detail the (DFR; r) for DFR values: \(2^{-64}\), \(2^{-128}\).

D Additional Information

The following values of r were used by the extrapolation method:

  • BIKE-1 Level-1: 9349, 9547, 9749, 9803, 9859, 9883, 9901, 9907, 9923, 9941, 9949, 10037, 10067, 10069, 10091, 10093, 10099, 10133, 10139.

  • BIKE-1 Level-3: 19013, 19037, 19051, 19069, 19141, 19157, 19163, 19181, 19219, 19237, 19259, 19301, 19333, 19373, 19387, 19403, 19427, 19469, 19483, 19507, 19541, 19571, 19597, 19603, 19661, 19709, 19717, 19739, 19763, 19813, 19853.

E The Linear and the Quadratic Extrapolations

Table 4 gives the equations for the linear and the quadratic extrapolation together with the extrapolated values of r for a DFR of \(2^{-23}\), \(2^{-64}\), and \(2^{-128}\). It covers the tuple (scheme, level, decoder, X), where decoder \(\in \) {BG=Black-Gray, BF=Backflip\(^+\)}.

The BIKE specification [3] chooses r to be the minimum required for achieving a certain security level, and the best bandwidth trade-off. It also indicates that it is possible to increase r by “plus or minus \(50\%\)” (leaving w, t fixed) without reducing the complexity of the best known key/message attacks. This is an interesting observation. For example, increasing the BIKE-1 Level-3 \(r=19,853\) by \(50\%\) gives \(r=29,779\) which is already close to the BIKE-1 Level-5 that has \(r=32,749\) (of course with different w and t). We take a more conservative approach and restrict r values to be at most \(30\%\) above their CCA values stated in [3]. Table 4 labels values beyond this limit as N/A.

Table 4. The linear and the quadratic extrapolation equations, and the computed r values for a given DFR. The cases labeled with N/A are those where the value of r to achieve a target DFR could not be found in the range \([0.7r', 1.3r']\), where \(r'\) is the recommended value for IND-CCA security in [3]

F Illustration Graphs

Fig. 7.
figure 7

Histograms of the cases (vertical axis; measured in percentage) that end-up with some weight of an “ideal” errors vector (horizontal axis) after the \(X_{BG}=1,2,3,4\) iterations. The decoder is the Black-Gray decoder. Panels a, c, e, g represents the results for \(r=9,803\) and Panels b, d, f, h for \(r=10,163\) with \(f=0,20,30,40\). A lower error weight is better. See explanation in the text.

Fig. 8.
figure 8

BIKE-1 Level-1 and Level-3 extrapolations (see Sect. 4 for details).

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Drucker, N., Gueron, S., Kostic, D. (2020). On Constant-Time QC-MDPC Decoders with Negligible Failure Rate. In: Baldi, M., Persichetti, E., Santini, P. (eds) Code-Based Cryptography. CBCrypto 2020. Lecture Notes in Computer Science(), vol 12087. Springer, Cham. https://doi.org/10.1007/978-3-030-54074-6_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-54074-6_4

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-54073-9

  • Online ISBN: 978-3-030-54074-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics