Next Article in Journal
Prediction of Postoperative ICU Requirements: Closing the Translational Gap with a Real-World Clinical Benchmark for Artificial Intelligence Approaches
Previous Article in Journal
New Information Communication Technologies in the Digital Era
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

From Subset-Sum to Decoding: Improved Classical and Quantum Algorithms via Ternary Representation Technique

by
Yang Li
Key Laboratory of System Software (Chinese Academy of Sciences) and State Key Laboratory of Computer Science, Institute of Software, Chinese Academy of Sciences, Beijing 100190, China
Information 2025, 16(10), 887; https://doi.org/10.3390/info16100887 (registering DOI)
Submission received: 11 September 2025 / Revised: 6 October 2025 / Accepted: 10 October 2025 / Published: 12 October 2025

Abstract

The subset-sum problem, a foundational NP-hard problem in theoretical computer science, serves as a critical building block for cryptographic constructions. This work introduces novel classical and quantum heuristic algorithms for the random subset-sum problem at density  d = 1 , where exactly one solution is expected. Classically, we propose the first algorithm based on a ternary tree representation structure, inspired by recent advances in lattice-based cryptanalysis. Through numerical optimization, our method achieves a time complexity of  𝒪 ˜ 2 0.2400 n  and space complexity of  𝒪 ˜ 2 0.2221 n , improving upon the previous best classical heuristic result of  𝒪 ˜ 2 0.2830 n . In the quantum setting, we develop a corresponding algorithm by integrating the classical ternary representation technique with a quantum walk search framework. The optimized quantum algorithm attains a time and space complexity of  𝒪 ˜ 2 0.1843 n , surpassing the prior state-of-the-art quantum heuristic of  𝒪 ˜ 2 0.2182 n . Furthermore, we apply our algorithms to information set decoding in code-based cryptography. For half-distance decoding, our classical algorithm improves the time complexity to  𝒪 ˜ 2 0.0453 n , surpassing the previous best of  𝒪 ˜ 2 0.0465 n . For full-distance decoding, we achieve a quantum complexity of  𝒪 ˜ 2 0.058326 n , advancing beyond the prior best quantum result of  𝒪 ˜ 2 0.058696 n . These findings demonstrate the broad applicability and efficiency of our ternary representation technique across both classical and quantum computational models.

Graphical Abstract

1. Introduction

The subset-sum problem, also referred to as the knapsack problem, stands as one of the most fundamental and well-known NP-hard problems in theoretical computer science [1]. Owing to its computational intractability, it has been widely employed in the construction of cryptographic systems [2,3,4,5]. Moreover, this problem underpins several cryptographic schemes targeting post-quantum security (see, e.g., ref. [6]) and acts as a key component in certain quantum hidden shift algorithms [7]. These, in turn, are applied in quantum cryptanalysis of isogeny-based protocols [8] and symmetric cryptographic constructions [9].
An instance of the problem is specified by n integers  ( a 1 , a 2 , , a n ) ( Z 2 n ) n  and a target integer  s Z 2 n . There are two common formulations: the decision version, which is to verify the existence of a subset of  { a 1 , a 2 , , a n }  summing to s, and the computational version, which requires finding such a subset. The decision subset-sum problem is NP-complete. Moreover, given oracle access to the decision problem, a solution to the computational version can be recovered with n queries. When the instance is uniformly random, the problem is termed the random subset-sum problem (RSSP).
The density of an instance is defined as  d = n / log 2 max i a i . For a random instance  a , the density is closely related to the expected number of solutions. In the high-density regime where  d = Ω 1 / log n , dynamic programming offers an efficient solution [10]. In the low-density setting, Brickell [11] and Lagarias and Odlyzko [12] demonstrated that given oracle access to the shortest vector problem in lattices [13], RSSP can be solved efficiently for densities  d < 0.64 . Coster et al. [14] and Joux and Stern [15] further raised this bound to  d < 0.94 . For knapsack instances with density approaching 1, the best known algorithms exhibit exponential-time complexity, rendering them computationally intractable; this inherent difficulty is the reason for their designation as “hard” knapsacks.
This work addresses the random subset-sum problem at density  d = 1 , where exactly one solution is expected to exist. Horowitz and Sahni’s Meet-in-the-Middle approach [16] reduces the time and space complexity from  𝒪 2 n  to  𝒪 ( 2 n / 2 ) , avoiding the need for an exhaustive search over all  2 n  subsets. The idea of the method is to find a collision between two lists of partial sums, each comprising  2 n / 2  elements. Schroeppel and Shamir [17] refined this approach with a strategy based on merging four lists, which lowered the space complexity to  𝒪 ( 2 n / 4 ) .
A significant heuristic algorithm was proposed by Howgrave-Graham and Joux (HGJ) [18] at EUROCRYPT 2010, solving the RSSP with a time complexity of  𝒪 ˜ ( 2 0.337 n )  and a space complexity of  𝒪 ˜ ( 2 0.311 n ) , thus breaking the long-standing  2 n / 2  barrier. Their key innovation was the use of the representation technique, in which the solution is expressed ambiguously as a sum of vectors in  { 0 , 1 } n . This expands the size of the search space and enables the merging of more lists under arbitrary constraints, leading to improved time efficiency. The time and space complexity is derived via numerical optimization, under the standard heuristic assumption that the individual elements obtained in the merging steps are well-distributed. Becker, Coron, and Joux (BCJ) [19] subsequently reduced the time and space complexity to  𝒪 ˜ ( 2 0.291 n )  by introducing representations using vectors from  { 1 , 0 , 1 } n . Later, Bonnetain, Bricout, Schrottenloher, and Shen (BBSS) [20] further reduced the time and space complexity to  𝒪 ˜ 2 0.283 n  by relaxing BCJ constraints and permitting representations in  { 1 , 0 , 1 , 2 } n . Not only has the representation technique been employed as a tool for the subset-sum problem but it has also been successfully applied to the syndrome decoding problem [21,22,23,24] and the learn-with-errors (LWE) problem [25,26,27,28,29].
Quantum algorithms for the subset-sum problem have also attracted significant attention. The first quantum speedup was achieved by Bernstein, Jeffery, Lange, and Meurer (BJLM) [30], who proposed an algorithm leveraging the HGJ technique, achieving a time and space complexity of  𝒪 ˜ ( 2 0.241 n ) . Helm and May (HM) [31] subsequently developed a quantum variant of the BCJ algorithm that obtains a time and space complexity of  𝒪 ˜ ( 2 0.226 n ) . Later, Bonnetain et al. [20] introduced a quantum algorithm based on their classical algorithm, attaining the time and space complexity of  𝒪 ˜ 2 0.218 n  under the same classical heuristic assumptions.

1.1. Our Contribution

In this work, we introduce a new heuristic algorithm for the subset-sum problem based on a ternary representation technique. The algorithm is further accelerated within a quantum walk search framework, leading to a novel quantum approach.
Representation-based algorithms for the subset-sum problem typically enhance efficiency by increasing the number of representations. These methods inherently exhibit a search tree structure. By recursively constructing parent lists from child lists until reaching a root list that is expected to contain a solution, such algorithms effectively navigate the problem space. To date, all known classical heuristic algorithms employ a binary tree structure. Notably, Lee et al. [29] demonstrated in the context of ternary LWE cryptanalysis that ternary trees significantly increase the number of representations compared to binary trees. Inspired by their idea, we propose the first classical heuristic algorithm for the random subset-sum problem (RSSP) based on a ternary tree structure. Through numerical optimization, we show that our algorithm achieves a time complexity of  𝒪 ˜ 2 0.2400 n  and a space complexity of  𝒪 ˜ 2 0.2221 n , which, to the best of our knowledge, represents the current state of the art among classical heuristic algorithms.
In the quantum setting, we develop a novel quantum algorithm by integrating the proposed classical heuristic with a quantum walk over the Johnson graph, under the MNRS (Magniez–Nayak–Roland–Santha) framework [32]. This quantum algorithm retains the same heuristic foundation as its classical counterpart. After numerical optimization, we demonstrate that it achieves a time and space complexity of  𝒪 ˜ 2 0.1843 n , establishing the best-known quantum heuristic performance for RSSP.
A summary of these complexity results is provided in Table 1.
Furthermore, we apply both our classical and quantum algorithms to the decoding problem. Code-based cryptography, which relies on the hardness of decoding random linear codes, is a major candidate for post-quantum cryptography (PQC). Three of the four encryption schemes chosen in the fourth round of the NIST PQC standardization project [33] are code-based schemes, namely, Classic McEliece [34], BIKE [35], and HQC [36]. Among these, only HQC was ultimately selected for standardization. This prominence underscores the importance of rigorous security analysis for such systems.
Our decoding algorithms operate within the framework of information set decoding (ISD). The first classical ISD algorithm was introduced by Prange in 1962 [37]. Subsequent improvements were made by Stern [38] and Finiasz and Sendrier [39]. Later, further advancements were achieved through the use of representation techniques by May, Meurer, and Thomae (MMT) [21] as well as by Becker, Joux, May, and Meurer (BJMM) [22]. These were later enhanced by combining representation techniques with nearest neighbor searches, as proposed by May and Ozerov (MO) [40] and Both and May (BM) [41]. Currently, the Both–May algorithm [41] achieves the optimal time complexity among classical algorithms. Recent work has also explored time–memory trade-offs [42,43,44].
By applying our subset-sum algorithm to half-distance decoding, we improve upon the best-known ISD algorithm by Both–May, reducing the time complexity from  𝒪 ˜ ( 2 0.0465 n )  to  𝒪 ˜ ( 2 0.0453 n ) . For full-distance decoding, our algorithm achieves a time complexity of  𝒪 ˜ ( 2 0.0973 n ) , improving upon the previous  𝒪 ˜ ( 2 0.1020 n )  [22], which relied solely on representation techniques. Although this result does not surpass the state-of-the-art complexity of  𝒪 ˜ ( 2 0.0885 n )  attained by BM [41]—which combines both representation and nearest neighbor techniques—we anticipate that integrating our ternary representation approach with nearest neighbor search could lead to further improvements.
Quantum variants of ISD have been less extensively explored: Bernstein [45] analyzed a quantum version of Prange’s algorithm, and Kachigar and Tillich (KT) [23] later proposed several quantum-walk-based ISD algorithms, which currently represent the fastest known quantum ISD algorithms. Kirshanova [24] provided an alternative perspective on the quantum-walk-based KT algorithms and developed a quantum version of the MO algorithm. In this work, we propose a novel quantum ISD algorithm that outperforms the state-of-the-art algorithm by Kachigar and Tillich. A summary of the complexity results for ISD is provided in Table 2.

1.2. Organization

The remainder of this paper is structured as follows. Section 2 introduces essential preliminary concepts required for our subsequent analysis and illustrates representation techniques, in particular using the HGJ algorithm as an example. In Section 3, we first present our new classical heuristic subset-sum algorithm, detailing its procedure, explaining its correctness, and analyzing its complexity. Then, through rigorous mathematical derivation, we provide a provable probabilistic algorithm that does not rely on heuristics. In Section 4, we turn to quantum algorithms, explaining in detail how the newly proposed classical algorithm is combined with a quantum walk and subsequently analyzing the complexity of the resulting algorithm. In Section 5, we apply our new classical and quantum algorithms to the decoding problem, demonstrating how they can be incorporated into the information set decoding framework. Specifically, the quantum algorithm employs a nested structure combining Grover search and quantum walks. Finally, in Section 6, we conclude with a summary of our new results.

2. Preliminaries

This section introduces the foundational definitions and standard notations for the subset-sum problem, followed by an overview of representation techniques, illustrated through the HGJ algorithm.

2.1. Notations and Conventions

Definition 1
(Distributions of knapsacks). A knapsack (or subknapsack) is a vector  e D n  where  D = { 1 , 0 , 1 }  is the digit set. We denote by  D n [ α , β ]  the set of vectors  e  containing exactly  α n  entries equal to  1 ( α + β ) n  entries equal to 1, and  ( 1 2 α β ) n  entries equal to 0.
Definition 2
(Random subset-sum instance). Let  a ( Z N ) n  be chosen uniformly at random, where  N 2 n . For  β [ 0 , 1 ] , sample a vector  e  uniformly from  D n 0 , β , and define  s a , e mod N . Then the pair  ( a , s ) ( Z N ) n + 1  is termed a random subset-sum instance. Any vector  e { 0 , 1 } n  satisfying  a , e s mod N  is called a solution to the instance.
It is well established that the parameter choice  β = 1 / 2  represents the most computationally challenging scenario, as the vector  e  contains an equal proportion of zeros and ones, thereby maximizing combinatorial complexity. Consequently, this paper concentrates exclusively on this specific case.
In asymptotic analysis, we utilize the standard formula given below to estimate the cardinality of vector sets that contain a fixed quantity of certain coefficients.
Lemma 1
(Multinomial approximation). Let  D i g = { d 1 , , d k } Z N  be a digit set of cardinality k. Consider vectors in  Z N n D i g n  where each digit  d i  appears exactly  c i n  times and the coefficients  c i  satisfy  i = 1 k c i = 1 . The number of such vectors is asymptotically given by the multinomial coefficient:
n c 1 n , , c k n 2 H ( c 1 , , c k ) n ,
where the entropy function is defined as  H ( c 1 , , c k ) : = i = 1 k c i log 2 ( 1 c i ) .
We use the notation  n c 1 n , , c k 1 n , ·  as a shorthand for the multinomial coefficient  n c 1 n , , c k n , with the dot (·) standing for the remaining term  n i = 1 k 1 c i n . Similarly, we write  H ( c 1 , , c k 1 , · )  for the entropy  H ( c 1 , , c k ) .
We adopt the soft-O notation, denoted by  𝒪 ˜ , to suppress polylogarithmic factors in n. Any rounding is omitted for simplicity.

2.2. Representation Techniques

From a high-level perspective, classical algorithms based on representation techniques recursively generate subknapsack lists and merge them to ultimately obtain a list of solutions to the original knapsack problem.
We use the HGJ algorithm [18] as an example due to its seminal status and relatively simple structure. The tree structure of the HGJ algorithm is illustrated in Figure 1.
Consider a subset-sum instance  ( a , s ) ( Z N ) n + 1  with a solution  e D n [ 0 , 1 / 2 ] , meaning  a , e s mod 2 n , and exactly  n / 2  components of  e  are 1, while the remaining  n / 2  are 0.
The core idea is to represent  e  ambiguously as a sum of vectors in  { 0 , 1 } n , i.e.,  e = e 1 ( 1 ) + e 2 ( 1 )  with  e 1 ( 1 ) , e 2 ( 1 ) D n 0 , 1 / 4 . We call  ( e 1 ( 1 ) , e 2 ( 1 ) )  a representation of  e . The ambiguity introduces  R ( 1 ) = n / 2 n / 4  representations of  e , since each of the  n / 2  1-coordinates in  e  can be represented as  1 + 0  or  0 + 1 . This paper adopts the notation where a parenthesized superscript corresponds to the depth of a given vector or parameter in the tree.
Since finding even a single representation from this exponential set is adequate to solve the subset-sum problem, the HGJ algorithm’s core principle is to aim for the computation of approximately a  1 / R ( 1 )  fraction of all representations. This targeted approach is designed to yield, in expectation, exactly one valid representation.
This motivates the following strategy. Select a modulus  2 r ( 1 ) , where  r ( 1 ) = log 2 R ( 1 ) , and sample a target value at random  s 1 ( 1 ) { 0 , 1 , , 2 r ( 1 ) 1 } . Define the lists
L 1 ( 1 ) = e 1 ( 1 ) , a , e 1 ( 1 ) D n 0 , 1 / 4 × Z N a , e 1 ( 1 ) s 1 ( 1 ) mod 2 r ( 1 ) ,
L 2 ( 1 ) = e 2 ( 1 ) , a , e 2 ( 1 ) D n 0 , 1 / 4 × Z N a , e 2 ( 1 ) s 2 ( 1 ) mod 2 r ( 1 ) .
where  s 2 ( 1 ) = s s 1 ( 1 ) .  A collision where  a , e 1 ( 1 ) = a , e 2 ( 1 ) , and  e 1 ( 1 ) + e 2 ( 1 ) D n 0 , 1 / 2  yields a subset-sum solution. If there are no such collisions, the process is repeated with a new  s 1 ( 1 ) . After polynomially many iterations, the failure probability is negligible.
L 1 ( 1 ) , L 2 ( 1 )  are constructed recursively, see also Figure 1. We demonstrate the list construction method using  L 1 ( 1 )  as an example. We represent  e 1 ( 1 ) D n 0 , 1 / 4  as  e 1 ( 1 ) = e 1 ( 2 ) + e 2 ( 2 )  with  e 1 ( 2 ) , e 2 ( 2 ) D n 0 , 1 / 8 . By the same reasoning as before, the number of representations is  R ( 2 ) = n / 4 n / 8 . Let  r ( 2 ) = log 2 R ( 2 ) .  We compute
L j ( 2 ) = e j ( 2 ) , a , e j ( 2 ) D n 0 , 1 / 8 × Z N a , e j ( 2 ) s j ( 2 ) mod 2 r ( 2 ) ,
for  j = 1 , 2 , 3 , 4 , where  j = 1 4 s j ( 2 ) = s .
The level-2 lists are built from the level-3 lists below via a standard Meet-in-the-Middle approach.
L 2 j 1 ( 3 ) = e 2 j 1 ( 3 ) , a , e 2 j 1 ( 3 ) D n / 2 0 , 1 / 16 × 0 n / 2 × Z N ,
L 2 j ( 3 ) = e 2 j ( 3 ) , a , e 2 j ( 3 ) 0 n / 2 × D n / 2 0 , 1 / 16 × Z N for j = 1 , 2 , 3 , 4 .
Algorithm 1 outlines the HGJ procedure. In summary, the algorithm recursively constructs two lists  L 1 ( 1 )  and  L 2 ( 1 )  that are expected to contain a single representation of  e . It iteratively performs a merge-and-filter operation across multiple levels, progressively approaching the distribution  D n [ 0 , 1 / 2 ]  while incrementally increasing the bit-length of the modular constraint. This continues until the condition  a , e s ( mod 2 n )  is fully satisfied and a solution is found.
Consider two input distributions,  D 1 = D n α 1 , β 1  and  D 2 = D n α 2 , β 2 , with a target distribution  D = D n α , β . Given two lists  L 1 D 1 | L 1 |  and  L 2 D 2 | L 2 | , we define the following:
  • The merged list
    L m = { ( e 1 + e 2 , a , e 1 + e 2 ) e 1 L 1 , e 2 L 2 , a , e 1 + e 2 t mod M } ,
    where  0 t < M  is an arbitrary integer,
  • The filtered list  L f = ( L m D ) L m ,  containing the vectors with the target distribution.
Algorithm 1 The HGJ algorithm
Input: 
The random subset-sum instance  ( a , s ) ( Z N ) n + 1
Output: 
A solution  e D n 0 , 1 / 2  or ⊥ if no solution is found.
  1:
Construct all level-3 lists  L j ( 3 )  for  j { 1 , , 8 } .
  2:
for  i = 2  down to 0 do
  3:
      for  j = 1  to  2 i  do
  4:
            Construct  L j ( i )  from  L 2 j 1 ( i + 1 ) , L 2 j ( i + 1 ) .
  5:
      end for
  6:
end for
  7:
if   L 1 ( 0 ) then
  8:
      return any  e L 1 ( 0 )
  9:
else
10:
      return
11:
end if
A central tenet of the standard subset-sum heuristic is the treatment of  L f  elements as independent and uniformly distributed under D. The empirically validated heuristic allows for the derivation of classically provable, probabilistic algorithms, thereby corroborating the soundness of the heuristic itself (see Theorem 2 in [19]).
Heuristic 1.
Suppose the input vectors are uniformly distributed over  D 1 × D 2 . Then the filtered pairs of vectors are also uniformly distributed over the target set D—or more precisely, over the subset of vectors in D that satisfy the given modular constraint.
By Heuristic 1, the expected size of the merged list is given by  | L m | = ( | L 1 | · | L 2 | ) / M , and the average size of the filtered list  L f  equals  | L m | · pf , where pf denotes the probability that a pair  ( e 1 , e 2 ) , sampled uniformly from  D 1 × D 2 , satisfies  e 1 + e 2 D .
For each level  i { 1 , 2 , 3 } , the size of the corresponding lists is denoted by  L ( i ) . Under the same heuristic, the list sizes concentrate sharply around their expectations, leading to the expressions
L ( 3 ) = n / 2 n / 16 , L ( 2 ) = n n / 8 / R ( 2 ) , L ( 1 ) = n n / 4 / R ( 1 ) .
The time cost is
max L ( 3 ) , L ( 3 ) 2 R ( 2 ) , L ( 2 ) 2 R ( 1 ) / R ( 2 ) , L ( 1 ) 2 N / R ( 1 ) ,
and the memory cost is  max L ( 3 ) , L ( 2 ) , L ( 1 ) . Numerical optimization yields a time complexity of  𝒪 ˜ ( 2 0.337 n )  and a space complexity of  𝒪 ˜ ( 2 0.311 n ) .
The algorithm of BCJ [19] achieves a time and space complexity of  𝒪 ˜ ( 2 0.291 n )  by generalizing the representation technique to include entries from  { 1 , 0 , 1 } . In later work, Bonnetain et al. further improved this to  𝒪 ˜ 2 0.283 n  by relaxing BCJ constraints and allowing 2-coordinates in the representations.
In general, introducing more symbols ( 2 , 3, etc.) can increase the parameter search space and improve the optimal time complexity. However, the improvements gained by introducing further symbols are expected to exhibit diminishing returns.
To date, representation-based subset-sum algorithms in the literature exclusively employ binary trees as their search structure. In the following section, we propose new subset-sum algorithms based on ternary trees because ternary trees substantially increase the number of representations over binary trees.

3. A Novel Classical Subset-Sum Algorithm Based on Ternary Representation Techniques

3.1. Heuristic Construction

The proposed classical algorithm, which we refer to as TER, employs a ternary tree structure as illustrated in Figure 2. We encourage the reader to consult the figure for a clearer understanding of the algorithmic workflow. The tree has a depth of 3—a value determined through numerical optimization to be optimal for TER (see Appendix A for details).
For clarity, we consider a subset-sum instance  ( a , s ) ( Z N ) n + 1  with a solution  e D n [ 0 , 1 / 2 ] . The key idea is to represent  e  as a sum of three vectors in  D n , i.e.,
e = e 1 ( 1 ) + e 2 ( 1 ) + e 3 ( 1 )
where  e 1 ( 1 ) , e 2 ( 1 ) , e 3 ( 1 ) D n [ w ( 1 ) , 1 / 6 ] . This means each of these three vectors contains exactly  w ( 1 ) n  entries equal to  1 ( 1 / 6 + w ( 1 ) ) n  entries equal to 1, and  ( 5 / 6 2 w ( 1 ) ) n  entries equal to 0.
We begin by computing the number of representations and establishing the parameter  w ( 1 ) . For each 1-coordinate  e k  in  e , its decomposition via the k-th coordinates of  e 1 ( 1 ) , e 2 ( 1 ) , e 3 ( 1 )  must be one of
1 + 0 + 0 , 0 + 1 + 0 , 0 + 0 + 1 , 1 + 1 + ( 1 ) , 1 + ( 1 ) + 1 , ( 1 ) + 1 + 1 .
Let  ϵ 1 ( 1 ) n  denote the number of representations for each of the last three types. The total number of representations for the first three types is equal to  ( 1 / 2 3 ϵ 1 ( 1 ) ) n , because  e  has  n / 2  1-coordinates.
For each 0-coordinate  e k  in  e , its decomposition via the k-th coordinates of  e 1 ( 1 ) , e 2 ( 1 ) , e 3 ( 1 )  must be one of
0 + 1 + ( 1 ) , 0 + ( 1 ) + 1 , 1 + 0 + ( 1 ) , ( 1 ) + 0 + 1 , 1 + ( 1 ) + 0 , ( 1 ) + 1 + 0 ,
excluding the trivial case  0 + 0 + 0 . Let  ϵ 0 ( 1 ) n  denote the number of each of these six nontrivial representations.
Table 3 summarizes the counts for each type of level-1 representation.
The total number of representations is given by
R ( 1 ) = n / 2 ϵ 1 ( 1 ) n , ϵ 1 ( 1 ) n , ϵ 1 ( 1 ) n , ( 1 / 6 ϵ 1 ( 1 ) ) n , ( 1 / 6 ϵ 1 ( 1 ) ) n , · × n / 2 ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , · ,
where the two factors, respectively, account for the number of representations for 1-coordinates and 0-coordinates in the vector  e .
The number of  ( 1 ) -coordinates of  e j ( 1 )  for  j = 1 , 2 , 3  is  ( ϵ 1 ( 1 ) + 2 ϵ 0 ( 1 ) ) n ,  and the number of 1-coordinates is  ( 1 / 6 + ϵ 1 ( 1 ) + 2 ϵ 0 ( 1 ) ) n .  Let  w ( 1 ) = ϵ 1 ( 1 ) + 2 ϵ 0 ( 1 ) , then  e j ( 1 ) D n w ( 1 ) , 1 / 6  for  j = 1 , 2 , 3 .
To capture a representation of  e , we choose a modulus  2 r ( 1 )  where  r ( 1 ) = 1 2 log 2 R ( 1 ) , and random targets  s 1 ( 1 ) , s 2 ( 1 ) { 0 , 1 , , 2 r ( 1 ) 1 } . We then define the lists:
L 1 ( 1 ) = e 1 ( 1 ) , a , e 1 ( 1 ) D n [ w ( 1 ) , 1 / 6 ] × Z N a , e 1 ( 1 ) s 1 ( 1 ) mod 2 r ( 1 ) , L 2 ( 1 ) = e 2 ( 1 ) , a , e 2 ( 1 ) D n [ w ( 1 ) , 1 / 6 ] × Z N a , e 2 ( 1 ) s 2 ( 1 ) mod 2 r ( 1 ) , L 3 ( 1 ) = e 3 ( 1 ) , a , e 3 ( 1 ) D n [ w ( 1 ) , 1 / 6 ] × Z N a , e 3 ( 1 ) s 3 ( 1 ) mod 2 r ( 1 ) ,
where  s 3 ( 1 ) = s s 1 ( 1 ) s 2 ( 1 ) .
A valid solution is found when  a , e 1 ( 1 ) + a , e 2 ( 1 ) = a , e 3 ( 1 )  and  e 1 ( 1 ) + e 2 ( 1 ) + e 3 ( 1 ) D n [ 0 , 1 / 2 ] . If no collision occurs, new values  ( s 1 ( 1 ) , s 2 ( 1 ) )  are sampled. The failure probability becomes negligible after polynomially many attempts.
The expected size of each list  L j ( 1 ) ( j = 1 , 2 , 3 )  is
E | L j ( 1 ) | = n w ( 1 ) n , ( 1 / 6 + w ( 1 ) ) n , · R ( 1 ) .
These lists are constructed recursively. For example, to build  L 1 ( 1 ) , we represent  e 1 ( 1 ) D n [ w ( 1 ) , 1 / 6 ]  as  e 1 ( 1 ) = e 1 ( 2 ) + e 2 ( 2 ) + e 3 ( 2 )  with  e 1 ( 2 ) , e 2 ( 2 ) , e 3 ( 2 ) D n [ w ( 2 ) , 1 / 18 ] .
Let  ϵ 1 ( 2 ) n  count each of the representations  1 + 1 + ( 1 ) 1 + ( 1 ) + 1 , and  ( 1 ) + 1 + 1  for the 1-coordinates of  e 1 ( 1 ) , and  ϵ 0 ( 2 ) n  count each of the six nontrivial representations of the 0-coordinates. For the  ( 1 ) -coordinates, the representations are
( 1 ) + 0 + 0 , 0 + ( 1 ) + 0 , 0 + 0 + ( 1 ) , 1 + ( 1 ) + ( 1 ) , ( 1 ) + 1 + ( 1 ) , ( 1 ) + ( 1 ) + 1 .
Let  ϵ 1 ( 2 ) n  count each of the last three types. Table 4 provides the counts for each type of level-2 representation.
The number of representations at this level is
R ( 2 ) = ( 1 / 6 + w ( 1 ) ) n ϵ 1 ( 2 ) n , ϵ 1 ( 2 ) n , ϵ 1 ( 2 ) n , ( 1 / 18 + w ( 1 ) / 3 ϵ 1 ( 2 ) ) n , ( 1 / 18 + w ( 1 ) / 3 ϵ 1 ( 2 ) ) n , · × ( 5 / 6 2 w ( 1 ) ) n ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , · × w ( 1 ) n ϵ 1 ( 2 ) n , ϵ 1 ( 2 ) n , ϵ 1 ( 2 ) n , ( w ( 1 ) / 3 ϵ 1 ( 2 ) ) n , ( w ( 1 ) / 3 ϵ 1 ( 2 ) ) n , · .
The number of  ( 1 ) -coordinates of  e j ( 2 )  for  j = 1 , 2 , 3  is calculated as
w ( 1 ) / 3 ϵ 1 ( 2 ) + 2 ϵ 1 ( 2 ) + 2 ϵ 0 ( 2 ) + ϵ 1 ( 2 ) n = ϵ 1 ( 1 ) / 3 + 2 ϵ 0 ( 1 ) / 3 + ϵ 1 ( 2 ) + ϵ 1 ( 2 ) + 2 ϵ 0 ( 2 ) n ,
and the number of 1-coordinates of  e j ( 1 )  for  j = 1 , 2 , 3  is calculated as
1 / 18 + w ( 1 ) / 3 ϵ 1 ( 2 ) + 2 ϵ 1 ( 2 ) + 2 ϵ 0 ( 2 ) + ϵ 1 ( 2 ) n = 1 / 18 + ϵ 1 ( 1 ) / 3 + 2 ϵ 0 ( 1 ) / 3 + ϵ 1 ( 2 ) + ϵ 1 ( 2 ) + 2 ϵ 0 ( 2 ) n .
Let  w ( 2 ) = ϵ 1 ( 1 ) / 3 + 2 ϵ 0 ( 1 ) / 3 + ϵ 1 ( 2 ) + ϵ 1 ( 2 ) + 2 ϵ 0 ( 2 ) , then  e j ( 2 ) D n [ w ( 2 ) , 1 / 18 ]  for  j = 1 , 2 , 3 .
Let  r ( 2 ) = 1 2 log 2 R ( 2 )  and choose random targets  s j ( 2 ) { 0 , 1 , , 2 r ( 2 ) 1 }  for  j { 1 , 2 , 4 , 5 , 7 , 8 } . We define
L j ( 2 ) = e j ( 2 ) , a , e j ( 2 ) D n w ( 2 ) , 1 / 18 × Z N a , e j ( 2 ) s j ( 2 ) mod 2 r ( 2 ) ,
for  j { 1 , , 9 } , where  s 3 k ( 2 ) = s k ( 1 ) s 3 k 2 ( 2 ) s 3 k 1 ( 2 )  for  k = 1 , 2 , 3 .
The expected size of each  L j ( 2 ) ( j { 1 , , 9 } )  is
E | L j ( 2 ) | = n w ( 2 ) n , ( 1 / 18 + w ( 2 ) ) n , · R ( 2 ) .
The level-2 lists are built from the level-3 lists via a Meet-in-the-Middle approach.
L 2 j 1 ( 3 ) = e 2 j 1 ( 3 ) , a , e 2 j 1 ( 3 ) D n / 2 w ( 2 ) , 1 / 18 × 0 n / 2 × Z N , L 2 j ( 3 ) = e 2 j ( 3 ) , a , e 2 j ( 3 ) 0 n / 2 × D n / 2 w ( 2 ) , 1 / 18 × Z N ,
for  j { 1 , , 9 } , each of size
n / 2 ( w ( 2 ) / 2 ) n , ( 1 / 36 + w ( 2 ) / 2 ) n , · .
Note that we employ the binary tree only for the top level, because the representation technique is not used in this level.
Algorithm 2 outlines the TER algorithm with a depth of 3. In summary, it recursively constructs three lists  L 1 ( 1 ) , L 2 ( 1 ) , L 3 ( 1 )  that are expected to contain a single representation of  e . Similar to the HGJ algorithm, this algorithm executes the merge-and-filter operation repeatedly over several levels.
Consider three input distributions,  D 1 = D n α 1 , β 1 D 2 = D n α 2 , β 2  and  D 3 = D n α 3 , β 3 , with a target distribution  D = D n α , β . Given three lists  L 1 D 1 | L 1 | L 2 D 2 | L 2 |  and  L 3 D 2 | L 3 | , we define the following:
  • The merged list
    L m = { ( e 1 + e 2 + e 3 , a , e 1 + e 2 + e 3 ) e 1 L 1 , e 2 L 2 , e 3 L 3 , a , e 1 + e 2 + e 3 t mod M } ,
    where  0 t < M  is an arbitrary integer,
  • The filtered list  L f = ( L m D ) L m ,  containing the vectors with the target distribution.
Algorithm 2 TER with a depth of 3
Input: 
The random subset-sum instance  ( a , s ) ( Z N ) n + 1
Parameters: 
ϵ 1 ( 1 ) , ϵ 0 ( 1 ) , ϵ 1 ( 2 ) , ϵ 0 ( 2 ) , ϵ 1 ( 2 )  that need to be optimized.
Output: 
A solution  e D n 0 , 1 / 2  or ⊥ if no solution is found.
  1:
Construct all level-3 lists  L j ( 3 )  for  j { 1 , , 18 } .
  2:
Compute  L j ( 2 )  from  L 2 j 1 ( 3 ) , L 2 j ( 3 )  for  j { 1 , , 9 } .
  3:
for  i = 1  down to 0 do
  4:
      for  j = 1  to  3 i  do
  5:
            Construct  L j ( i )  from  L 3 j 2 ( i + 1 ) , L 3 j 1 ( i + 1 ) , L 3 j ( i + 1 ) .
  6:
      end for
  7:
end for
  8:
if   L 1 ( 0 ) then
  9:
      return any  e L 1 ( 0 )
10:
else
11:
      return
12:
end if
Similar to the standard subset-sum assumption, our heuristic assumes that elements in  L f  are independently and uniformly sampled from the distribution D.
Heuristic 2.
Suppose the input vectors are uniformly distributed over  D 1 × D 2 × D 3 . Then the filtered pairs of vectors are also uniformly distributed over the target set D—or more precisely, over the subset of vectors in D that satisfy the given modular constraint.
By Heuristic 2, the expected sizes of the merged list is given by  | L m | = ( | L 1 | · | L 2 | · | L 3 | ) / M , and the average size of the filtered list  L f  equals  | L m | · pf , where pf denotes the probability that a uniformly random triple  ( e 1 , e 2 , e 3 )  from  D 1 × D 2 × D 3  satisfies  ( e 1 + e 2 + e 3 ) D .
Theorem 1.
Let  ( a , s ) ( Z N ) n + 1  be a random subset-sum instance whose solution is a vector  e D n 0 , 1 / 2 . Under Heuristic 2, Algorithm 2 finds  e  in time  𝒪 ˜ ( 2 0.2400 n )  and space  𝒪 ˜ ( 2 0.2221 n ) .
Proof. 
For each level  i { 1 , 2 , 3 } , the size of the corresponding lists is denoted by  L ( i ) . Under Heuristic 2, the list sizes concentrate sharply around their expectations, leading to the expressions
L ( 1 ) = n w ( 1 ) n , ( 1 / 6 + w ( 1 ) ) n , · / R ( 1 ) , L ( 2 ) = n w ( 2 ) n , ( 1 / 18 + w ( 2 ) ) n , · / R ( 2 ) , L ( 3 ) = n / 2 ( w ( 2 ) / 2 ) n , ( 1 / 36 + w ( 2 ) / 2 ) n , · .
where
w ( 1 ) = ϵ 1 ( 1 ) + 2 ϵ 0 ( 1 ) , w ( 2 ) = ϵ 1 ( 1 ) / 3 + 2 ϵ 0 ( 1 ) / 3 + ϵ 1 ( 2 ) + ϵ 1 ( 2 ) + 2 ϵ 0 ( 2 ) , R ( 1 ) = n / 2 ϵ 1 ( 1 ) n , ϵ 1 ( 1 ) n , ϵ 1 ( 1 ) n , ( 1 / 6 ϵ 1 ( 1 ) ) n , ( 1 / 6 ϵ 1 ( 1 ) ) n , · × n / 2 ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , · , R ( 2 ) = ( 1 / 6 + w ( 1 ) ) n ϵ 1 ( 2 ) n , ϵ 1 ( 2 ) n , ϵ 1 ( 2 ) n , ( 1 / 18 + w ( 1 ) / 3 ϵ 1 ( 2 ) ) n , ( 1 / 18 + w ( 1 ) / 3 ϵ 1 ( 2 ) ) n , · × ( 5 / 6 2 w ( 1 ) ) n ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , ϵ 0 ( 2 ) n , · × w ( 1 ) n ϵ 1 ( 2 ) n , ϵ 1 ( 2 ) n , ϵ 1 ( 2 ) n , ( w ( 1 ) / 3 ϵ 1 ( 2 ) ) n , ( w ( 1 ) / 3 ϵ 1 ( 2 ) ) n , · ,
and  ϵ 1 ( 1 ) , ϵ 0 ( 1 ) , ϵ 1 ( 2 ) , ϵ 0 ( 2 ) , ϵ 1 ( 2 )  are parameters to be optimized.
Based on the preceding analysis, the time complexity of Algorithm 2 can be derived as follows:
max L ( 3 ) , L ( 3 ) 2 R ( 2 ) , L ( 2 ) 3 R ( 1 ) / R ( 2 ) , L ( 1 ) 3 N / R ( 1 ) ,
and the space complexity is  max L ( 3 ) , L ( 2 ) , L ( 1 ) . Let us focus on the asymptotic exponent in  log 2  and relative to n. Denote  l ( i ) = log 2 ( L ( i ) ) / n  for  i = 1 , 2 , 3 . Recall that  r ( 1 ) = 1 2 log 2 R ( 1 )  and  r ( 2 ) = 1 2 log 2 R ( 2 ) . Computing the time complexity essentially amounts to solving the following optimization problem, where the objective function is
max l ( 3 ) , 2 l ( 3 ) r ( 2 ) / n , 3 l ( 2 ) ( r ( 1 ) r ( 2 ) ) / n , 3 l ( 1 ) ( 1 r ( 1 ) / n ) ,
subject to the following constraints:
l ( 1 ) = H ( 1 / 6 + w ( 1 ) , w ( 1 ) ) r ( 1 ) / n , l ( 2 ) = H ( 1 / 18 + w ( 2 ) , w ( 2 ) ) r ( 2 ) / n , l ( 3 ) = H ( 1 / 18 + w ( 2 ) , w ( 2 ) ) / 2 , w ( 1 ) = ϵ 1 ( 1 ) + 2 ϵ 0 ( 1 ) , w ( 2 ) = ϵ 1 ( 1 ) / 3 + 2 ϵ 0 ( 1 ) / 3 + ϵ 1 ( 2 ) + ϵ 1 ( 2 ) + 2 ϵ 0 ( 2 ) , 2 r ( 1 ) n = H ( 2 ϵ 1 ( 1 ) , 2 ϵ 1 ( 1 ) , 2 ϵ 1 ( 1 ) , 1 / 3 2 ϵ 1 ( 1 ) , 1 / 3 2 ϵ 1 ( 1 ) , · ) / 2 + H ( 2 ϵ 0 ( 1 ) , 2 ϵ 0 ( 1 ) , 2 ϵ 0 ( 1 ) , 2 ϵ 0 ( 1 ) , 2 ϵ 0 ( 1 ) , 2 ϵ 0 ( 1 ) , · ) / 2 , 2 r ( 2 ) n = H ϵ 1 ( 2 ) 1 / 6 + w ( 1 ) , ϵ 1 ( 2 ) 1 / 6 + w ( 1 ) , ϵ 1 ( 2 ) 1 / 6 + w ( 1 ) , 1 / 3 ϵ 1 ( 2 ) 1 / 6 + w ( 1 ) , 1 / 3 ϵ 1 ( 2 ) 1 / 6 + w ( 1 ) , · × ( 1 / 6 + w ( 1 ) ) + H ϵ 0 ( 2 ) 5 / 6 2 w ( 1 ) , ϵ 0 ( 2 ) 5 / 6 2 w ( 1 ) , ϵ 0 ( 2 ) 5 / 6 2 w ( 1 ) , ϵ 0 ( 2 ) 5 / 6 2 w ( 1 ) , ϵ 0 ( 2 ) 5 / 6 2 w ( 1 ) , ϵ 0 ( 2 ) 5 / 6 2 w ( 1 ) , · × ( 5 / 6 2 w ( 1 ) ) + H ϵ 1 ( 2 ) w ( 1 ) , ϵ 1 ( 2 ) w ( 1 ) , ϵ 1 ( 2 ) w ( 1 ) , 1 / 3 ϵ 1 ( 2 ) w ( 1 ) , 1 / 3 ϵ 1 ( 2 ) w ( 1 ) , · × w ( 1 ) .
Note that Lemma 1 is applied when computing the exponents of the constraints.
Numerical optimization yields the parameters
ϵ 0 ( 1 ) = 0.0066 , ϵ 1 ( 1 ) = 0.0024 , ϵ 0 ( 2 ) = 0.0004 , ϵ 1 ( 2 ) = 0.0001 , ϵ 1 ( 2 ) = 0.0000 ,
w ( 1 ) = 0.0156 , w ( 2 ) = 0.0059 .
This results in
R ( 1 ) = 2 1.1473 n , R ( 2 ) = 2 0.3396 n ,
which in turn yield list sizes
L ( 3 ) = 2 0.1922 n , L ( 2 ) = 2 0.2147 n , L ( 1 ) = 2 0.2221 n , L ( 0 ) = 1 .
The time complexity is  𝒪 ˜ 2 0.2400 n , determined by the merged list size, and the space complexity is  𝒪 ˜ 2 0.2221 n , governed by the filtered list size.    □

3.2. Rigorous Analysis of TER

In this subsection, we establish rigorous foundations for Heuristic 2 and present a provable variant of TER that eliminates heuristic assumptions. Our analysis relies on distributional properties of modular sums, as captured by the following fundamental result (Theorem 3.2 in [46]).
Theorem 2.
For any set  B Z M n , the identity
1 M n a Z M n c Z M P a ( B , c ) 1 M 2 = M 1 M | B |
holds, where  P a ( B , c )  denotes the probability that  a · x : = a , x c ( mod M )  for a random  x  drawn uniformly from  B , i.e.,
P a ( B , c ) = 1 | B | ( x 1 , , x n ) B s . t . a · x c mod M .
The left-hand side of Equation (3) represents the average squared deviation from uniformity across all coefficient vectors  a = ( a 1 , , a n )  and residues  c Z M . This quantity measures the overall non-uniformity of the distribution. The right-hand side being constant for fixed  | B |  implies that if certain subset-sum instances exhibit significant deviation from uniformity, others must be exceptionally uniform to maintain the average.
We now extend this result to the Cartesian product setting relevant to our decomposition approach.
Theorem 3.
For any sets  B 1 , B 2 Z M n  and the same coefficient vector  a Z M n , the identity
1 M n a Z M n ( c 1 , c 2 ) Z M 2 P a ( B 1 × B 2 , c 1 , c 2 ) 1 M 2 2 = ( M 1 ) 2 M 2 | B 1 | | B 2 |
holds, where  P a ( B 1 × B 2 , c 1 , c 2 )  denotes the probability that  a · x c 1 ( mod M )  and  a · y c 2 ( mod M )  for random  ( x , y )  drawn uniformly from  B 1 × B 2 .
Proof. 
See Appendix C for the full proof.    □
We now analyze pathological instances that cause TER to fail. During ternary decomposition (e.g., representing  e  as  e 1 ( 1 ) + e 2 ( 1 ) + e 3 ( 1 ) ), certain coefficient vectors—such as  a = ( 0 , , 0 ) —prevent constructing valid level-1 lists (Equation (1)) with random targets  s 1 ( 1 ) , s 2 ( 1 )  due to sparse residue coverage.
Let  B 1  and  B 2  denote the vector sets in the first two parts of the ternary decomposition. We quantify how many residue pairs  ( s 1 ( 1 ) , s 2 ( 1 ) ) Z M 2  remain uncovered by  B 1 × B 2 . For parameter  Λ > 0 , define an instance as Type I bad if either  B 1  covers fewer than  M / Λ  residues or  B 2  covers fewer than  M / Λ  residues.
For such bad instances, at least  ( Λ 1 ) M / Λ  residues lead to zero probability:  P a ( B 1 , s 1 ( 1 ) ) = 0  or  P a ( B 2 , s 2 ( 1 ) ) = 0 . We now establish a lower bound for the variance under bad instances. Without loss of generality, assume that  B 1  covers fewer than  M / Λ  residues. For at least  ( Λ 1 ) M / Λ  uncovered residues  s 1 ( 1 ) ,
P a ( B 1 , s 1 ( 1 ) ) P a ( B 2 , s 2 ( 1 ) ) 1 M 2 2 = 1 M 4 .
For the remaining at most  M / Λ  covered residues  s 1 ( 1 ) , we consider the minimal uniformity scenario: each such residue has a probability of at least  Λ / M  (since the total probability sums to 1), and  P a ( B 2 , s 2 ( 1 ) )  is uniform. Then,
P a ( B 1 , s 1 ( 1 ) ) P a ( B 2 , s 2 ( 1 ) ) 1 M 2 2 ( Λ 1 ) 2 M 4 .
Consequently, the lower bound for the variance is
s 1 ( 1 ) , s 2 ( 1 ) Z M P a ( B 1 , s 1 ( 1 ) ) P a ( B 2 , s 2 ( 1 ) ) 1 M 2 2 ( Λ 1 ) M 2 Λ · 1 M 4 + M 2 Λ · ( Λ 1 ) 2 M 4 = Λ 1 M 2 .
Let  N I  denote the number of Type I bad instances. By Theorem 3,
N I · Λ 1 M 2 M n · ( M 1 ) 2 M 2 | B 1 | | B 2 | .
Since  | B 1 | | B 2 | M 2 , the fraction of Type I bad instances is
N I M n 1 Λ 1 .
Another failure mode occurs when intermediate lists grow beyond expected sizes, violating the complexity analysis in Theorem 1. We now rigorously analyze list sizes during TER’s execution.
Let  L f  be the filtered list in a merge-and-filter operation with distributions D. Let  B 3  denote all vectors with distribution D. We want  | L f | Λ | B 3 | / M  for parameter  Λ . Define Type II bad instances as those where more than  M / ( 2 Λ )  residues c satisfy  P a ( B 3 , c ) Λ / M .
By Theorem 2,
N II M n · M 2 Λ · ( Λ 1 ) 2 M 2 M 1 M B 3 1 B 3 ,
where  N II  counts Type II bad instances. Thus,
N II 2 Λ ( Λ 1 ) 2 · M B 3 · M n 2 Λ ( Λ 1 ) 2 · M n .
The fraction of Type II bad instances is at most  Λ / ( Λ 1 ) 2 .
Now consider the merged list size. Let  L m  be the merged list in a merge-and-filter operation (definition in Equation (2)). Let  B 4  contain all sums  e 1 + e 2 + e 3  without modular constraints. Decompose  M = M 1 · M 2 , where  M 1  represents active moduli from input lists and  M 2  is the supplementary constraint introduced during  L m  construction.
Let  σ ( mod M )  denote the target sum for elements in  L m , with  σ L ( mod M 1 ) σ M ( mod M 1 ) σ R ( mod M 1 )  representing partial sums from the three input lists, respectively, satisfying  σ L + σ M + σ R σ ( mod M 1 ) .
The size of  L m  admits the bound
| L m | = c 1 , c 2 , c 3 Z M c 1 + c 2 + c 3 σ ( mod M 1 ) ( | B 4 | · P a ( B 4 , c 1 ) ) · ( | B 4 | · P a ( B , c 2 ) ) · ( | B 4 | · P a ( B 4 , c 3 ) ) i = 1 3 c i Z M c i σ i ( mod M 1 ) ( | B 4 | · P a ( B 4 , c i ) ) 3 1 / 3 .
To estimate this quantity, we require bounds on sums of the form
c Z M c c 0 ( mod M 1 ) P a ( B , c ) 3 .
We can extend the relation from Theorem 2 to third moments:
1 M n a Z M n c Z M P a ( B , c ) 3 = M 2 + 3 M | B | 3 M + | B | 2 3 | B | + 2 M 2 | B | 2 .
Define Type III bad instances as those where more than  M 1 / ( 12 Λ )  values  c 0  satisfy
c Z M c c 0 ( mod M 1 ) P a ( B 4 , c ) 3 Λ 2 M 1 3 M 2 .
Letting  N III  count such instances,
N III M n · M 1 12 Λ · Λ 2 M 1 3 M 2 M 2 + 3 M | B 4 | 3 M + | B 4 | 2 3 | B 4 | + 2 M 2 | B 4 | 2 .
which implies
N III 12 Λ · M 2 + 3 M | B 4 | + | B 4 | 2 | B 4 | 2 · M n .
In TER,  | B 4 | M  for  L m  construction, so  F III ( 48 / Λ ) M n . The fraction of Type III bad instances is at most  48 / Λ .
This analysis provides theoretical guarantees for all intermediate lists in TER. Since depth-3 TER uses four ternary decompositions, the total fraction of bad instances is bounded by
4 1 Λ 1 + 2 Λ ( Λ 1 ) 2 + 48 Λ 212 Λ .
By choosing sufficiently large  Λ , this fraction becomes negligible.
Excluding three types of bad subset-sum instances, we analyze the success probability of algorithm TER on the remaining good instances, where modulus values are randomly resampled in each ternary decomposition. For good instances, failures fall into three categories:
  • Selecting residues that yield zero probability. With at most  ( Λ 1 ) M / Λ  such residues, the failure probability is  ( Λ 1 ) / Λ .
  • The filtered list overflow. With at most  M / ( 2 Λ )  residues, the failure probability is  ( Λ 1 ) / Λ .
  • The merged list overflow. For each of the three lists to be merged, at most  M 1 / ( 12 Λ )  residues cause overflow, and the failure probability here is  3 / ( 12 Λ ) .
Thus, the overall failure probability is
Λ 1 Λ + 1 2 Λ + 3 12 Λ = 1 1 4 Λ .
Using the limit formula  lim n ( 1 1 / n ) n = e 1 , we repeat each ternary decomposition  8 Λ  times to ensure a failure probability of at most  e 2 . Since  e 2 0.135 , and TER involves four ternary decompositions, the overall failure probability is at most  4 × 0.135 = 0.54 . Hence, the success probability is at least  0.46 . If this success probability is insufficient, a polynomial number of repetitions yields a success probability exponentially close to 1, excluding the bad subset-sum instances. Therefore, this repetition strategy allows us to construct a provable probabilistic version of TER.

4. Improved Subset-Sum Algorithm Based on Quantum Walks

In this section, we begin by introducing the MNRS framework for searching marked vertices on graphs using quantum walks. We then describe how our classical algorithm, TER, is incorporated into this quantum walk framework. Subsequently, we provide a detailed complexity analysis of our quantum algorithm. Through numerical optimization, we derive the optimal parameters and their corresponding complexity values.

4.1. Quantum Walks

Consider an undirected graph  G = ( V , E )  that is both connected and regular. Suppose that some vertices of G are “marked.” We denote by  ϵ  the fraction of marked vertices; equivalently, a vertex chosen uniformly at random is marked with probability  ϵ . Furthermore, let  δ  be the spectral gap of G, i.e., the difference between its two largest eigenvalues. For a classical random walk on G starting from any vertex, the number of steps required to approximate the stationary distribution is roughly  1 / δ .
A classical random walk searches for a marked vertex via the following subroutines:
  • Setup. Sample a random vertex  v V  in time  T S .
  • Update. Perform  1 / δ  random walk steps, where each step moves to a uniformly random adjacent vertex in time  T U .
  • Checking. Check whether the current vertex is marked in time  T C . If not, return to Step 2.
The total time complexity is
T RW = T S + 1 ϵ 1 δ T U + T C .
In the quantum setting, the walk takes place over a superposition of vertices. The initial state is the uniform superposition  v V | v . The algorithm proceeds by iterating approximately  1 / ϵ  times, each iteration amplifying the amplitude on marked vertices. Crucially, each such iteration requires only about  1 / δ  update steps to sufficiently mix the quantum state. An update step in the quantum walk maps a vertex to a superposition of its neighbors. The MNRS framework [32] enables us to focus on specifying the setup, checking, and update unitaries.
Theorem 4
(Quantum walk on a graph [32]). Given a regular graph  G = ( V , E )  with spectral gap  δ > 0 , where at least an  ϵ > 0  fraction of the vertices are marked, for a random walk on a graph G with setup, update, and checking costs denoted by  T S T U , and  T C , respectively, there exists a quantum algorithm that can find a marked vertex with high probability in time
T QW = 𝒪 T S + 1 ϵ T C + T U δ .
Johnson graphs are central to the construction of our quantum walk.
Definition 3
(Johnson graph). The Johnson graph, denoted  J ( N , k ) , is an undirected graph whose vertices correspond to all k-element subsets of a universe of size N. Two vertices S and  S  are connected by an edge if and only if  | S S | = k 1 . This means  S  can be obtained from S by replacing exactly one element. The spectral gap of  J ( N , k )  is given by
δ ( J ( N , k ) ) = N k ( N k ) .
Definition 4
(Cartesian product of Johnson graphs). Let  J m ( N , k )  denote the Cartesian product of m copies of the Johnson graph  J ( N , k ) . Each vertex in  J m ( N , k )  is an m-tuple  ( S 1 , , S m )  of k-element subsets. Two vertices  ( S 1 , , S m )  and  ( S 1 , , S m )  are adjacent if and only if they differ in exactly one coordinate i, and for that index,  | S i S i | = k 1 . The spectral gap satisfies
δ ( J m ( N , k ) ) 1 m · δ ( J ( N , k ) ) = Ω 1 k .
Remark 1
(Heuristics on quantum walks [26]). A notable distinction between classical and quantum subroutines is that quantum updates are required to terminate within a specified time limit, whereas classical procedures may run indefinitely in worst-case scenarios, albeit with low probability. This issue was studied in (Section 6 in [47]) and (Section 5 in [20]). It was shown that terminating updates within a polynomial factor of their expected runtime will not significantly impact final quantum states. Hence, up to a polynomial overhead, it is sufficient to analyze the quantum walk complexity using the expected costs.

4.2. Quantum TER (QTER)

Next, we present the quantum version of our classical algorithm TER, termed QTER. Recall the tree structure illustrated in Figure 2. The depth of the tree in our quantum algorithm is also a parameter subject to optimization, and a depth of 3 was found to be optimal for QTER (as detailed in the Appendix A).
In the quantum walk setup, we construct random subsets  U j ( 3 ) L j ( 3 )  for  j { 1 , , 18 } , each of size  U ( 3 ) : = ( L ( 3 ) ) γ  with  γ < 1 . The TER algorithm is then executed using these newly formed depth-3 lists  U j ( 3 ) .
Let  N = L ( 3 )  and  k = U ( 3 ) . For each list  L j ( 3 ) , where  j { 1 , , 18 } , we associate a Johnson graph denoted  J j ( N , k ) . The overall structure for the random walk is defined on the Cartesian product graph
J ( N , k ) = J 1 ( N , k ) × J 2 ( N , k ) × × J 18 ( N , k ) .
The vertices of  J ( N , k )  are  ( U 1 ( 3 ) , U 2 ( 3 ) , , U 18 ( 3 ) ) , with  U j ( 3 ) L j ( 3 ) , | U j ( 3 ) | = k , 1 j 18 . Denote by  U j ( i )  the j-th list at level i, which is constructed from  U 1 ( 3 ) , , U 18 ( 3 )  according to TER, for  0 i 2 , 1 j 3 i . The data structure of a vertex in the graph  J ( N , k )  maintains all such lists  U j ( i ) . A vertex is considered marked if  U 1 ( 0 )  includes a solution to the initial random subset-sum problem. It can be seen that solving the random subset-sum problem can be transformed into the problem of finding a marked vertex on a graph.
The pseudocode of QTER with depth 3 is given in Algorithm 3.
We now analyze the quantum resources required by Algorithm 3. The quantum circuit width, measured in qubits, comprises three main components: the current vertex registers  j = 1 18 | U j ( 3 ) , the coin register  | c o i n , and the data register  | d a t a .
The tensor product of 18 vertex registers requires  18 U ( 3 )  qubits. The coin register, which stores superpositions of neighboring vertices, also requires  18 U ( 3 )  qubits. The data register stores all hierarchical lists constructed from the current vertex, namely, the level-2, level-1, and level-0 lists, requiring  9 U ( 2 ) + 3 U ( 1 ) + U ( 0 )  qubits in total, where  U ( i ) ( i = 0 , 1 , 2 )  denotes the size of each level-i list. Since the list sizes  U ( i )  grow exponentially with the problem parameters, the overall circuit width is dominated by  max ( U ( 3 ) , U ( 2 ) , U ( 1 ) , U ( 0 ) )  when ignoring polynomial factors.
The circuit depth is determined by three key subroutines. Let  T S T U , and  T C  represent the circuit depths of the setup, update, and checking operations, respectively. The total circuit depth of Algorithm 3 is given by
T S + 1 ϵ T C + T U δ ,
which is consistent with Theorem 4. The complexity of QTER therefore depends on the parameters  T S T U T C ϵ , and  δ .
The checking subroutine achieves  T C = 𝒪 ˜ ( 1 )  through the following procedure: We allocate one ancilla qubit and apply a controlled operation using the register storing  U 1 ( 0 )  as control and the ancilla as target. This operation flips the ancilla qubit if and only if  U 1 ( 0 )  contains a valid solution. The ancilla qubit then facilitates the phase flip for marked vertices. Finally, we uncompute the ancilla by applying the conjugate transpose of the controlled operation. This entire process requires only a polynomial number of quantum gates and one ancilla qubit, ensuring  T C = 𝒪 ˜ ( 1 ) .
We will analyze  T S T U ϵ , and  δ  in the next subsection to determine the overall complexity of QTER.
Algorithm 3 QTER with depth 3
Input: 
The random subset-sum instance  ( a , s ) ( Z N ) n + 1
Parameters: 
γ , ϵ 1 ( 1 ) , ϵ 0 ( 1 ) , ϵ 1 ( 2 ) , ϵ 0 ( 2 ) , ϵ 1 ( 2 )  that need to be optimized.
Output: 
A solution  e D n 0 , 1 / 2  or ⊥ if no solution is found.
  1:
[Setup] Prepare the initial state (normalization omitted):
( U 1 ( 3 ) × × U 18 ( 3 ) ) J ( N , k ) j = 1 18 | U j ( 3 ) | c o i n | d a t a | 0 ,
where  U j ( 3 ) L j ( 3 )  of size  ( L ( 3 ) ) γ  for  j { 1 , , 18 } , the  | c o i n  register represents a superposition of the neighboring vertices, and the  | d a t a  register stores the data associated with the current vertex. ▹ Parameters  ϵ 1 ( 1 ) , ϵ 0 ( 1 ) , ϵ 1 ( 2 ) , ϵ 0 ( 2 ) , ϵ 1 ( 2 )  are employed in the construction of the  | d a t a  state.
  2:
Repeat  O ( 1 / ϵ )  times:
      (2.1)
[Checking]
j = 1 18 | U j ( 3 ) | c o i n | d a t a j = 1 18 | U j ( 3 ) | c o i n | d a t a , if the vertex is marked , j = 1 18 | U j ( 3 ) | c o i n | d a t a , else .
      (2.2)
[Update] Repeat  O ( 1 / δ )  times:
                 (2.2.1)
Perform a single step of the quantum walk.
                 (2.2.2)
Update the data structure.
  3:
Measure the register  | d a t a .
  4:
if   U 1 ( 0 ) then
  5:
      return any  e U 1 ( 0 )
  6:
else
  7:
      return
  8:
end if

4.3. The Complexity of QTER

From Equation (6), the spectral gap of  J ( N , k )  is
δ ( J ( N , k ) ) = Ω 1 k = Ω 1 U ( 3 ) .
A node v that is marked equivalent to its associated level-0 list  U 1 ( 0 )  is non-empty; that is, it retains at least one representation of  e  that survives all merge-and-filter operations. Note that the parameter selection for the lists  L j ( 3 )  within the TER framework ensures that, in expectation, there exists a representation
e = e 1 ( 3 ) + + e 18 ( 3 )
which persists through all filtering steps up to the root list  L 1 ( 0 ) . Under the QTER construction, the probability that  e j ( 3 ) U j ( 3 )  holds simultaneously for all  j { 1 , , 18 }  is given by
ϵ = U ( 3 ) L ( 3 ) 18 = L ( d ) 18 ( γ 1 ) .
Hence, the probability that v is marked is  ϵ .
As shown in Section 3, for TER we obtain the list sizes for each level:
L ( 1 ) = n w ( 1 ) n , ( 1 / 6 + w ( 1 ) ) n , · / R ( 1 ) , L ( 2 ) = n w ( 2 ) n , ( 1 / 18 + w ( 2 ) ) n , · / R ( 2 ) , L ( 3 ) = n / 2 ( w ( 2 ) / 2 ) n , ( 1 / 36 + w ( 2 ) / 2 ) n , · .
We first calculate the setup cost  T S  of QTER with depth 3. The size of the QTER level-3 list is
U ( 3 ) = L ( 3 ) γ = n / 2 ( w ( 2 ) / 2 ) n , ( 1 / 36 + w ( 2 ) / 2 ) n , · γ .
The level-3 lists  U j ( 3 )  can be computed and sorted with respect to the inner products  a , e j ( 3 )  in time  U ( 3 )  for  j { 1 , , 18 } . The level-2 lists contain all elements from their two level-3 children lists that match on the inner products. Thus, we expect  U ( 2 ) = ( U ( 3 ) ) 2 / R ( 2 )  elements that match on their inner products.
Analogously, we compute level-1 lists in expected time  ( U ( 2 ) ) 3 R ( 2 ) / R ( 1 ) . However, now we have to filter out all  e j ( 1 ) D n [ w ( 1 ) , 1 / 6 ]  for  j = 1 , 2 , 3 .
Denote  p r ( i )  as the probability that a uniformly random triple  ( e 1 ( i + 1 ) , e 2 ( i + 1 ) , e 3 ( i + 1 ) ) L 1 ( i + 1 ) × L 2 ( i + 1 ) × L 3 ( i + 1 )  from  ( D n [ w ( i + 1 ) , 1 / ( 2 × 3 i + 1 ) ] ) 3  satisfies  ( e 1 ( i ) + e 2 ( i ) + e 3 ( i ) ) D n [ w ( i ) , 1 / ( 2 × 3 i ) ] , for  i = 0 , 1 . The specific calculation formula for  p r ( 0 ) , p r ( 1 )  can be found in Appendix B.
By leveraging the filtering probability, the size of level-1 lists can be estimated as follows:
U ( 1 ) = U ( 2 ) 3 R ( 1 ) / R ( 2 ) · p r ( 1 ) .
The level-0 list can be computed in expected time  ( U ( 1 ) ) 3 R ( 1 ) / N  and
U ( 0 ) = U ( 1 ) 3 N / R ( 1 ) · p r ( 0 ) .
Thus, the setup cost can be bounded as
T S = max U ( 3 ) , U ( 3 ) 2 R ( 2 ) , U ( 2 ) 3 R ( 1 ) / R ( 2 ) , U ( 1 ) 3 N / R ( 1 ) max U ( 3 ) , U ( 3 ) 2 R ( 2 ) , U ( 3 ) 6 R ( 1 ) R ( 2 ) , U ( 3 ) 18 N R ( 1 ) R ( 2 ) 3 .
The update procedure involves inserting and deleting an element from one of the sets  U j ( 3 ) , where  j { 1 , , 18 } . For instance, suppose we wish to replace an element  e 4 ( 3 )  in  U 4 ( 3 ) . This update operation on  U 4 ( 3 )  can be performed in constant time, i.e., in  𝒪 ( 1 ) .
This update affects the lower-level list  U 2 ( 2 )  if there exist matching elements  e 3 ( 3 )  such that  a , e 3 ( 3 ) + e 4 ( 3 ) = s 2 ( 2 ) mod 2 r ( 2 ) . The expected number of such elements is  U ( 3 ) / R ( 2 ) , applicable to both deletion and insertion operations. At level 1, for the list  U 1 ( 1 ) , each of the  U ( 3 ) / R ( 2 )  elements leads to an expected number of  ( U ( 2 ) ) 2 R ( 2 ) / R ( 1 )  insertions or deletions. A similar reasoning applies to the level-0 list  U 1 ( 0 ) . Overall, the total expected cost of an update is given by
T U = max 1 , U ( 3 ) R ( 2 ) , U ( 2 ) 2 U ( 3 ) R ( 1 ) , U ( 1 ) U ( 2 ) 2 U ( 3 ) N max 1 , U ( 3 ) R ( 2 ) , U ( 3 ) 5 R ( 1 ) R ( 2 ) , U ( 3 ) 17 N R ( 1 ) R ( 2 ) 3 .
Observe that if we approximate the values of  T S  and  T U  using their upper bounds, the relation  T S = U ( 3 ) T U  holds. By combining Equations (5), (7) and (8) with  T C = 𝒪 ˜ ( 1 ) , we derive the following expression for the quantum walk runtime:
T Q W T S + 1 ϵ 1 δ T U + T C = U ( 3 ) T U + L ( 3 ) U ( 3 ) 9 U ( 3 ) T U + 1 = L ( 3 ) γ T U + L ( 3 ) 9 ( 1 γ ) + γ 2 T U = 2 L ( 3 ) 18 19 T U .
To balance setup costs with the cost to find a marked node, we set parameter  γ  to  18 / 19 . This value satisfies the equation  γ = 9 ( 1 γ ) + γ 2 . If  γ  is greater than  18 / 19 , the setup costs increase, leading to a larger overall complexity  T Q W ; if  γ  is smaller than  18 / 19 , the cost of the update and checking iterations becomes higher, also resulting in an increase in the overall complexity  T Q W .
It should be noted that the exponent  γ  converges to 1 as the tree depth increases. This implies that QTER degrades to TER as the number of the depth increases. For the QTER algorithm, a depth of 3 is found to be optimal.
Analogously to Section 3, we obtain the following parameters through numerical optimization:
ϵ 0 ( 1 ) = 0.0057 , ϵ 1 ( 1 ) = 0.0020 , ϵ 0 ( 2 ) = 0.0009 , ϵ 1 ( 2 ) = 0.0001 , ϵ 1 ( 2 ) = 0.0000 ,
w ( 1 ) = 0.0133 , w ( 2 ) = 0.0063 .
This results in
R ( 1 ) = 2 1.1054 n , R ( 2 ) = 2 0.3685 n ,
which in turn yield list sizes
U ( 3 ) = 2 0.1843 n , U ( 2 ) = 2 0.1843 n , U ( 1 ) = 2 0.1639 n , U ( 0 ) = 2 0.1230 n .
The time and space complexity are both  𝒪 ˜ 2 0.1843 n .
Theorem 5.
Let  ( a , s ) ( Z N ) n + 1  be a random subset-sum instance whose solution is a vector  e D n 0 , 1 / 2 . Under the assumption of Heuristic 2, there exists a quantum algorithm (Algorithm 3) that finds  e  in time and space  𝒪 ˜ 2 0.1843 n .

5. Application to Decoding

We now turn to the application of our subset-sum techniques to the problem of decoding random binary linear codes. This is a central problem in coding theory and cryptography, and it can be formulated as a subset-sum problem over the additive group  ( F 2 m , + )  rather than  ( Z 2 n , + ) .
Definition 5
(Syndrome decoding problem). Let  P F 2 ( n k ) × n  be a uniformly random full-rank matrix, which serves as the parity-check matrix of a random linear code  C = { c F 2 n P c = 0 } . Let  y F 2 n  be a received erroneous codeword. The decoding problem is to find an error vector  e F 2 n  of minimal Hamming weight such that
P e = P y .
We denote the syndrome by  s = P y . The goal is to recover  e  (and hence the codeword  c = y + e ).
Note that if  e  has weight at most  d 1 2 , where d is the minimum distance of  C , then the solution is unique. This is referred to as the half-distance decoding scenario. If  | e | d , we are in the full-distance decoding setting.
It i s well-known that the relative distance  d / n  of a random linear code asymptotically meets the Gilbert–Varshamov bound:
d n H 1 1 k n ,
where  H 1  is the inverse of the binary entropy function. Thus, the complexity of decoding can be expressed as a function of the code rate  k / n .
A key observation is that the condition  P e = s  can be viewed as a subset-sum instance over  F 2 n k : the columns of P form the set of elements, and  s  is the target. The additional constraint is that the solution  e  must be a binary vector of low Hamming weight.

5.1. Information Set Decoding

The core idea of ISD is to reduce the problem dimension via Gaussian elimination.
Let  Π  be an  n × n  permutation matrix over  F 2 . For any permutation matrix  Π P Π 1 · Π e = s  holds. Let be a parameter such that  0 n k . For any , with constant probability, Gaussian elimination produces an invertible matrix  G F 2 ( n k ) × ( n k )  such that
G ( P Π 1 ) = P 1 0 P 2 I n k ,
where  P 1 F 2 × ( k + ) P 2 F 2 ( n k ) × ( k + ) , and  I n k  is the identity matrix of size  n k .
Partition  Π e = ( e , e )  with  e F 2 k + e F 2 n k , and similarly let  G s = ( s , s ) . Then the equation  G ( P Π 1 ) ( Π e ) = G s  becomes
P 1 e = s , P 2 e + e = s .
Let us introduce an additional parameter p. We say that a permutation  Π  is good if it induces a weight distribution satisfying  | e | = p  and  | e | = ω p . Assume such a good permutation is found, then the decoding problem reduces to finding a vector  e F 2 k +  of weight p such that  P 1 e = s , and  | P 2 e + s | = ω p . The complete solution is then given by  e = Π 1 ( e , P 2 e + s ) .
The probability that a randomly chosen permutation is good is
P ( p , ) = k + p n k ω p n ω .
In the following subsection, we show how to solve the resulting subset-sum instance  P 1 e = s  efficiently using a variant of TER, adapted to the binary group setting.

5.2. TER for Decoding

Let us focus on the subset-sum instance  P 1 , 1 P 1 , 2 P 1 , k + s  with solution  e F 2 k + , where  P 1 , j ( 1 j k + )  stands for the jth column of matrix  P 1  and  P 1 , 1 , , P 1 , k + , s F 2 . We represent  e  as a sum of three vectors, that is,  e = e 1 ( 1 ) + e 2 ( 1 ) + e 3 ( 1 )  with  e 1 ( 1 ) , e 2 ( 1 ) , e 3 ( 1 ) F 2 k + .
Since the computations are performed in the field  F 2 , the 1-coordinates of  e  can be represented in the following forms:  1 + 0 + 0 0 + 1 + 0 0 + 0 + 1 1 + 1 + 1 ; furthermore, the 0-coordinates can be represented as  0 + 1 + 1 1 + 0 + 1 1 + 1 + 0 0 + 0 + 0 .
For arbitrary  h 2 , Algorithm 4 gives the pseudocode of TER for decoding with depth h. For each level i ( 1 i h 1 ), we define the following quantities:
  • Let  ϵ 1 ( i ) n  denote the number of representations of the form  1 + 1 + 1 ;
  • Let  ϵ 0 ( i ) n  denote the number of representations of the form  0 + 1 + 1 1 + 0 + 1 , or  1 + 1 + 0 ;
  • Let  p ( i )  denote the number of 1-coordinates, then  p ( 0 ) = p .
Algorithm 4 TER for decoding with depth h (TER-de(h))
Input: 
( P 1 , P 2 , s , s , p ) F 2 × ( k + ) × F 2 ( n k ) × ( k + ) × F 2 × F 2 ( n k ) × ( 0 , 1 ) .
Parameters: 
ϵ 1 ( i ) , ϵ 0 ( i )  for  1 i < h .
Output: 
e F 2 k +  of weight p such that  P 1 e = s  and  | P 2 e + s | = ω p , or ⊥ if no such vector is found.
  1:
Construct all level-h lists  L j ( h )  for  j { 1 , , 2 × 3 d 1 } .
  2:
Compute  L j ( h 1 )  from  L 2 j 1 ( h ) , L 2 j ( h )  for  j { 1 , , 3 h 1 } .
  3:
for  i = h 2  down to 0 do
  4:
      for  j = 1  to  3 i  do
  5:
            Construct  L j ( i )  from  L 3 j 2 ( i + 1 ) , L 3 j 1 ( i + 1 ) , L 3 j ( i + 1 ) .
  6:
      end for
  7:
end for
  8:
if  e L 1 ( 0 )  such that  | P 2 e + s | = ω p  then
  9:
      return  e
10:
else
11:
      return
12:
end if
The counts of these representations are summarized in Table 5. For each level i ( 1 i h 1 ), we can compute the following quantities:
  • The number of representations is
    R ( i ) = p ( i 1 ) ϵ 1 ( i ) n , p ( i 1 ) ϵ 1 ( i ) n / 3 , p ( i 1 ) ϵ 1 ( i ) n / 3 , · × k + p ( i 1 ) 3 ϵ 0 ( i ) n ϵ 0 ( i ) n , ϵ 0 ( i ) n , ϵ 0 ( i ) n , · ;
  • The number of 1-coordinates is
    p ( i ) = p ( i 1 ) + 2 ϵ 1 ( i ) n 3 + ϵ 0 ( i ) n ;
  • The list size is
    L ( i ) = k + p ( i ) / R ( i ) ;
  • The time cost is
    T ( i ) = L ( i ) 3 R ( i 1 ) / R ( i ) ,
    where we set  R ( 0 ) = 2 2 l  for the consistency of the formula.
The level-h list size is
L ( h ) = ( k + ) / 2 p ( i 1 ) / 2 ,
and the level-h runtime is
T ( h ) = L ( h ) 2 R ( i 1 ) .
Then, the overall time complexity is
T ( p , ; ϵ 1 ( i ) , ϵ 0 ( i ) ) = max L ( h ) , T ( 1 ) , , T ( h ) ,
and the space complexity is
S ( p , ; ϵ 1 ( i ) , ϵ 0 ( i ) ) = max L ( 1 ) , , L ( h ) ,
where  1 i h 1 .
Next, we integrate TER for decoding into the ISD framework. The complete pseudocode of the resulting ISD algorithm is provided in Algorithm 5.
Algorithm 5 An ISD algorithm that leverages TER
Input: 
Syndrome decoding instance  ( P , y , ω )
Parameters: 
k / n , p with  0 p ω , with  0 n k , h ϵ 1 ( i ) , ϵ 0 ( i )  for  1 i < h .
Output: 
A solution  e F 2 n  of weight  ω  such that  P e = P y .
  1:
repeat
  2:
      Randomly select a permutation matrix  Π F 2 n × n .
  3:
      Using Gaussian elimination compute G such that
G ( P Π 1 ) = P 1 0 P 2 I n k ,
  4:
      Compute  G P y = ( s , s ) F 2 k + × F 2 n k .
  5:
       e T E R d e ( h ) ( P 1 , P 2 , s , s , p )                                            ▹ Call Algorithm 4
  6:
until   e
  7:
Output  e = Π 1 ( e , P 2 e + s ) .
To determine the computational complexity of our algorithm for a fixed code rate  k / n  and a fixed search tree depth h, we aim to optimize the parameters  p , , and  ϵ 1 ( i ) , ϵ 0 ( i )  for  1 i < h , such that the expression
T ( p , ; ϵ 1 ( i ) , ϵ 0 ( i ) ) · P ( p , ) 1
is minimized, subject to the following constraints:
0 < < min ( n k , n k ω p ) 0 < p < min ( ω , k + ) 0 < p ( h 1 ) < < p ( 1 ) < p 0 < R ( h 1 ) < < R ( 1 ) < .
In the half-distance decoding scenario, optimization leads to complexities of
T HD = 2 0.0453 n   and   M HD = 2 0.0293 n ,
under a worst-case code rate of  k / n = 0.444  with  ω / n = H 1 ( 1 k / n ) = 0.065  and the following parameter values:
h = 2 , p n = 0.015 , l n = 0.071 ,
ϵ 0 ( 1 ) = 0.000000 , ϵ 1 ( 1 ) = 0.000004 .
Our algorithm achieves a runtime of  T HD = 2 0.0453 n , which represents a polynomial improvement over the previous best runtime of  2 0.0465 n  [41].
In the full-distance decoding scenario, optimization leads to complexities of
T FD = 2 0.0973 n   and   M FD = 2 0.0667 n ,
under a worst-case code rate of  k / n = 0.405  with  ω / n = H 1 ( 1 k / n ) = 0.144  and the following parameter values:
h = 3 , p n = 0.047 , l n = 0.171 ,
ϵ 0 ( 1 ) = 0.000000 , ϵ 1 ( 1 ) = 0.000062 ,
ϵ 0 ( 2 ) = 0.00000000 , ϵ 1 ( 2 ) = 0.00000009 .
The running time of our algorithm,  T FD = 2 0.0973 n , is faster than the previous best result of  2 0.1020 n  [22] achieved using representation techniques alone. However, it does not outperform the current state-of-the-art algorithm [41], which has a time complexity of  2 0.0885 n  and incorporates both representation techniques and nearest neighbor search. We speculate that combining our ternary representation technique with nearest neighbor search could lead to further improvements.

5.3. Improved Quantum ISD Algorithm

In this subsection, we detail the implementation of a quantum version of Algorithm 5. The quantum speedup over the classical algorithm primarily stems from two aspects: first, the accelerated search for a good permutation  Π , and second, the efficient identification of a valid vector  e  that meets the required conditions for a given permutation.
Kachigar and Tillich [23] suggested using Grover’s algorithm to search for good permutations. Grover’s algorithm [48] is an optimal method for unstructured search problems, offering a quadratic speedup over the best classical algorithms. The unstructured search problem involves finding an element x in a set   that is marked as “good” by a given oracle function  f : { 0 , 1 } , where  f ( x ) = 1  indicates that x is good. Let  η  denote the fraction of elements in   for which  f ( x ) = 1 . Grover’s algorithm finds a solution with  𝒪 ( 1 / η )  queries to f—compared to a classical lower bound of  Ω ( 1 / η ) —and, assuming an average query time of  T f , the total execution time is  𝒪 ( T f / η ) .
Algorithm 6 presents the oracle implementation for our quantum ISD algorithm. Specifically, the oracle function within the Grover search is realized through a quantum walk routine. The quantum ISD algorithm then operates by performing transformations on quantum states of the following form (normalization omitted):
i = 1 P ( p , ) | Π i | Π i ( P ) U j ( h ) J j ( N , k ) | U 1 ( h ) | U 2 × 3 h 1 ( h ) | aux | U 1 ( 0 ) Quantum Walk = Check for the outer Grover | Is Π good ?
The outer search applies Grover’s algorithm over a set of  P ( p , )  permutations. The validity of a permutation  Π  is verified via a quantum walk search, as detailed in Algorithm 6. After approximately  T QW  steps, the register  | U 1 ( 0 )  contains a non-empty level-0 list that yields the correct error vector provided that  Π  is a good permutation.
Thus, the total complexity of our quantum ISD algorithm is  𝒪 ( P ( p , ) · T QW ) . Optimization leads to complexities of
T QISD = 2 0.058326 n   and   M QISD = 2 0.020802 n ,
under a worst-case code rate of  k / n = 0.447  with  ω / n = H 1 ( 1 k / n ) = 0.128  and the following parameter values:
h = 2 , p n = 0.013 , l n = 0.052 ,
ϵ 0 ( 1 ) = 0.000000 , ϵ 1 ( 1 ) = 0.000011 .
Our quantum ISD algorithm achieves a runtime of  T QISD = 2 0.058326 n , yielding a polynomial improvement over the previous best quantum runtime of  2 0.058696 n  [23].
Algorithm 6 An oracle for quantum ISD algorithm
  1:
[Setup] Prepare the initial state (normalization omitted):
U j ( h ) J j ( N , k ) j = 1 | U j ( h ) | aux | 0 | 0 ,
where h denotes the depth of the search tree, the registers within the brackets are employed in the quantum walk search, and the last register is used to store the output of the oracle.
  2:
Repeat  𝒪 ( 1 / ϵ )  times:
  •     (2.1) [Checking] Perform the quantum walk checking.
  •     (2.2) [Update] Repeat  𝒪 ( 1 / δ )  times:
    •      (2.2.1) Perform a single step of the quantum walk.
    •      (2.2.2) Update the data structure.
  3:
The quantum state at this point is
U j ( h ) J j ( N , k ) j = 1 | U j ( h ) | aux | U 1 ( 0 ) | 0 .
A controlled operation is then applied, using the register storing  U 1 ( 0 )  as the control and the last register as the target, such that the bit in the last register is flipped if  U 1 ( 0 )  is non-empty.

6. Conclusions

In this work, we have presented significant advancements in solving RSSP and, by extension, the decoding problem for random linear codes in both the classical and quantum computational settings.
Our primary contribution is the introduction of a novel heuristic algorithm for RSSP based on a ternary tree representation structure. This approach, inspired by techniques in lattice-based cryptanalysis, fundamentally departs from the binary tree structures employed by all previous classical heuristic algorithms. Through meticulous numerical optimization, we demonstrated that our classical algorithm achieves a time complexity of  𝒪 ˜ 2 0.2400 n  and a space complexity of  𝒪 ˜ 2 0.2221 n , establishing a new state of the art for classical heuristic algorithms.
Building upon this classical foundation, we developed a novel quantum algorithm by integrating the ternary representation technique with a quantum walk search framework. The resulting algorithm achieves a time and space complexity of  𝒪 ˜ 2 0.1843 n , which, to the best of our knowledge, represents the best-known heuristic performance for RSSP on quantum computers.
We further demonstrated the cryptographic impact of our algorithms by applying them to the decoding problem. For half-distance decoding, our classical algorithm improves upon the state-of-the-art BM algorithm, reducing the time complexity from  𝒪 ˜ ( 2 0.0465 n )  to  𝒪 ˜ ( 2 0.0453 n ) . For full-distance decoding, while our result of  𝒪 ˜ ( 2 0.0973 n )  improves upon pure representation-based approaches like BJMM, it does not surpass the hybrid technique of Both–May. However, this strongly suggests a promising avenue for future work: integrating our ternary representation techniques with nearest neighbor search techniques could potentially lead to further breakthroughs in decoding complexity. In the quantum setting, our proposed ISD algorithm outperforms all previous works, achieving a time complexity of  𝒪 ˜ ( 2 0.058326 n ) .
Finally, while the quantum algorithms presented in this work achieve improved asymptotic complexities, their practical implementation remains challenging due to the exponential number of qubits required. Recent research directions have explored alternative quantum approaches that utilize only polynomial qubit resources, albeit at the cost of exponential classical memory or higher quantum time complexity [49,50]. Investigating such space-efficient implementations, which may be more amenable to future quantum hardware, represents an interesting direction for future work.

Funding

This work was supported by the Innovation Program for Quantum Science and Technology under Grant No. 2024ZD0300502 and the Beijing Nova Program under Grants No. 20220484128 and 20240484652.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The code associated with this submission is publicly available and can be accessed via the following link: https://gitee.com/li-yang777777/subset-sum (accessed on 22 August 2025).

Acknowledgments

The authors thank the reviewers for their valuable feedback and insightful suggestions, which greatly improved this manuscript.

Conflicts of Interest

The author declares no conflicts of interest.

Appendix A. TER with Arbitrary Depth

For arbitrary  d 2 , Algorithm A1 gives the pseudocode of TER with depth d. Following the same analytical approach as in Section 3, we start from the first level and compute the number of representations and expected list sizes for each level up to level d.
For each level i ( 1 i d 1 ), we define the following quantities:
  • Let  ϵ 1 ( i ) n  denote the number of representations of the form  1 + 1 + ( 1 ) 1 + ( 1 ) + 1 , or  ( 1 ) + 1 + 1 .
  • Let  ϵ 0 ( i ) n  denote the number of representations of the form  0 + 1 + ( 1 ) 0 + ( 1 ) + 1 1 + 0 + ( 1 ) ( 1 ) + 0 + 1 1 + ( 1 ) + 0 , or  ( 1 ) + 1 + 0 .
  • Let  ϵ 1 ( i ) n  denote the number of representations of the form  1 + ( 1 ) + ( 1 ) ( 1 ) + 1 + ( 1 ) , or  ( 1 ) + ( 1 ) + 1 .
  • Let  w ( i ) n  denote the number of  1 -coordinates.
  • Let  v ( i ) n  denote the number of 1-coordinates.
The result from level 1 is the same as the depth-3 case. Table 3 presents the number of each type of level-1 representations. Thus,  w ( 1 ) = ϵ 1 ( 1 ) + 2 ϵ 0 ( 1 ) , v ( 1 ) = 1 / 6 + w ( 1 ) , and the number of representations is
R ( 1 ) = n / 2 ϵ 1 ( 1 ) n , ϵ 1 ( 1 ) n , ϵ 1 ( 1 ) n , ( 1 / 6 ϵ 1 ( 1 ) ) n , ( 1 / 6 ϵ 1 ( 1 ) ) n , · × n / 2 ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , ϵ 0 ( 1 ) n , · .
Table A1 presents the number of each type of level-i ( 2 i d 1 )  representation. Then, for  2 i d 1 ,
w ( i ) = w ( i 1 ) / 3 + ϵ 1 ( i ) + ϵ 1 ( i ) + 2 ϵ 0 ( i ) , v ( i ) = 1 2 × 3 i + w ( i ) .
and the number of representations can be computed as follows:
R ( i ) = v ( i 1 ) n ϵ 1 ( i ) n , ϵ 1 ( i ) n , ϵ 1 ( i ) n , v ( i 1 ) 3 ϵ 1 ( i ) n , v ( i 1 ) 3 ϵ 1 ( i ) n , · × 1 v ( i 1 ) w ( i 1 ) n ϵ 0 ( i ) n , ϵ 0 ( i ) n , ϵ 0 ( i ) n , ϵ 0 ( i ) n , ϵ 0 ( i ) n , ϵ 0 ( i ) n , · × w ( i 1 ) n ϵ 1 ( i ) n , ϵ 1 ( i ) n , ϵ 1 ( i ) n , w ( i 1 ) 3 ϵ 1 ( i ) n , w ( i 1 ) 3 ϵ 1 ( i ) n , · .
Let  L ( i )  be the size of lists at level i for  1 i < d . Then, under Heuristic 2
L ( i ) = n w ( i ) n , v ( i ) n , · / R ( i ) , L ( d ) = n / 2 ( w ( d 1 ) / 2 ) n , ( v ( d 1 ) / 2 ) n , · .
The time complexity of Algorithm A1 is
max L ( d ) , L ( d ) 2 R ( d 1 ) , L ( d 2 ) 3 R ( d 2 ) / R ( d 1 ) , , L ( 1 ) 3 N / R ( 1 ) ,
and the space complexity is  max L ( d ) , , L ( 1 ) .
Algorithm A1 TER with depth d
Input: 
The random subset-sum instance  ( a , s ) ( Z N ) n + 1
Parameters: 
ϵ 1 ( 1 ) , ϵ 0 ( 1 ) , ϵ 1 ( i ) , ϵ 0 ( i ) , ϵ 1 ( i )  for  2 i < d .
Output: 
A solution  e D n 0 , 1 / 2  or ⊥ if no solution is found.
  1:
Construct all level-d lists  L j ( d )  for  j { 1 , , 2 × 3 d 1 } .
  2:
Compute  L j ( d 1 )  from  L 2 j 1 ( d ) , L 2 j ( d )  for  j { 1 , , 3 d 1 } .
  3:
for  i = d 2  down to 0 do
  4:
      for  j = 1  to  3 i  do
  5:
            Construct  L j ( i )  from  L 3 j 2 ( i + 1 ) , L 3 j 1 ( i + 1 ) , L 3 j ( i + 1 ) .
  6:
      end for
  7:
end for
  8:
if   L 1 ( 0 ) then
  9:
      return any  e L 1 ( 0 )
10:
else
11:
      return
12:
end if
Table A1. Count of different level-i ( 2 i d 1 )  representations.
Table A1. Count of different level-i ( 2 i d 1 )  representations.
RepresentationsCount
1-coordinates   1 + 0 + 0   v ( i 1 ) 3 ϵ 1 ( i ) n
  0 + 1 + 0   v ( i 1 ) 3 ϵ 1 ( i ) n
  0 + 0 + 1   v ( i 1 ) 3 ϵ 1 ( i ) n
  1 + 1 + ( 1 )   ϵ 1 ( i ) n
  1 + ( 1 ) + 1   ϵ 1 ( i ) n
  ( 1 ) + 1 + 1   ϵ 1 ( i ) n
0-coordinates   0 + 1 + ( 1 )   ϵ 0 ( i ) n
  0 + ( 1 ) + 1   ϵ 0 ( i ) n
  1 + 0 + ( 1 )   ϵ 0 ( i ) n
  ( 1 ) + 0 + 1   ϵ 0 ( i ) n
  1 + ( 1 ) + 0   ϵ 0 ( i ) n
  ( 1 ) + 1 + 0   ϵ 0 ( i ) n
  0 + 0 + 0   1 v ( i 1 ) w ( i 1 ) 6 ϵ 0 ( i ) n
1 -coordinates   ( 1 ) + 0 + 0   w ( i 1 ) 3 ϵ 1 ( i ) n
  0 + ( 1 ) + 0   w ( i 1 ) 3 ϵ 1 ( i ) n
  0 + 0 + ( 1 )   w ( i 1 ) 3 ϵ 1 ( i ) n
  1 + ( 1 ) + ( 1 )   ϵ 1 ( i ) n
  ( 1 ) + 1 + ( 1 )   ϵ 1 ( i ) n
  ( 1 ) + ( 1 ) + 1   ϵ 1 ( i ) n
Table A2 presents the time and space complexities of algorithms TER and QTER at various depths.
Table A2. Time and space complexities of TER and QTER at different depths.
Table A2. Time and space complexities of TER and QTER at different depths.
AlgorithmDepthTime ComplexitySpace Complexity
TER2   𝒪 ˜ ( 2 0.3251 n )   𝒪 ˜ ( 2 0.3251 n )
3   𝒪 ˜ ( 2 0.2400 n )   𝒪 ˜ ( 2 0.2221 n )
4   𝒪 ˜ ( 2 0.2400 n )   𝒪 ˜ ( 2 0.2221 n )
5   𝒪 ˜ ( 2 0.2400 n )   𝒪 ˜ ( 2 0.2221 n )
6   𝒪 ˜ ( 2 0.3017 n )   𝒪 ˜ ( 2 0.2164 n )
QTER2   𝒪 ˜ ( 2 0.2786 n )   𝒪 ˜ ( 2 0.2786 n )
3   𝒪 ˜ ( 2 0.1843 n )   𝒪 ˜ ( 2 0.1843 n )
4   𝒪 ˜ ( 2 0.2289 n )   𝒪 ˜ ( 2 0.2014 n )

Appendix B. Filtering Probability

In this section, we provide the formula for calculating the filtering probability, which is used in the numerical optimization of QTER.
Lemma A1.
For  0 i d 2 , let  e 1 ( i + 1 ) , e 2 ( i + 1 ) , e 3 ( i + 1 ) D n w ( i + 1 ) , 1 / ( 2 × 3 i + 1 ) . Then the level-i filtering probability of TER with depth d, denoted  p r ( i ) , is given by
v ( i + 1 ) n ϵ 1 ( i + 1 ) n , ϵ 1 ( i + 1 ) n , ϵ 0 ( i + 1 ) n , ϵ 0 ( i + 1 ) n , ϵ 1 ( i + 1 ) n , · × w ( i + 1 ) n ϵ 1 ( i + 1 ) n , ϵ 0 ( i + 1 ) n , ϵ 0 ( i + 1 ) n , ϵ 1 ( i + 1 ) n , ϵ 1 ( i + 1 ) n , · × 1 v ( i + 1 ) w ( i + 1 ) n ϵ 0 ( i + 1 ) n , ϵ 0 ( i + 1 ) n , v ( i ) 3 ϵ 1 ( i + 1 ) n n , v ( i ) 3 ϵ 1 ( i + 1 ) n n , w ( i ) 3 ϵ 1 ( i + 1 ) n n , w ( i ) 3 ϵ 1 ( i + 1 ) n n , · ÷ n v ( i + 1 ) n , w ( i + 1 ) n , · 2 .
Proof. 
Given a fixed vector  e 1 ( i + 1 ) D n w ( i + 1 ) , 1 / ( 2 × 3 i + 1 ) , we proceed to count the number of pairs  e 2 ( i + 1 ) , e 3 ( i + 1 ) D n w ( i + 1 ) , 1 / ( 2 × 3 i + 1 )  that are compatible with  e 1 ( i + 1 ) .
We begin by considering the coordinates where  e 1 ( i + 1 )  has a value of 1. The total number of such coordinates is  v ( i + 1 ) n = w ( i + 1 ) + 1 2 × 3 i + 1 n . According to Table A1, these coordinates are categorized into the following six types based on the values that  e 2 ( i + 1 )  and  e 3 ( i + 1 )  take at the same positions:
  • Type  1 + 0 + 0 , which occurs  v ( i ) / 3 ϵ 1 ( i + 1 ) n  times.
  • Type  1 + 1 + ( 1 ) , which occurs  ϵ 1 ( i + 1 ) n  times.
  • Type  1 + ( 1 ) + 1 , which occurs  ϵ 1 ( i + 1 ) n  times.
  • Type  1 + 0 + ( 1 ) , which occurs  ϵ 0 ( i + 1 ) n  times.
  • Type  1 + ( 1 ) + 0 , which occurs  ϵ 0 ( i + 1 ) n  times.
  • Type  1 + ( 1 ) + ( 1 ) , which occurs  ϵ 1 ( i + 1 ) n  times.
The number of ways to assign the values of  e 2 ( i + 1 )  and  e 3 ( i + 1 )  at these  v ( i + 1 ) n  positions, according to the above distribution, is given by the multinomial coefficient:
v ( i + 1 ) n ϵ 1 ( i + 1 ) n , ϵ 1 ( i + 1 ) n , ϵ 0 ( i + 1 ) n , ϵ 0 ( i + 1 ) n , ϵ 1 ( i + 1 ) n , · .
This corresponds to the first term in Expression (A1).
Similarly, the number of compatible pairs for the coordinates where  e 1 ( i + 1 )  takes the value 0 is given by the second term in Expression (A1), and the number for the coordinates where  e 1 ( i + 1 )  equals  1  corresponds to the third term in Expression (A1).
In order to obtain the probability, we divide the first three terms in Expression (A1) by
n v ( i + 1 ) n , w ( i + 1 ) n , · 2 ,
which corresponds to the total number of all possible pairs  ( e 2 ( i + 1 ) , e 3 ( i + 1 ) ) . □

Appendix C. Proof of Theorem 3

We proceed to prove the result stated in Theorem 3 of the main text.
Proof. 
Following [46], employ exponential sums with  e ( z ) = exp ( 2 π i z / M )  and the identity
λ = 0 M 1 e ( λ u ) = 0 , if u 0 ( mod M ) ; M , if u 0 ( mod M ) .
First prove that for  λ 1 , λ 2 0  the following identity holds:
a Z M n x B 1 y B 2 e ( λ 1 a · x + λ 2 a · y ) 2 = M n | B 1 | | B 2 | .
Calculate the left side of the above identity
a Z M n x B 1 y B 2 e ( λ 1 a · x + λ 2 a · y ) 2 = x , x B 1 y , y B 2 a Z M n e λ 1 ( a · x a · x ) + λ 2 ( a · y a · y )
By Equation (A2), if  x = x  and  y = y , the inner sum contributes  M n . If  x x  or  y y , assuming  y n y n  without loss of generality:
a Z M n e λ 1 ( a · x a · x ) + λ 2 ( a · y a · y ) = a Z M n e λ 1 ( a · x a · x ) ( a 1 , , a n 1 ) Z M n 1 e λ 2 j = 1 n 1 a j ( y j y j ) a n = 0 M 1 e λ 2 a n ( y n y n ) = 0 ,
establishing Equation (A3).
For fixed  a , independence of  a · x  and  a · y  gives
P a ( B 1 × B 2 , c 1 , c 2 ) = P a ( B 1 , c 1 ) · P a ( B 2 , c 2 ) .
From Equation (A2),
P a ( B 1 , c 1 ) = 1 M | B 1 | x B 1 λ 1 = 0 M 1 e λ 1 ( a · x c 1 ) ,
P a ( B 2 , c 2 ) = 1 M | B 2 | y B 2 λ 2 = 0 M 1 e λ 2 ( a · y c 2 ) .
Thus,
P a ( B 1 × B 2 , c 1 , c 2 ) = 1 M 2 | B 1 | | B 2 | x B 1 y B 2 λ 1 , λ 2 = 0 M 1 e λ 1 ( a · x c 1 ) + λ 2 ( a · y c 2 ) .
The contribution of the term corresponding to  λ 1 = λ 2 = 0  is  1 M 2 .
Therefore,
c 1 , c 2 Z M P a ( B 1 × B 2 , c 1 , c 2 ) 1 M 2 2 = c 1 , c 2 Z M 1 M 2 | B 1 | | B 2 | λ 1 , λ 2 = 1 M 1 e ( λ 1 c 1 λ 2 c 2 ) x B 1 y B 2 e ( λ 1 a · x + λ 2 a · y ) 2 = 1 M 4 | B 1 | 2 | B 2 | 2 c 1 , c 2 Z M λ 1 , λ 1 , λ 2 , λ 2 = 1 M 1 e c 1 ( λ 1 + λ 1 ) c 2 ( λ 2 + λ 2 ) x , x B 1 y , y B 2 e ( λ 1 a · x + λ 1 a · x + λ 2 a · y + λ 2 a · y ) = 1 M 4 | B 1 | 2 | B 2 | 2 λ 1 , λ 1 , λ 2 , λ 2 = 1 M 1 x , x B 1 y , y B 2 e ( λ 1 a · x + λ 1 a · x + λ 2 a · y + λ 2 a · y ) c 1 , c 2 Z M e c 1 ( λ 1 + λ 1 ) c 2 ( λ 2 + λ 2 ) .
The sum over  c 1 , c 2  vanishes if  λ 1 + λ 1 ¬ 0 ( mod M )  or  λ 2 + λ 2 ¬ 0 ( mod M )  and is equal to M otherwise. Hence,
c 1 , c 2 Z M P a ( B 1 × B 2 , c 1 , c 2 ) 1 M 2 2 = 1 M 2 | B 1 | 2 | B 2 | 2 λ 1 , λ 2 = 1 M 1 x , x B 1 y , y B 2 e λ 1 ( a · x a · x ) + λ 2 ( a · y + a · y ) = 1 M 2 | B 1 | 2 | B 2 | 2 λ 1 , λ 2 = 1 M 1 x B 1 y B 2 e ( λ 1 a · x + λ 2 a · y ) 2
Applying Equation (A3) yields the result. □

References

  1. Garey, M.R.; Johnson, D.S. Computers and Intractability: A Guide to the Theory of NP-Completeness; W.H. Freeman: San Francisco, CA, USA, 1979; p. 338. [Google Scholar]
  2. Merkle, R.; Hellman, M. Hiding information and signatures in trapdoor knapsacks. IEEE Trans. Inf. Theory 1978, 24, 525–530. [Google Scholar] [CrossRef]
  3. Chor, B.; Rivest, R.L. A knapsack-type public key cryptosystem based on arithmetic in finite fields. IEEE Trans. Inf. Theory 1988, 34, 901–909. [Google Scholar] [CrossRef]
  4. Impagliazzo, R.; Naor, M. Efficient cryptographic schemes provably as secure as subset sum. J. Cryptol. 1996, 9, 199–216. [Google Scholar] [CrossRef]
  5. Faust, S.; Masny, D.; Venturi, D. Chosen-ciphertext security from subset sum. In Public-Key Cryptography—PKC 2016; Springer International Publishing: Berlin/Heidelberg, Germany, 2016; pp. 35–46. [Google Scholar]
  6. Lyubashevsky, V.; Palacio, A.; Segev, G. Public-key cryptographic primitives provably as secure as subset sum. In Proceedings of the Theory of Cryptography Conference, Zurich, Switzerland, 9–11 February 2010; Springer International Publishing: Berlin/Heidelberg, Germany, 2010; pp. 382–400. [Google Scholar]
  7. Bonnetain, X. Improved low-qubit hidden shift algorithms. arXiv 2019, arXiv:1901.11428. [Google Scholar] [CrossRef]
  8. Bonnetain, X.; Schrottenloher, A. Quantum security analysis of CSIDH. In Proceedings of the Annual International Conference on the Theory and Applications of Cryptographic Techniques, Zagreb, Croatia, 10–14 May 2020; Springer International Publishing: Berlin/Heidelberg, Germany, 2020; pp. 493–522. [Google Scholar]
  9. Bonnetain, X.; Naya-Plasencia, M. Hidden shift quantum cryptanalysis and implications. In Proceedings of the International Conference on the Theory and Application of Cryptology and Information Security, Brisbane, QLD, Australia, 2–6 December 2018; Springer International Publishing: Berlin/Heidelberg, Germany, 2018; pp. 560–592. [Google Scholar]
  10. Galil, Z.; Margalit, O. An almost linear-time algorithm for the dense subset-sum problem. SIAM J. Comput. 1991, 20, 1157–1189. [Google Scholar] [CrossRef]
  11. Brickell, E.F. Solving low density knapsacks. In Advances in Cryptology: Proceedings of Crypto 83; Springer US: Boston, MA, USA, 1984; pp. 25–37. [Google Scholar]
  12. Lagarias, J.C.; Odlyzko, A.M. Solving low-density subset sum problems. J. ACM (JACM) 1985, 32, 229–246. [Google Scholar] [CrossRef]
  13. Ajtai, M. The shortest vector problem in L2 is np-hard for randomized reductions. In Proceedings of the Thirtieth Annual ACM Symposium on Theory of Computing, Dallas, TX, USA, 24–26 May 1998; Association for Computing Machinery: New York, NY, USA, 1998; pp. 10–19. [Google Scholar]
  14. Coster, M.J.; LaMacchia, B.A.; Odlyzko, A.M.; Schnorr, C.P. An improved low-density subset sum algorithm. In Proceedings of the Workshop on the Theory and Application of of Cryptographic Techniques, Brighton, UK, 8–11 April 1991; Springer International Publishing: Berlin/Heidelberg, Germany, 1991; pp. 54–67. [Google Scholar]
  15. Joux, A.; Stern, J. Improving the critical density of the Lagarias-Odlyzko attack against subset sum problems. In Proceedings of the International Symposium on Fundamentals of Computation Theory, Gosen, Germany, 9–13 September 1991; Springer International Publishing: Berlin/Heidelberg, Germany, 1991; pp. 258–264. [Google Scholar]
  16. Horowitz, E.; Sahni, S. Computing partitions with applications to the knapsack problem. J. ACM (JACM) 1974, 21, 277–292. [Google Scholar] [CrossRef]
  17. Schroeppel, R.; Shamir, A. A t = O(2n/2), s = O(2n/4) algorithm for certain np-complete problems. SIAM J. Comput. 1981, 10, 456–464. [Google Scholar] [CrossRef]
  18. Howgrave-Graham, N.; Joux, A. New generic algorithms for hard knapsacks. In Proceedings of the Annual International Conference on the Theory and Applications of Cryptographic Techniques, Zagreb, Croatia, 10–14 May 2020; Springer International Publishing: Berlin/Heidelberg, Germany, 2010; pp. 235–256. [Google Scholar]
  19. Becker, A.; Coron, J.; Joux, A. Improved generic algorithms for hard knapsacks. In Proceedings of the Annual International Conference on the Theory and Applications of Cryptographic Techniques, Zagreb, Croatia, 10–14 May 2020; Springer International Publishing: Berlin/Heidelberg, Germany, 2011; pp. 364–385. [Google Scholar]
  20. Bonnetain, X.; Bricout, R.; Schrottenloher, A.; Shen, Y. Improved classical and quantum algorithms for subset-sum. In Proceedings of the International Conference on the Theory and Application of Cryptology and Information Security, Brisbane, QLD, Australia, 2–6 December 2018; Springer International Publishing: Berlin/Heidelberg, Germany, 2020; pp. 633–666. [Google Scholar]
  21. May, A.; Meurer, A.; Thomae, E. Decoding random linear codes in  𝒪 ˜ (20.054n). In Proceedings of the International Conference on the Theory and Application of Cryptology and Information Security, Brisbane, QLD, Australia, 2–6 December 2018; Springer International Publishing: Berlin/Heidelberg, Germany, 2011; pp. 107–124. [Google Scholar]
  22. Becker, A.; Joux, A.; May, A.; Meurer, A. Decoding random binary linear codes in 2n/20: How 1 + 1 = 0 improves information set decoding. In Proceedings of the Annual International Conference on the Theory and Applications of Cryptographic Techniques, Zagreb, Croatia, 10–14 May 2020; Springer International Publishing: Berlin/Heidelberg, Germany, 2012; pp. 520–536. [Google Scholar]
  23. Kachigar, G.; Tillich, J. Quantum information set decoding algorithms. In Proceedings of the International Workshop on Post-Quantum Cryptography, Utrecht, The Netherlands, 26–28 June 2017; Springer International Publishing: Cham, Switzerland, 2017; pp. 69–89. [Google Scholar]
  24. Kirshanova, E. Improved quantum information set decoding. In Proceedings of the International Workshop on Post-Quantum Cryptography, Utrecht, The Netherlands, 26–28 June 2017; Springer International Publishing: Cham, Switzerland, 2018; pp. 507–527. [Google Scholar]
  25. May, A. How to meet ternary LWE keys. In Proceedings of the Annual International Cryptology Conference, Virtual, 16–20 August 2021; Springer International Publishing: Cham, Switzerland, 2021; pp. 701–731. [Google Scholar]
  26. van Hoof, I.; Kirshanova, E.; May, A. Quantum Key Search for Ternary LWE. In Proceedings of the International Workshop on Post-Quantum Cryptography, Utrecht, The Netherlands, 26–28 June 2017; Springer International Publishing: Cham, Switzerland, 2021; pp. 117–132. [Google Scholar]
  27. Kirshanova, E.; May, A. How to Find Ternary LWE Keys Using Locality Sensitive Hashing. In Proceedings of the IMA International Conference on Cryptography and Coding, Oxford, UK, 14–16 December 2021. [Google Scholar]
  28. Glaser, T.; May, A. How to Enumerate LWE Keys as Narrow as in Kyber/Dilithium. In Proceedings of the International Conference on Cryptology and Network Security, Singapore, 19–22 December 2023. [Google Scholar]
  29. Lee, E.; Lee, J.; Son, Y.; Wang, Y. Improved Meet-LWE Attack via Ternary Trees. Cryptology ePrint Archive, Paper 2024/824. Available online: https://eprint.iacr.org/2024/824 (accessed on 23 August 2025).
  30. Bernstein, D.J.; Jeffery, S.; Lange, T.; Meurer, A. Quantum algorithms for the subset-sum problem. In Proceedings of the International Workshop on Post-Quantum Cryptography, Utrecht, The Netherlands, 26–28 June 2017; Springer International Publishing: Berlin/Heidelberg, Germany, 2013; pp. 16–33. [Google Scholar]
  31. Helm, A.; May, A. Subset Sum Quantumly in 1.17n. In Proceedings of the 13th Conference on the Theory of Quantum Computation, Communication and Cryptography, Sydney, Australia, 16–18 July 2018; Schloss Dagstuhl–Leibniz-Zentrum für Informatik: Dagstuhl, Germany, 2018; pp. 5:1–5:15. [Google Scholar]
  32. Magniez, F.; Nayak, A.; Roland, J.; Santha, M. Search via quantum walk. SIAM J. Comput. 2011, 40, 142–164. [Google Scholar] [CrossRef]
  33. NIST. Status Report on the Fourth Round of the NIST Post-Quantum Cryptography Standardization Process. NIST Internal Report 8545. Available online: https://csrc.nist.gov/projects/post-quantum-cryptography/post-quantum-cryptography-standardization (accessed on 3 March 2025).
  34. Albrecht, M.R.; Bernstein, D.J.; Chou, T.; Cid, C.; Gilcher, J.; Lange, T.; Maram, V.; Von Maurich, I.; Misoczki, R.; Niederhagen, R.; et al. Classic McEliece: Conservative Code-Based Cryptography. In NIST Post-Quantum Standardization, 4th Round; National Institute of Standards and Technology: Gaithersburg, MD, USA, 2022; Available online: https://classic.mceliece.org/nist.html (accessed on 23 October 2022).
  35. Aragon, N.; Barreto, P.; Bettaieb, S.; Bidoux, L.; Blazy, O.; Deneuville, J.C.; Gaborit, P.; Ghosh, S.; Gueron, S.; Güneysu, T.; et al. BIKE: Bit Flipping Key Encapsulation. In NIST Post-Quantum Standardization, 4th Round; National Institute of Standards and Technology: Gaithersburg, MD, USA, 2024; Available online: https://bikesuite.org/ (accessed on 10 October 2024).
  36. Gaborit, P.; Aguilar-Melchor, C.; Aragon, N.; Bettaieb, S.; Bidoux, L.; Blazy, O.; Deneuville, J.C.; Persichetti, E.; Zémor, G.; Bos, J.; et al. Hamming Quasi-Cyclic (HQC). In NIST Post-Quantum Standardization, 4th Round; National Institute of Standards and Technology: Gaithersburg, MD, USA, 2025; Available online: https://pqc-hqc.org/resources.html (accessed on 22 August 2025).
  37. Prange, E. The use of information sets in decoding cyclic codes. IRE Trans. Inf. Theory 1962, 8, 5–9. [Google Scholar] [CrossRef]
  38. Stern, J. A method for finding codewords of small weight. In Proceedings of the International Colloquium on Coding Theory and Applications, Toulon, France, 2–4 November 1988; Springer International Publishing: Berlin/Heidelberg, Germany, 1988; pp. 106–113. [Google Scholar]
  39. Finiasz, M.; Sendrier, N. Security bounds for the design of code-based cryptosystems. In Proceedings of the International Conference on the Theory and Application of Cryptology and Information Security, Brisbane, QLD, Australia, 2–6 December 2018; Springer International Publishing: Berlin/Heidelberg, Germany, 2009; pp. 88–105. [Google Scholar]
  40. May, A.; Ozerov, I. On computing nearest neighbors with applications to decoding of binary linear codes. In Proceedings of the Annual International Conference on the Theory and Applications of Cryptographic Techniques, Zagreb, Croatia, 10–14 May 2020; Springer International Publishing: Berlin/Heidelberg, Germany, 2015; pp. 203–228. [Google Scholar]
  41. Both, L.; May, A. Decoding linear codes with high error rate and its impact for LPN security. In Proceedings of the International Conference on Post-Quantum Cryptography, Fort Lauderdale, FL, USA, 9–11 April 2018; Springer International Publishing: Cham, Switzerland, 2018; pp. 25–46. [Google Scholar]
  42. Esser, A.; Zweydinger, F. New time-memory trade-offs for subset sum–improving ISD in theory and practice. In Proceedings of the Annual International Conference on the Theory and Applications of Cryptographic Techniques, Zagreb, Croatia, 10–14 May 2020; Springer Nature Switzerland: Cham, Switzerland, 2023; pp. 360–390. [Google Scholar]
  43. Esser, A. Revisiting nearest-neighbor-based information set decoding. In Proceedings of the IMA International Conference on Cryptography and Coding, Oxford, UK, 14–16 December 2021; Springer Nature Switzerland: Cham, Switzerland, 2023; pp. 34–54. [Google Scholar]
  44. Furue, H.; Aikawa, Y. An Improved Both-May Information Set Decoding Algorithm: Towards More Efficient Time-Memory Trade-Offs. In Proceedings of the International Conference on Post-Quantum Cryptography, Fort Lauderdale, FL, USA, 9–11 April 2018; Springer Nature Switzerland: Cham, Switzerland, 2025; pp. 104–128. [Google Scholar]
  45. Bernstein, D.J. Grover vs. mceliece. In Proceedings of the International Workshop on Post-Quantum Cryptography, Utrecht, The Netherlands, 26–28 June 2017; Springer International Publishing: Berlin/Heidelberg, Germany, 2010; pp. 73–80. [Google Scholar]
  46. Nguyen, P.Q.; Shparlinski, I.E.; Stern, J. Distribution of modular sums and the security of the server aided exponentiation. In Cryptography and Computational Number Theory; Birkhäuser: Basel, Switzerland, 2001; pp. 331–342. [Google Scholar]
  47. Ambainis, A. Quantum walk algorithm for element distinctness. SIAM J. Comput. 2007, 37, 210–239. [Google Scholar] [CrossRef]
  48. Grover, L.K. Quantum computers can search arbitrarily large databases by a single query. Phys. Rev. Lett. 1997, 79, 4709–4712. [Google Scholar] [CrossRef]
  49. Helm, A.; May, A. The power of few qubits and collisions–subset sum below Grover’s bound. In Proceedings of the International Conference on Post-Quantum Cryptography, Fort Lauderdale, FL, USA, 9–11 April 2018; Springer Nature Switzerland: Cham, Switzerland, 2020; pp. 445–460. [Google Scholar]
  50. Chevignard, C.; Fouque, P.A.; Schrottenloher, A. Reducing the number of qubits in quantum information set decoding. In Proceedings of the International Conference on the Theory and Application of Cryptology and Information Security, Brisbane, QLD, Australia, 2–6 December 2018; Springer Nature Singapore: Singapore, 2024; pp. 299–329. [Google Scholar]
Figure 1. The tree structure of the HGJ algorithm. The darker regions indicate portions where the modulus constraint has been established.
Figure 1. The tree structure of the HGJ algorithm. The darker regions indicate portions where the modulus constraint has been established.
Information 16 00887 g001
Figure 2. The ternary tree structure of TER. The darker regions indicate portions where the modulus constraint has been established.
Figure 2. The ternary tree structure of TER. The darker regions indicate portions where the modulus constraint has been established.
Information 16 00887 g002
Table 1. Comparison of complexity exponent of subset-sum algorithms: classical and quantum approaches.
Table 1. Comparison of complexity exponent of subset-sum algorithms: classical and quantum approaches.
AlgorithmTime ComplexitySpace Complexity
ClassicalHGJ   0.337   0.311
BCJ   0.291   0.291
BBSS   0.2830   0.2830
Ours   0 . 2400   0 . 2221
QuantumBJLM   0.241   0.241
HM   0.226   0.226
BBSS   0.2182   0.2182
Ours   0 . 1843   0 . 1843
Note: Bold values highlight the best (lowest) complexity exponents in each category.
Table 2. Comparison of time complexity exponent of ISD: classical and quantum approaches.
Table 2. Comparison of time complexity exponent of ISD: classical and quantum approaches.
AlgorithmFull DistanceHalf Distance
ClassicalPrange   0.1206   0.0576
MMT   0.1116   0.0537
BJMM   0.1019   0.0494
MO   0.0953   0.0473
BM   0 . 0885   0.0465
Ours   0.0973   0 . 0453
QuantumBernstein   0.060350  
KT   0.058696  
Kirshanova   0.059450  
Ours   0 . 058326  
Note: Bold values highlight the best (lowest) complexity exponents in each category.
Table 3. Count of different level-1 representations.
Table 3. Count of different level-1 representations.
RepresentationsCount
1-coordinates   1 + 0 + 0   ( 1 / 6 ϵ 1 ( 1 ) ) n
  0 + 1 + 0   ( 1 / 6 ϵ 1 ( 1 ) ) n
  0 + 0 + 1   ( 1 / 6 ϵ 1 ( 1 ) ) n
  1 + 1 + ( 1 )   ϵ 1 ( 1 ) n
  1 + ( 1 ) + 1   ϵ 1 ( 1 ) n
  ( 1 ) + 1 + 1   ϵ 1 ( 1 ) n
0-coordinates   0 + 1 + ( 1 )   ϵ 0 ( 1 ) n
  0 + ( 1 ) + 1   ϵ 0 ( 1 ) n
  1 + 0 + ( 1 )   ϵ 0 ( 1 ) n
  ( 1 ) + 0 + 1   ϵ 0 ( 1 ) n
  1 + ( 1 ) + 0   ϵ 0 ( 1 ) n
  ( 1 ) + 1 + 0   ϵ 0 ( 1 ) n
  0 + 0 + 0   ( 1 / 2 6 ϵ 0 ( 1 ) ) n
Table 4. Count of different level-2 representations.
Table 4. Count of different level-2 representations.
RepresentationsCount
1-coordinates   1 + 0 + 0   ( 1 / 18 + w ( 1 ) / 3 ϵ 1 ( 2 ) ) n
  0 + 1 + 0   ( 1 / 18 + w ( 1 ) / 3 ϵ 1 ( 2 ) ) n
  0 + 0 + 1   ( 1 / 18 + w ( 1 ) / 3 ϵ 1 ( 2 ) ) n
  1 + 1 + ( 1 )   ϵ 1 ( 2 ) n
  1 + ( 1 ) + 1   ϵ 1 ( 2 ) n
  ( 1 ) + 1 + 1   ϵ 1 ( 2 ) n
0-coordinates   0 + 1 + ( 1 )   ϵ 0 ( 2 ) n
  0 + ( 1 ) + 1   ϵ 0 ( 2 ) n
  1 + 0 + ( 1 )   ϵ 0 ( 2 ) n
  ( 1 ) + 0 + 1   ϵ 0 ( 2 ) n
  1 + ( 1 ) + 0   ϵ 0 ( 2 ) n
  ( 1 ) + 1 + 0   ϵ 0 ( 2 ) n
  0 + 0 + 0   ( 5 / 6 2 w ( 1 ) 6 ϵ 0 ( 2 ) ) n
1 -coordinates   ( 1 ) + 0 + 0   ( w ( 1 ) / 3 ϵ 1 ( 2 ) ) n
  0 + ( 1 ) + 0   ( w ( 1 ) / 3 ϵ 1 ( 2 ) ) n
  0 + 0 + ( 1 )   ( w ( 1 ) / 3 ϵ 1 ( 2 ) ) n
  1 + ( 1 ) + ( 1 )   ϵ 1 ( 2 ) n
  ( 1 ) + 1 + ( 1 )   ϵ 1 ( 2 ) n
  ( 1 ) + ( 1 ) + 1   ϵ 1 ( 2 ) n
Table 5. Count of different level-i ( 1 i h 1 )  representations.
Table 5. Count of different level-i ( 1 i h 1 )  representations.
RepresentationsCount
1-coordinates   1 + 0 + 0   p ( i 1 ) ϵ 1 ( i ) n 3
  0 + 1 + 0   p ( i 1 ) ϵ 1 ( i ) n 3
  0 + 0 + 1   p ( i 1 ) ϵ 1 ( i ) n 3
  1 + 1 + 1   ϵ 1 ( i ) n
0-coordinates   0 + 1 + 1   ϵ 0 ( i ) n
  1 + 0 + 1   ϵ 0 ( i ) n
  1 + 1 + 0   ϵ 0 ( i ) n
  0 + 0 + 0   k + p ( i 1 ) 3 ϵ 0 ( i ) n
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Li, Y. From Subset-Sum to Decoding: Improved Classical and Quantum Algorithms via Ternary Representation Technique. Information 2025, 16, 887. https://doi.org/10.3390/info16100887

AMA Style

Li Y. From Subset-Sum to Decoding: Improved Classical and Quantum Algorithms via Ternary Representation Technique. Information. 2025; 16(10):887. https://doi.org/10.3390/info16100887

Chicago/Turabian Style

Li, Yang. 2025. "From Subset-Sum to Decoding: Improved Classical and Quantum Algorithms via Ternary Representation Technique" Information 16, no. 10: 887. https://doi.org/10.3390/info16100887

APA Style

Li, Y. (2025). From Subset-Sum to Decoding: Improved Classical and Quantum Algorithms via Ternary Representation Technique. Information, 16(10), 887. https://doi.org/10.3390/info16100887

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop