Title: SALSA VERDE: a machine learning attack on LWE with sparse small secrets
Venue: NeurIPS 2023
Accepted: yes
Keywords: machine learning

cryptography

cryptanalysis
Abstract: Learning with Errors (LWE) is a hard math problem used in post-quantum cryptography. Homomorphic Encryption (HE) schemes rely on the hardness of the LWE problem for their security, and two LWE-based cryptosystems were recently standardized by NIST for digital signatures and key exchange (KEM).  Thus, it is critical to continue assessing the security of LWE and specific parameter choices. For example, HE uses secrets with small entries, and the HE community has considered standardizing small sparse secrets to improve efficiency and functionality.  However, prior work, SALSA and PICANTE, showed that ML attacks can recover sparse binary secrets. Building on these, we propose VERDE, an improved ML attack that can recover sparse binary, ternary, and narrow Gaussian secrets. Using improved preprocessing and secret recovery techniques, VERDE can attack LWE with larger dimensions ($n=512$) and smaller moduli ($\log_2 q=12$ for $n=256$), using less time and power. We propose novel architectures for scaling. Finally, we develop a theory that explains the success of ML LWE attacks.

SALSA VERDE: a machine learning attack on Learning With Errors with sparse small secrets

Abstract

Learning with Errors (LWE) is a hard math problem used in post-quantum cryptography. Homomorphic Encryption (HE) schemes rely on the hardness of the LWE problem for their security, and two LWE-based cryptosystems were recently standardized by NIST for digital signatures and key exchange (KEM). Thus, it is critical to continue assessing the security of LWE and specific parameter choices. For example, HE uses secrets with small entries, and the HE community has considered standardizing small sparse secrets to improve efficiency and functionality. However, prior work, SALSA and PICANTE, showed that ML attacks can recover sparse binary secrets. Building on these, we propose VERDE, an improved ML attack that can recover sparse binary, ternary, and narrow Gaussian secrets. Using improved preprocessing and secret recovery techniques, VERDE can attack LWE with larger dimensions ( n = 512 ) and smaller moduli ( log 2 q = 12 for n = 256 ), using less time and power. We propose novel architectures for scaling. Finally, we develop a theory that explains the success of ML LWE attacks.

1 Introduction

Language models have been successfully applied to numerous practical science problems in recent years. For example, transformers [57] have been used to solve problems in mathematics [40, 24], theoretical physics [26], chemistry [50], and biology [46]. In this paper, we present an application of transformers to computer security: the cryptanalysis of Learning With Errors (LWE) [45], a hard math problem underpinning leading proposals for post-quantum public key cryptography.

Public-key cryptosystems are the main solution for secure communication over the Internet. Public keys can be used to encode messages or verify digital signatures to or from a user with the corresponding private key. Security relies on the fact that recovering the private key from the public data requires solving a computationally hard math problem. Most currently deployed public-key systems are based on RSA [47], which relies on the hardness of factoring large numbers into products of primes. Unfortunately, large-scale quantum computers will enable implementation of Shor's algorithm [52], which can factor integers in quantum polynomial time and break such systems. As a result, new hard problems are sought to serve as the basis of post-quantum public key cryptography (PQC). The US National Institute of Standards and Technology (NIST) ran a 5 year competition to define future PQC standards [2], and standardized 4 PQC systems in July 2022 [17]. Two of these rely on special cases of the same hard (and Shor-free) problem: Learning with Errors (LWE).

The Learning With Errors problem (LWE) assumes that it is hard to recover a secret vector s , given many LWE samples ( a , b ) . In a LWE sample, each a is a random vector of n integers modulo q ( n is the dimension and q is the modulus), and b is a noisy modular inner product of a and the secret key s -that is, b = a · s + e mod q , with the error e drawn from a Gaussian distribution of

width σ e centered at 0 , e ∼ N (0 , σ 2 e ) and σ e ≪ q . The hardness of LWE is related to the hardness of well-known lattice problems such as the (approximate) Shortest Vector Problem (SVP).

Most classical attacks on LWE rely on lattice reduction [41, 49, 19]. For example, given m samples ( a i , b i ) , create a matrix A m × n whose m rows are the vectors a i . The unique shortest vector problem (uSVP) attack recovers the secret s by finding the shortest vector in a lattice constructed from b , the columns of A m × n , and other parameters. The best known algorithms for solving SVP run in time exponential in the dimension n . Somewhat counter-intuitively, the smaller the modulus q , the harder the LWE problem. Approximate solutions can be computed in polynomial time with LLL [41], but the approximation factor is exponentially bad (exponential in n ). We compare our results with uSVP attacks on LWE in §A.7.

Machine learning (ML) attacks on LWE. SALSA [58], the seminal ML attack on LWE, uses a large collection of LWE samples { ( a , b ) } with the same secret s to train a transformer [57] that predicts b from a . SALSA presents methods for secret recovery via queries to the trained model, and observes that high model accuracy is not needed: secrets are recovered as soon as the transformer starts to learn (training loss drops). SALSA is a proof of concept, recovering binary secrets with 3 or 4 nonzero bits for problems with dimension up to 128 , small instances of LWE solvable via exhaustive search.

PICANTE builds on an observation from SALSA ([58, Table 4]): transformers trained on LWE samples { ( a , b ) } , with entries of a drawn from a restricted range instead of all of [0 , q ) , can recover binary secrets with larger Hamming weights h (number of nonzero bits). So PICANTE introduces a data preprocessing phase during which the LWE samples ( a , b ) are processed by BKZ, a lattice reduction algorithm, to obtain LWE samples with the same secret but smaller coordinate variance (and larger error, see §2). In addition to training the transformer on the preprocessed samples, PICANTE reduces the number of LWE samples required for the attack from 4 million in SALSA to 4 n (e.g. 1400 for n = 350 ), and improves secret recovery. Overall, PICANTE can recover binary secrets for dimensions up to 350 and Hamming weight up to 60 . This is a considerable improvement over SALSA, faster than the uSVP attacks we compare against, and out of reach for exhaustive search.

PICANTE has several limitations . First, it only recovers sparse binary secrets, an important but limited subclass of LWE. Homomorphic encryption (HE) may use binary secrets, but HE and other PQC schemes typically use ternary ( s i ∈ {-1 , 0 , 1 } ) or small ( | s i | < k , k small) secrets. Second, PICANTE's preprocessing is costly as dimension increases, making it difficult to scale PICANTE to dimensions larger than 350 . For n = 512 , log 2 q = 45 , PICANTE's preprocessing approach could not finish in a month with full parallelization. Third, PICANTE only experiments with large modulus q : log 2 q = 23 for n = 256 , log 2 q = 27 for n = 300 , and log 2 q = 32 for n = 350 . Practical LWE-based systems use small q : LIZARD [21] recommends log 2 q = 10 for n = 608 with sparse binary secrets, and the HE standard [4] recommends log 2 q = 25 for n = 1024 with ternary secrets.

Our work, SALSA VERDE , improves on PICANTE and makes the following contributions:

We introduce a two-bit distinguisher, a new secret recovery technique for sparse binary, ternary and small Gaussian secrets. VERDE fully recovers binary and ternary secrets equally well (§3).

We improve data preprocessing techniques , making them forty times faster and 20% more effective, enabling recovery of binary, ternary and small Gaussian secrets for dimension 512 (§4).

We decrease the modulus q , showing VERDE outperforming uSVP attacks (§5 and §A.7).

We propose NoMod , a framework for understanding the success of ML-based LWE attacks (§5).

We present a theoretical analysis to show heuristically that successful secret recovery depends only on √ h and the standard deviation of the distribution of the LWE data (§6).

We experiment with encoder-only models and compare their success with seq2seq models (§7).

Key results. Our main finding is that small, sparse LWE secrets are weak. For dimension n = 256 , we can recover binary and ternary secrets with 10% sparsity ( h/n ) for log 2 q = 20 , and with 3% sparsity when log 2 q = 12 (Table 1). For n = 512 , log 2 q = 41 , we recover binary and ternary secrets with ≥ 11% sparsity. Furthermore, VERDE scales well to higher dimensions for small sparse secret recovery. Training VERDE models on n = 256 / 350 / 512 problems takes only 1.5/1.6/2.5 hours per epoch, a small proportional increase compared to the increase in n . Also, we find that VERDE runs faster than uSVP attacks, at the expense of using more compute resources in parallel (see A.7).

In Table 1, we report the timings for successful secret recoveries, for binary/ternary/Gaussian secrets, with varying n and log q . The table records the highest h recovered for each column: for binary secrets,

h is the Hamming weight, and for ternary and Gaussian secrets, h is the number of non-zero entries. We record the amount of time needed for each stage of the attack, preprocessing (in hours/CPU, assuming full parallelization), model training (hours/epoch · (# epochs)), and total attack time. For full parallelization, the number of CPU cores required is 4 million divided by 2 n . Source code and parameters to reproduce our main experiments are included in the supplementary material. The full code base will be open-sourced.

Scope of results. Instances of cryptographic problems like LWE can be broadly categorized as easy (solvable via exhaustive search), medium-to-hard (requiring significant resources to solve), or standardized (believed secure). VERDE attacks medium-to-hard LWE problems (parameterized by dimension n , Hamming weight h , modulus q ). VERDE does not attack toy problems (like SALSA did), nor does it attack the NIST standard directly. Rather, VERDE demonstrates successful attacks on medium-to-hard LWE problems using tools from AI, improving our understanding of the security of proposed LWE-based cryptosystems.

2 SALSA VERDE Overview

In this section we describe the SALSA VERDE attack and relevant parts of its predecessor PICANTE.

If

use 2-bit distinguisher

Data preparation

Model training

Secret recovery

Reduce

with BKZ

Distinguisher

4n LWE

samples

Train transformer on

BKZ-reduced samples

4

Run secret recovery

on trained model

5

After each

If          , stop;

else, keep training

matrices

1

2

3

...

make

or

RBKZAi

(RA, Rb)

Rb

=

R(A

s + e)

i

i

High-level overview. Like PICANTE, VERDE starts with 4 n LWE samples with the same secret s . In practice, this data would be eavesdropped. VERDE then proceeds in three stages: preprocessing, model training and secret recovery (see Figure 1). The preprocessing stage augments the 4 n initial ( a , b ) pairs to 2 million, then runs lattice reduction to yield a training set of 4 million samples with the same secret s . The preprocessed data is used to train a transformer to predict b from a . After each training epoch (2 million LWE samples), the model is queried to form a secret guess. The attack succeeds if the secret guess is correct, tested via statistical methods without knowledge of the actual secret. Otherwise, the model is trained for another epoch, and secret recovery is run again.

Data preprocessing. VERDE's preprocessing is similar to PICANTE's, with several improvements. First, we create n × n matrices A i by sampling without replacement n of the 4 n original LWE samples. Then, we apply lattice reduction to the matrices A i to reduce the standard deviation of their entries (initially uniformly distributed over [0 , q ) ). This process generates 2 n preprocessed samples ( a ′ , b ′ ) , with the same secret and is implemented in parallel to create a training set of 4 million samples.

During lattice reduction, PICANTE applies BKZ (as implemented in fplll [27]) to the 2 n × 2 n matrix:

Λ i = [ ω · I n A i 0 q · I n ] . BKZ finds a linear transformation [ R i C i ] such that the norms of the 2 n rows of [ R i C i ] Λ i = [ ω · R i R i A i + q · C i ] are small. Applying R i to A i and b i , PICANTE generates 2 n reduced LWE pairs ( R i A i , R i b i ) (modulo q ). VERDE instead rearranges the rows of Λ i and applies lattice reduction to Λ ′ i = [ 0 q · I n ω · I n A i ] . This reduces the number of operations needed for lattice reduction and allows BKZ to run with lower floating point precision. These two improvements cut the preprocessing time significantly.

They also result in smaller R i norms (smaller error in R i b i ), which can be leveraged to further reduce the norm of R i A i + q · C i by using a lower ω parameter ( ω = 10 ) than PICANTE ( ω = 15 ). Finally, VERDE replaces BKZ with two interleaved algorithms (BKZ 2.0 [19] and the efficient reduction technique introduced in [15]), adaptively increases the blocksize and precision as reduction progresses, and introduces a stopping condition. For instance, for n = 256 and log 2 q = 20 , VERDE's preprocessing is 45 × faster, while improving the quality of the reduction by 20% (Table 2).

Quality of reduction is measured by the standard deviation of the entries of A i . Preprocessing time in Table 2 is the hours needed to process one matrix on a single CPU. We list the time for all n, q attempted in Tables 5 and 19. For each dimension n and modulus q , we process 2 million /n matrices in parallel across hundreds of CPUs, see §A.1 for details. Better preprocessing allows VERDE to scale to larger dimensions and retrieve secrets with larger h .

Transformer training. The 4 million reduced LWE pairs are used to train a transformer to predict b from a . The values b and the coordinates of a are integers in [0 , q ) . They are represented in base B = ⌈ q/ 8 ⌉ (for log 2 q > 30 , B = ⌈ q/ 16 ⌉ ) and encoded as sequences of two tokens over a vocabulary of 2 , 000 (see §A.1 for a discussion of these choices). Model training is framed as a translation task, from a sequence of 2 n tokens representing a to a sequence of 2 tokens representing b (see [40, 12] for similar uses of transformers for mathematical calculations). The model is trained to minimize the cross-entropy between model prediction and the sequence of tokens representing b , using the Adam optimizer with warmup [39] and a learning rate of 10 -5 . For n = 256 , 350 and 512 , each epoch uses 2 million LWE samples and runs for 1 . 5 , 1 . 6 , or 2 . 5 hours. Time/epoch doesn't vary with q or secret type. Our models train on one NVIDIA V100 32GB GPU and often succeed in the first epoch for low h . Number of epochs required are included in many tables throughout, including Tables 3 and 4.

VERDE uses the same architecture as PICANTE: a sequence to sequence (seq2seq) transformer [57], with a one-layer encoder (dimension 1024 , 4 attention heads), and a 9-layer decoder (dimension 512 , 4 heads). The last 8 layers of the decoder are shared (i.e. they form a Universal Transformer [25]). Iteration through shared loops is controlled by the copy-gate mechanism introduced in [22].

Seq2seq models allow output sequences to be longer than inputs, a useful feature for machine translation but not necessary in our setting. For comparison, we also implement a simpler encoderonly transformer, that is 4-layer BERT-like (dimension 512 , 4 heads), together with rotary word embeddings (analogous to the rotary position embeddings [55]) to account for the modular nature of the problem. On top of this, we also add an earth mover's distance (EMD) auxiliary objective. We compare this model's performance to that of the seq2seq model (§7).

Secret recovery. Secret recovery runs after each epoch ( 2 million LWE samples). PICANTE used three recovery methods: direct recovery, cross-attention and distinguisher. Direct recovery struggles as dimension increases, because it relies on accurate model evaluations at special a values which are out of distribution for the training set. Cross-attention is incompatible with encoder-only architectures and is consistently outperformed by the distinguisher on VERDE-preprocessed data. Thus, VERDE only uses the distinguisher, which works as follows: for any test vector a test and random K , if the i -th entry of the secret s i is zero, then ( a test + K e i ) · s = a test · s (where e i is the i -th standard basis vector). Therefore, for each i , the distinguisher computes the difference between model predictions on a test and a test + K e i for different a test. If differences are small, the corresponding s i is likely zero. For ternary and Gaussian secrets, the distinguisher is modified (see §3).

For successful secret recovery, the trained model must generalize well to { a test } , the vectors used for testing. In PICANTE, the distinguisher runs on random a test, with coordinates uniform in [0 , q ) . However, the model is trained on preprocessed a train, with a non-uniform coordinate distribution. So PICANTE's distinguisher recovery requires that the model generalize outside its training distribution.

This is known to be a difficult ML task. Instead, VERDE runs the distinguisher on a held-out subset of 128 preprocessed vectors a test. Since the test vectors have the same distribution as the training set, the trained model only needs to generalize in-distribution, a much easier task. This change in a test improves the performance of the distinguisher (see Table 14 in §A.4).

In practice, for each secret coordinate, the distinguisher computes the sum of the absolute difference between model predictions at a test and a test + K e i , for 128 vectors a test and a random K ∈ (0 . 3 q, 0 . 7 q ) for each a test. The model makes a secret prediction s ′ by setting the bits to 1 on the h coordinates with the largest sums, and verifies s ′ by computing a · s ′ -b on the original 4 n LWE samples. If the secret is correctly predicted, this quantity should always be small. The statistical properties of this test are discussed in section A.2 of [42].

Having discussed VERDE's background and described its methodology, we now present VERDE's key results, as summarized in §1. We begin with results on ternary and narrow Gaussian secrets.

3 Secret Distributions

One of VERDE's major contributions is a method to recover secrets from sparse ternary and narrow Gaussian distributions, both of which are being considered for use in real-world cryptosystems [4]. Prior ML-based LWE attacks (PICANTE and SALSA) only recovered sparse binary secrets. Here, we describe VERDE's method for recovering these more general secret distributions, and its performance on ternary and small Gaussian secrets for fixed dimension n = 256 and log 2 q = 20 . Throughout this paper, h denotes the number of nonzero entries in a secret, which is equal to the Hamming weight in the binary case. We define secret sparsity as the percentage of nonzero secret entries h/n .

Recovering ternary and small Gaussian secrets. In lattice-based cryptography, ternary secrets are vectors s of dimension n , with entries equal to 0 , 1 , or -1 (with equal probability of 1 and -1 in sparse secrets). Gaussian secrets are vectors s of dimension n , with entries drawn from a Gaussian distribution with small standard deviation σ . In this paper, we use σ = 3 . The Homomorphic Encryption Standard [4] includes secure parameter choices for Gaussian secrets with σ = 3 . 2 .

Ternary and Gaussian secrets introduce new challenges for ML-based attacks on LWE. The recovery methods in PICANTE distinguish zero from nonzero bits. In the binary case, this produces one guess s guess, which can be verified by checking that b -a · s guess is small. In the ternary case, PICANTE would produce 2 h secret guesses (about 12 h guesses for Gaussian secrets), due to the additional -1 entries, and verification becomes very expensive as h increases. VERDE recovers ternary secrets using a two-step approach: first, partial recovery distinguishes zero from nonzero entries, then full recovery guesses the sign of the nonzero bits.

Partial recovery. To identify nonzero bits, VERDE uses the binary secret distinguisher from §2 (after [42, Section 4.3]). For each secret bit, it computes a score from a sample of reduced LWE pairs. The h bits with the highest scores are candidate nonzero bits. VERDE assumes h is not known and runs the next step for all reasonable possible values of h , e.g. from 1 to n/ 20 . Partial recovery alone is a major contribution, as we are not aware of existing attacks that can identify nonzero secret bits.

̸

Full recovery (ternary secrets). To determine whether nonzero bits of a ternary secret are 1 or -1 , VERDE introduces a novel two-bit distinguisher, leveraging the following observation. If two nonzero secret bits s i and s j are equal, then for any a , exchanging the coordinates a i and a j will result in the same b , and corresponding model predictions will be close. Otherwise, model predictions will be different (if s i = s j ). Similarly, if s i = s j , for any a and c = 0 , changing a i → a i + c and a j → a j -c yields the same b , and close model predictions. The two-bit distinguisher uses these techniques to compare each nonzero bit with all others, therefore defining two classes of nonzero bits. Letting one class of bits be 1 or -1 , VERDE produces two secret guesses to be verified.

̸

Full recovery (Gaussian secrets). At present, we implemented full recovery only for binary and ternary secrets. However, full recovery of small Gaussian secrets is possible via the following adaptation of the two-bit distinguisher. The two-bit distinguisher groups nonzero secret bits into k classes believed to have the same value. In our case, the nonzero bits follow a Gaussian distribution with σ = 3 , so we may safely assume that all non-zero secret bits are in [ -9 , 9] (within 3 standard deviations) - i.e. k = 18 . Since the secret is Gaussian, we expect the largest classes to correspond to the values -1 and 1 , followed by -2 and 2 , and so on. Therefore, we can intelligently assign values to classes based on class size, and test the corresponding 2 k/ 2 = 512 secrets. We leave

implementation of this as future work and report the performance of partial Gaussian secret recovery, using knowledge of s to validate correctness.

VERDE's performance across secret distributions.

VERDE recovers ternary secrets with sparsity up to 10% , with comparable performance on binary secrets. Table 3 provides details on partial and full ternary secret recovery for n = 256 and log 2 q = 20 and h = 5 - -25 . For low values of h ( h < 20 ), ternary secrets are partially recovered early during training (i.e. mostly in epoch 0 or 1 , during the first pass on preprocessed data), and usually fully recovered in the same epoch or shortly after. As h increases, more training is required for recovery, and the delay between partial and full recovery increases.

For small Gaussian secrets , VERDE only implements par- tial recovery (recovery of the nonzero bits). Table 4 presents results for n = 350 and log 2 q = 27 . Recovered h are lower than in the binary case, and models require less training for low h .

Figure 2 compares VERDE's performance across secret distributions for problems with n = 256 and different moduli q . For each setting, we run 100 recovery experiments and report the highest h secret recovered in those attempts. Recovery is comparable for binary and ternary secrets. Small Gaussian secrets are significantly harder.

4 Large Dimension

The hardness of LWE increases as n grows. PICANTE recovered sparse binary secrets for dimension up to n = 350 . VERDE pushes this limit to n = 512 , for sparse binary, ternary, and narrow Gaussian secrets. For n = 512 and log 2 q = 41 , VERDE recovers binary and ternary secrets with sparsity up to 0 . 12 (highest h = 63 , 60 ) and Gaussian secrets with h up to 16 . The longer VERDE's preprocessing step runs, the higher h secrets it can recover. Recall that real-world schemes like LIZARD operate in dimension n = 608 [21] and HE in dimension n = 1024 [4]. Those systems use significantly smaller q where LWE is harder: log 2 q = 10 and 27 , respectively, compared to VERDE's log 2 q = 41 .

VERDE's performance in large dimension. Table 5 shows VERDE's performance for dimension n = 512 , after 7 to 35 days of preprocessing, on the same set of matrices A i . For each preprocessing time, we measure the quality of lattice reduction via a 'reduction factor,' computed by taking the ratio of the standard deviation of reduced A i entries to the standard deviation of a random matrix with uniform coefficients 0 ≤ a i < q , i.e. stddev ( A bkz ) stddev ( A rand ) , with stddev ( A rand ) = q √ 12 . This metric, used in PICANTE for selecting BKZ parameters, is discussed in § 6. As Table 5 demonstrates, the maximum recoverable h is strongly correlated to the quality of lattice reduction.

Preprocessing adjustments for large n . Scaling up to n = 512 requires a number of adjustments to our preprocessing methodology. For n = 512 , the first loops in BKZ 2.0 are very slow. To avoid this, we use BKZ with smaller blocksizes than those used for n = 256 and 350 (see §A.1). Also, lattice

reduction is significantly slower for larger matrices. To mitigate this, for n = 512 , we use 448 LWE samples (instead of 512 ) when generating A i for lattice reduction, therefore reducing the matrix size from 1024 × 1024 to 960 × 960 . Experimentally, we observe that using slightly fewer samples did not negatively impact our reduction factor or attack performance.

5 Small Modulus

To define real-world parameters for lattice-based cryptography, standardization committees and communities (e.g. [4, 17]) select a small enough modulus q (for fixed dimension n ), so that all known attacks are (heuristically) predicted to run in time at least 2 128 , therefore attaining the U.S. government minimum 128 -bit security level. For classical lattice reduction attacks, the smaller the modulus, the more difficult the attack. This is because lattice reduction algorithms such as LLL and BKZ attempt to compute short vectors in Euclidean space, but cryptosystems operate modulo q . Smaller moduli result in smaller lattice volumes, meaning shorter target vectors are required to break the system. In our ML approach, we also observe that VERDE is less likely to succeed when q is smaller (see Table 6). Nevertheless, VERDE outperforms the uSVP attack (§A.7).

PICANTE vs. VERDE's performance on small q . PICANTE attacks larger moduli: it can recover binary secrets with h = 31 for log 2 q = 23 and n = 256 , and h = 60 for log 2 q = 32 and n = 350 . Table 6 presents VERDE's highest recovered h (in 10 random attempts) for dimensions 256 and 350 and different q for binary, ternary, and narrow Gaussian secrets. First, note that VERDE recovers binary secrets with h = 33 for n = 256 and log 2 q = 20 , but also, VERDE succeeds for much smaller q , as small as log 2 q = 12 , a near-real-world parameter setting, demonstrating that VERDE significantly outperforms PICANTE. However, for smaller q , VERDE recovers only secrets with smaller h . As with classical attacks, the likely culprit is lattice reduction: the reduction factor after preprocessing is 0 . 71 for log 2 q = 12 versus 0 . 43 for log 2 q = 20 , and h for recovered binary secrets drops from 33 to 6 . Section 6 provides a theoretical explanation of this phenomenon.

Figure 3 visualizes VERDE's success rates for n = 256 with binary secrets. For every value of q and h , we run VERDE on 10 binary secrets, using the same preprocessed data. VERDE's success rate decreases as h increases. Attempting 10 random binary secrets for n = 256 , log 2 q = 12 , VERDE recovers secrets for up to h = 6 but not h = 7 , 8 (Table 6). However, with more attempts, VERDE recovers 1 / 100 binary secrets for h = 8 . Experiments with different random seeds (see §A.2) suggest that model initialization alone is not responsible for how success rate trends with h .

Explaining success for smaller q via NoMod. As Table 6 indicates, for given n and h , secrets are harder to recover for smaller q . This suggests that the modular operations in the computation of b

Proportion of NoMod training data

from a might account for the difficulty. To investigate this, we evaluate, for a given known binary secret s , the percentage of samples where computing b did not require the modular operation, for the 4 million samples in our training set. More precisely, we represent the mod q coordinates of a and b in the interval ( -q/ 2 , q/ 2) , and compute x = a · s -b without modular operations. If b was computed without modular operations, then x is equal to the error for that sample, which is small. Otherwise x is equal to the error plus a multiple of q . For each ( a , b ) , if | x | < q/ 2 , then no modular operation was performed. We define NoMod to be the percentage of such x in the training set.

Figure 4 shows the distribution of secret recoveries, for varying NoMod , for 210 experiments with dimension n = 256 and log 2 q = 20 . Clearly, recovery occurs when NoMod exceeds a threshold value, empirically observed to be 67% . These results confirm our hypothesis that modular arithmetic is the major cause of failure to recover secrets, and help explain the observation ([42, §6.4] and §A.2) that some secrets are never recovered, no matter how many model initializations are tried. For a given secret, NoMod is a property of the training data, not of model initialization, and multiple initializations only seem to help when NoMod is close to the recovery threshold.

A trick for improving attack success. The NoMod percentage can only be calculated if the secret is known, so it cannot aid real-world attack settings. However, our NoMod observations suggest that, if recovery fails for a given secret s , the failure may be due to a low NoMod factor in the preprocessed training set. This reveals a strategy for potentially recovering such secrets. If an initial run of VERDE fails for a secret s , start over with the (un-preprocessed) matrices A i , sampled from the original LWE samples. For each of these, apply a random permutation Π to the columns and preprocess the permuted matrices. This creates a new dataset of A ′ with corresponding b ′ , associated to a permuted counterpart s ′ of the original secret s . If the NoMod of s ′ , b ′ and A ′ is higher that that of s , b and A (though this cannot be measured), s ′ can be recovered. If the attack succeeds, s can be restored by applying the inverse of permutation Π . Table 7 presents the impact of permutations on NoMod for 10 secrets and h = 6 , 7 , 8 for n = 256 and log 2 q = 14 . Some secrets become recoverable after using the permutation trick.

6 A Theoretical Scaling Law for VERDE

Intuition. The NoMod experiments provide a key insight about the hardness of secret recovery in SALSA-based attacks on LWE. They suggest that a secret s can be recovered from a training set if over 67% of the { x = a · s -b } are concentrated in the interval of length q . If the random variable x is Gaussian (a reasonable assumption for h ≫ 1 , since the entries of a are random and bounded), 68% of its values will be within one standard deviation of its mean, i.e. spread over two standard deviations. Therefore, for the secret to be recoverable, the standard deviation of x should satisfy σ x ≤ q/ 2 . If s is a binary secret with Hamming weight h , and the entries of a have standard deviation σ a , we have x ≈ a · s -e and σ x ≈ √ hσ a + σ e ≈ √ hσ a . Therefore, s is recoverable if √ hσ a ≤ q/ 2 , or σ a ≤ q 2 √ h .

Scaling Laws. We now apply this insight to the experimental results of ML-based attacks on LWE. Consider the original SALSA attack, which does not utilize data preprocessing. Since the entries of a are uniformly distributed over [0 , q ) , σ a = q √ 12 . Replacing in σ a ≤ q 2 √ h yields h ≤ 3 , the main experimental result of SALSA. If we constrain the entries of a to be in [0 , αq ) (Table 4 in [58]), we have σ a = αq √ 12 , and h ≤ 3 α 2 . Applying this formula for α ∈ 0 . 6 , 0 . 55 , 0 . 5 , 0 . 45 , we obtain maximal recoverable Hamming weights of 8, 10, 12 and 15, which closely match SALSA experimental results.

These results shed light on the role of preprocessing in PICANTE and VERDE. When the standard deviation of a is reduced by a factor α , maximal recoverable h increases by a factor 1 α 2 . However, the formula h ≤ 3 α 2 underestimates actually recovered h by a factor of 2 . For instance, from the reduction factors from Table 5, we should expect recovered h to range from 11 to 29 as preprocessing time increases from 7 to 35 days, but actual recovered h ranges from 20 to 63 . As seen in §5, the preprocessing step makes some secrets easier to recover for the same h , so VERDE performs better than predicted by theory for some secrets (at the expense of other secrets). Finally, note that the formula for the standard deviation of x is the same for ternary and binary secrets. This accounts for the observation in §3 that ternary secrets are of similar difficulty for VERDE as binary secrets.

7 Model architecture

VERDE's baseline model uses a seq2seq architecture as in SALSA and PICANTE. Here, we compare it to the new encoder-only model discussed in §2. Specifically, this new model is based on the DeBERTa [34] model but replaces its 'relative positional embeddings' with rotary word embeddings, in the spirit of rotary positional embeddings (RoPE) [55] but applied to the integer words. It has 4 layers, 4 heads and 512 dimensions. On top of the cross-entropy loss, we add an auxiliary, squared earth mover's distance (EMD) loss to compare model's softmax distribution with the target b . This encourages the model to make predictions that are at least close to the targets, if not exact matches. Trained with the auxiliary EMD loss, the model also replaces the beam search used in the distinguisher with a novel EMD-based distinguisher that compares the difference between the distributions produced by the model on a test and a test + K e i .

Overall, we find that the performance of the two models are comparable (see Table 8). The encoderonly model requires more training epochs before recovery for n = 256 , log 2 q = 12 , but requires fewer epochs for n = 512 , and may scale well to larger n . Furthermore, we observe that the EMD distinguisher still enables full recovery of ternary secrets with high h .

8 Related Work

ML for cryptanalysis. Numerous proposals leverage ML for cryptanalysis, either indirectly or directly. We call approaches which use ML as part of (but not the main element of) the cryptanalysis process indirect approaches. Indirect approaches typically use ML models to strengthen existing cryptanalysis approaches, such as side channel or differential analysis [18]. Most relevant to this work is a recent paper showing the successful use of ML algorithms in side-channel analysis to attack Kyber, one of the NIST standardized PQC proposals [28]. Direct ML-based cryptanalysis schemes train models to directly recover cryptographic secrets from plaintext/ciphertext pairs or similar information. Such approaches have been studied against a variety of cryptosystems, including block ciphers [29, 9, 18, 3, 53, 38, 8], hash functions [30], and substitution ciphers [1, 54, 7, 31]. The two ML-based LWE attacks described in §1, SALSA [58] and PICANTE [42], fall under this heading.

Use of transformers for mathematics. In recent years, language models have been used to solve math problems beyond the cryptanalysis applications explored in this work. Much prior work has considered how well language models can solve written math problems [35, 48]. More recently, [32] showed large transformers could achieve high accuracy on elementary/high school problems, and [59] explored the accuracy of GPT-3 [11] on math word problems. Language models have also been applied to formalized symbolic math problems. After [40] demonstrated that transformers can solve such problems with high accuracy, follow-up work has explored transformers' use in theorem proving [43], dynamical systems [13], SAT solving [51], transport graphs [14], and symbolic regression [10, 23]. Finally, some have proposed customizing model architectures to enable specific arithmetic operations [36, 56, 44].

9 Discussion

We present VERDE, a ML-based attack on LWE with sparse small secrets. VERDE improves data preprocessing and secret recovery, enabling significant performance gains over prior work, SALSA [58] and PICANTE [42]. In particular, VERDE can recover secrets with more general distributions (ternary, small Gaussian), larger dimensions n , smaller moduli q , and higher h . In our implementation, VERDE outperforms the uSVP attack, requiring less time but more compute resources (details in Appendix A.7). Most importantly, this work provides key theoretical insights into observed attack performance, paving the way for targeted future work. Note that even if we recover secrets with seemingly low probability, such as one seed out of ten succeeds for that secret ( 1 / 10 ), or if we do not recover all secrets successfully, such as we recover one out of ten secrets with our attack, this is still enough to make these cryptosystems unsafe to use with low weight secrets (unless there is a way to check for vulnerability to our attack without running the attack).

Limitations and broader impact. Despite significantly advancing the state-of-the-art in ML-based LWE attacks, VERDE cannot yet break standardized LWE-based PQC schemes, limiting its real-world impact. Because of this, our paper raises no immediate security concerns. Nevertheless, we have shared a copy of our paper with the NIST PQC group to make them aware of this attack.

Future work. Scaling VERDE to attack real-world systems requires work in several directions: increasing dimension n , reducing modulus q , and increasing h , the number of nonzero entries in recoverable secrets. Continued innovations in model architecture (a la §7) may allow attacks in higher dimension n , while the theoretical scaling law of §6 provides helpful guidance for improving q and h . Given our new insight and analysis of the importance of the NoMod percentage, we conclude that the reason that small q is hard for the transformers with our current approach is that they are not good at modular arithmetic (not yet, anyway-this is an area for future work and improvement). In addition, our preprocessing is not well-suited to what is precisely needed and relies on existing lattice reduction algorithms which scale poorly with n and q .

This suggests two avenues for improvement: first, to develop model architectures that perform modular arithmetic better. Limited existing work has studied the application of ML to modular arithmetic more broadly [44, 33], Second, alternative preprocessing techniques should be developed to directly concentrate the distribution of random vectors, without relying on lattice reduction methods. With the goal of reducing the standard deviation of the training data, around any center, techniques from the broader math community may prove helpful.

Acknowledgements. We thank Jana Sotáková for her contributions to developing the attack on ternary secrets, Hamming reduction techniques, and Section A.3. We also thank Mark Tygert for his helpful input.

References

Ezat Ahmadzadeh, Hyunil Kim, Ongee Jeong, and Inkyu Moon. A Novel Dynamic Attack on Classical Ciphers Using an Attention-Based LSTM Encoder-Decoder Model. IEEE Access , 2021.

Gorjan Alagic, Jacob Alperin-Sheriff, Daniel Apon, et al. Status report on the second round of the nist post-quantum cryptography standardization process. US Department of Commerce, NIST , 2020. https://www.nist.gov/publications/ status-report-second-round-nist-post-quantum-cryptography-standardizationprocess .

Mohammed M Alani. Neuro-cryptanalysis of DES and triple-DES. In Proc. of NeurIPS , 2012.

Martin Albrecht, Melissa Chase, Hao Chen, et al. Homomorphic encryption standard. In Protecting Privacy through Homomorphic Encryption , pages 31-62. Springer, 2021. https: //eprint.iacr.org/2019/939 .

Martin R. Albrecht. On Dual Lattice Attacks Against Small-Secret LWE and Parameter Choices in HElib and SEAL. In Jean-Sébastien Coron and Jesper Buus Nielsen, editors, Advances in Cryptology - EUROCRYPT 2017 , pages 103-129, Cham, 2017. Springer International Publishing. https://eprint.iacr.org/2017/047 .

Martin R. Albrecht, Rachel Player, and Sam Scott. On the concrete hardness of learning with errors. Journal of Mathematical Cryptology , 9(3):169-203, 2015. https://eprint.iacr. org/2015/046.

Nada Aldarrab and Jonathan May. Can sequence-to-sequence models crack substitution ciphers? 2020. https://arxiv.org/abs/2012.15229 .

Seunggeun Baek and Kwangjo Kim. Recent advances of neural attacks against block ciphers. In Proc. of SCIS , 2020.

Adrien Benamira, David Gerault, Thomas Peyrin, and Quan Quan Tan. A deeper look at machine learning-based cryptanalysis. In Proc. of Annual International Conference on the Theory and Applications of Cryptographic Techniques , 2021.

Luca Biggio, Tommaso Bendinelli, Alexander Neitz, Aurelien Lucchi, and Giambattista Parascandolo. Neural symbolic regression that scales. 2021. https://arxiv.org/abs/2106. 06427 .

Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, et al. Language models are few-shot learners. In Proc. of NeurIPS , 2020.

François Charton. Linear algebra with transformers, 2021. https://arxiv.org/abs/2112. 01898 .

François Charton, Amaury Hayat, and Guillaume Lample. Learning advanced mathematical computations from examples. 2020. https://arxiv.org/abs/2006.06462 .

François Charton, Amaury Hayat, Sean T. McQuade, Nathaniel J. Merrill, and Benedetto Piccoli. A deep language model to predict metabolic network equilibria. 2021. https: //arxiv.org/abs/2112.03588 .

François Charton, Kristin Lauter, Cathy Li, and Mark Tygert. An efficient algorithm for integer lattice reduction, 2023. https://arxiv.org/abs/2303.02226 .

Hao Chen, Lynn Chua, Kristin Lauter, and Yongsoo Song. On the Concrete Security of LWE with Small Secret. Cryptology ePrint Archive, Paper 2020/539, 2020. https://eprint.iacr. org/2020/539 .

Lily Chen, Dustin Moody, Yi-Kai Liu, et al. PQC Standardization Process: Announcing Four Candidates to be Standardized, Plus Fourth Round Candidates. US Department of Commerce, NIST , 2022. https://csrc.nist.gov/News/2022/ pqc-candidates-to-be-standardized-and-round-4 .

Yi Chen and Hongbo Yu. Bridging Machine Learning and Cryptanalysis via EDLCT. Cryptology ePrint Archive , 2021. https://eprint.iacr.org/2021/705 .

Yuanmi Chen and Phong Q. Nguyen. BKZ 2.0: Better Lattice Security Estimates. In Proc. of ASIACRYPT 2011 , 2011.

Jung Hee Cheon, Minki Hhan, Seungwan Hong, and Yongha Son. A Hybrid of Dual and Meet-in-the-Middle Attack on Sparse and Ternary Secret LWE. IEEE Access , 2019.

Jung Hee Cheon, Duhyeong Kim, Joohee Lee, and Yongsoo Song. Lizard: Cut Off the Tail! A Practical Post-quantum Public-Key Encryption from LWE and LWR. In Dario Catalano and Roberto De Prisco, editors, Security and Cryptography for Networks , pages 160-177, Cham, 2018. Springer International Publishing. https://eprint.iacr.org/2016/1126.pdf .

Róbert Csordás, Kazuki Irie, and Jürgen Schmidhuber. The Neural Data Router: Adaptive Control Flow in Transformers Improves Systematic Generalization. In Proc. of ICML , 2022.

Stéphane d'Ascoli, Pierre-Alexandre Kamienny, Guillaume Lample, and François Charton. Deep symbolic regression for recurrent sequences. 2022. https://arxiv.org/abs/2201. 04600 .

Alex Davies, Petar Veliˇ ckovi´ c, Lars Buesing, Sam Blackwell, et al. Advancing mathematics by guiding human intuition with AI. Nature , (7887), 2021.

Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. Universal transformers. In Proc. of ICLR , 2019.

Aurélien Dersy, Matthew D. Schwartz, and Xiaoyuan Zhang. Simplifying polylogarithms with machine learning, 2022. https://arxiv.org/abs/2206.04115 .

The FPLLL development team. fplll, a lattice reduction library, Version: 5.4.4. Available at https://github.com/fplll/fplll , 2023.

Elena Dubrova, Kalle Ngo, and Joel Gärtner. Breaking a fifth-order masked implementation of crystals-kyber by copy-paste. Cryptology ePrint Archive , 2022. https://eprint.iacr. org/2022/1713 .

Aron Gohr. Improving attacks on round-reduced speck32/64 using deep learning. In Proc. of Annual International Cryptology Conference , 2019.

Sergij V Goncharov. Using fuzzy bits and neural networks to partially invert few rounds of some cryptographic hash functions. 2019. https://arxiv.org/abs/1901.02438 .

Sam Greydanus. Learning the enigma with recurrent neural networks. 2017. https://arxiv. org/abs/1708.07576 .

Kaden Griffith and Jugal Kalita. Solving Arithmetic Word Problems with Transformers and Preprocessing of Problem Text. 2021. https://arxiv.org/abs/2106.00893 .

Andrey Gromov. Grokking modular arithmetic, 2023. https://arxiv.org/pdf/2301. 02679.pdf .

Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced BERT with disentangled attention. In Proc. of ICLR , 2021.

Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Computation , 1997.

Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. 2015. https://arxiv. org/abs/1511.08228 .

Ravi Kannan. Minkowski's Convex Body Theorem and Integer Programming. Mathematics of Operations Research , 12:415-440, 1987.

Hayato Kimura, Keita Emura, Takanori Isobe, Ryoma Ito, Kazuto Ogawa, and Toshihiro Ohigashi. Output prediction attacks on block ciphers using deep learning. In Proc. of Applied Cryptography and Network Security Workshops , 2022.

Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Proc. of ICLR , 2015.

Guillaume Lample and François Charton. Deep learning for symbolic mathematics. In Proc. of ICLR , 2020.

H.W. jr. Lenstra, A.K. Lenstra, and L. Lovász. Factoring polynomials with rational coefficients. Mathematische Annalen , 261:515-534, 1982.

Cathy Li, Jana Sotáková, Emily Wenger, Mohamed Malhou, Evrard Garcelon, Francois Charton, and Kristin Lauter. SALSA PICANTE: a machine learning attack on LWE with binary secrets, 2023. https://arxiv.org/abs/2303.04178 .

Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving, 2020. https://arxiv.org/abs/2009.03393 .

Alethea Power, Yuri Burda, Harri Edwards, Igor Babuschkin, and Vedant Misra. Grokking: Generalization beyond overfitting on small algorithmic datasets, 2022. https://arxiv.org/ abs/2201.02177 .

Oded Regev. On Lattices, Learning with Errors, Random Linear Codes, and Cryptography. In Proc. of the Thirty-Seventh Annual ACM Symposium on Theory of Computing , 2005. https: //dblp.org/rec/journals/corr/cs-DS-0304005.bib .

Alexander Rives, Joshua Meier, Tom Sercu, Siddharth Goyal, Zeming Lin, Jason Liu, Demi Guo, Myle Ott, C. Lawrence Zitnick, Jerry Ma, and Rob Fergus. Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences. Proceedings of the National Academy of Sciences , 2021.

Ronald L Rivest, Adi Shamir, and Leonard Adleman. A method for obtaining digital signatures and public-key cryptosystems. Communications of the ACM , 1978.

David Saxton, Edward Grefenstette, Felix Hill, and Pushmeet Kohli. Analysing Mathematical Reasoning Abilities of Neural Models. 2019. https://arxiv.org/abs/1904.01557 .

C.P. Schnorr. A hierarchy of polynomial time lattice basis reduction algorithms. Theoretical Computer Science , 53(2):201-224, 1987.

Philippe Schwaller, Teodoro Laino, Théophile Gaudin, Peter Bolgar, Christopher A. Hunter, Costas Bekas, and Alpha A. Lee. Molecular transformer: A model for uncertainty-calibrated chemical reaction prediction. ACS Central Science , 5(9):1572-1583, 2019.

Feng Shi, Chonghan Lee, Mohammad Khairul Bashar, Nikhil Shukla, Song-Chun Zhu, and Vijaykrishnan Narayanan. Transformer-based Machine Learning for Fast SAT Solvers and Logic Synthesis. 2021. https://arxiv.org/abs/2107.07116 .

Peter W Shor. Algorithms for quantum computation: discrete logarithms and factoring. In Proceedings 35th Annual Symposium on Foundations of Computer Science , 1994.

Jaewoo So. Deep learning-based cryptanalysis of lightweight block ciphers. Security and Communication Networks , 2020.

Shivin Srivastava and Ashutosh Bhatia. On the Learning Capabilities of Recurrent Neural Networks: A Cryptographic Perspective. In Proc. of ICBK , 2018.

Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding, 2021. https://arxiv.org/abs/2104.09864 .

Andrew Trask, Felix Hill, Scott Reed, Jack Rae, Chris Dyer, and Phil Blunsom. Neural arithmetic logic units. 2018. https://arxiv.org/abs/1808.00508 .

Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Proc. of NeurIPS , 2017.

Emily Wenger, Mingjie Chen, François Charton, and Kristin E Lauter. Salsa: Attacking lattice cryptography with transformers. Proc. of NeurIPS , 2022.

Mingyu Zong and Bhaskar Krishnamachari. Solving math word problems concerning systems of equations with GPT-3. In Proc. of AAAI , 2022.

A Appendix

A.1 Parameters

VERDE runs data preprocessing with the parameters shown in Table 9 in parallel using multiple CPUs. We fully parallelize when the time to process one matrix is greater than 24 hours-e.g., for n = 350 , log 2 q = 27 , we used 5000 CPUs. Otherwise, we parallelize on fewer CPUs depending on the attack time allowed-e.g., preprocessing is completed on 270 CPUs in less than 4 days for n = 256 , log 2 q = 14 , and on 990 CPUs in less than 3 days for n = 256 , log 2 q = 18 .

In VERDE, the tokenization used by the transformer mirrors the strategy in §4 of [42], but uses smaller bases B and larger bucket sizes r for better performance (Table 9, 10 of [42]). Decreasing B is further supported by Table 10, evaluated on a low modulus data using VERDE's preprocessing ( n = 256 , log 2 q = 16 ). Full ternary secret recovery and partial Gaussian secret recovery both improve with smaller B = 5363 .

A.2 More seeds for initialization

The ML attacks benefit from running multiple times with different seeds, or initializations , as was demonstrated in PICANTE [42, Section 6.4]. More seeds improve both the success probability and the number of epochs required. Table 11 shows how binary secret recovery improves with more seeds, for different Hamming weights h when n = 256 and log 2 q = 12 .

Table 12 shows the results for ternary secrets on n = 512 , log 2 q = 41 , where we run 5 initializations for each secret. While most initializations partially recovered the secret, only a few got full recovery within 20 epochs. Full recovery benefits from more initializations, especially for high h .

A.3 Comparison with PICANTE

To demonstrate the power of the new preprocessing in SALSA VERDE, we run a set of experiments on n = 256 , log 2 q = 23 , where PICANTE also showed success. Using blocksize β = 40 , each matrix is processed by VERDE in about 1 . 5 days; PICANTE took 2 . 2 days/matrix. VERDE achieves a reduction factor of 0 . 25 , compared to 0 . 33 in PICANTE. As shown in Table 1, the difference in the preprocessing step is even more striking for lower q .

The highest h recovered by PICANTE was h = 31 in 4 out of 20 experiments; VERDE recovered h = 43 . In Table 13, we see that for h = 26 -31 , VERDE significantly outperforms PICANTE in both the success rate and the number of epochs required. In other words, better preprocessing results in lower training time and better secret recovery.

A.4 Distinguisher tested on reduced data outperforms random data

We compare the performance of running the distinguisher on the preprocessed data that were held out from the training set (DistBKZ) with running on random vectors (Distrand). We run both set of experiments with the same model initialization seeds, and record a success for the method(s) that recovers the secret at the earliest epoch. Table 14 indicates that DistBKZ performs better.

A.5 Dimension reduction techniques

Most of the entries in a sparse secret are zero, so prior work [5] has suggested the idea of randomly assuming a subset of the entries to be zero and removing them to reduce the dimension of the lattice problem. The assumption will be correct with some probability depending on the secret's sparsity. Here we explore an improvement on this strategy: we use the partially trained model to glean signal on which entries should be kicked out. We can either try to kick out zeros, which we call dimension reduction , or in the binary case, kick out 1 s, which we call Hamming reduction , or combined.

This technique will be better than random when the model has begun to learn information about the bits, reflected in their relative rankings. Specifically, the ranking strategies described in [42, Section 4.3] are used to compute scores which estimate the likelihood of secret bits being 1 . Once the model has started to learn, we can assume that the highest ranked bits will correspond to secret bits which are equal to 1 , and the lowest ranked bits will correspond to zeros. So we use this information to reduce the dimension of the problem by kicking out low-ranked bits which we guess to be zero or high-ranked bits which we guess to be 1 . Then, we retrain a model on the smaller dimensional samples and hope to recover the secret. If the original kicked out bits were correct and the model recovers the secret of the smaller dimensional problem, then we find the original secret.

Dimension reduction. Since there are many more 0 s than 1 s in sparse secrets, we can potentially reduce the dimension significantly. Once we remove the bits with low scores, we can simply re-run

training on the dataset with ( a ′ , b ) where a ′ are the samples with the corresponding bits removed. If the indices have been identified incorrectly, then the reduction will fail. For n = 256 , log 2 q = 14 , VERDE attempted 10 binary secrets with h = 10 and did not recover the secret. Then we tried dimension reduction on these experiments and recovered one secret.

Hamming reduction. Kicking out 1 s from the secret is particularly valuable, given the theoretical analysis of the VERDE in Section 6. If nonzero bits are indeed ranked at the top by the model, a straightforward approach of kicking out the top-ranked bits and retraining on the smaller dimension and Hamming weight will likely yield improved secret recovery.

But in case some of the top-ranked bits are not equal to 1 , we propose the following strategy. Suppose S is a small set of indices for bits with the highest scores. We construct the following problem: let s ′ be s with bits in S flipped, and a ′ be a with a i negated for i ∈ S . Equivalently, for i ∈ S , a ′ i = -a i and s ′ i = 1 -s i . Then, the corresponding

If more than half of the indices in S are 1 , then s ′ has a smaller Hamming weight, hence the instance ( a ′ , b ′ = b -∑ i ∈ S a i ) is likely easier. If exactly half of the indices in S are 1 , then s ′ has the same h as s , but the new instance ( a ′ , b ′ ) will have a different NoMod and may be recoverable.

A.6 Attacking sparse secrets in larger dimensions

For sparse secrets on even larger dimensions, we can apply our attack after using combinatorial techniques to exploit the sparsity of the secret. The approach would be to combine VERDE with the techniques from [5, 20] as follows: Randomly kick out k entries of the secret, assuming they are zero, which will be true with some probability. This reduces the LWE problem to a smaller dimension where VERDE can recover the secret. The expected cost of the attack would be VERDE's cost multiplied by 1 /p , where p = ( n -h n ) k is the probability that the assumption that the k entries are 0 is correct.

A.7 Comparison with lattice reduction/uSVP attacks

In this section we compare VERDE with classical lattice reduction attacks in two ways. The LWE Estimator [6] gives heuristic predicted running times for the best-known lattice reduction attacks. But even the authors of the LWE Estimator claim that the estimates are often wrong and unreliable. So we compare VERDE to the Estimator results but we also compare to concrete running times in the case n = 256 , achieved by implementing the uSVP lattice attacks ourselves, on the same machines where we run our ML-based attacks. Unfortunately, many attacks listed by the LWE Estimator lack practical/accessible implementations, and we lacked the time and resources to implement all of these and run comparisons. Thus, we focus our concrete comparisons on the uSVP attack, which the Estimator predicts to be the best method for larger n such as n = 512 . We leave comparison of VERDE against other lattice reduction attacks as important future work for the broader lattice community, as practical attack run-times are poorly understood, especially for small sparse secrets.

Table 15 presents our concrete comparison between VERDE and the uSVP attack on binary secrets for n = 256 . To summarize the comparison, VERDE outperforms the uSVP attack in two senses: 1) VERDE fully recovers sparse binary and ternary secrets for n and q in some cases where the uSVP attack does not succeed in several weeks or months using fplll BKZ 2.0 [19] with the required block size; and 2) in cases where we improve the uSVP implementation enough (see below) to run with the required large block size, we find that in all cases, VERDE recovers the secrets much faster.

Summarizing classical lattice reduction attacks. Table 16 gives the estimated heuristic cost and specifies the block size for attacking sparse binary and ternary secrets for n = 256 , 350 , 512 and various q with the best known classical lattice reduction attack.

Table 17 gives the same information for the uSVP classical lattice reduction attack, focusing on n = 256 for some of the larger q and h where VERDE succeeds.

uSVP attack performance, binary secrets. For n = 256 and log 2 q = 20 , we run the concrete uSVP attack using fplll BKZ 2.0 with Kannan's embedding and parameters ([37], [16]). With block size 50 and 55 , secrets are not recovered in 25 days, and block size 60 or larger cannot finish the first BKZ loop in 3 days. We propose two improvements to get these attacks to run faster and better: 1) we rearrange the rows of the uSVP matrix as in VERDE; 2) we use the adaptive float type upgrade as in VERDE. In addition, after each BKZ loop, we also run the secret validation obtained from the shortest vector found so far, and terminate if we get a secret match.

With rearranging the rows but without the adaptive float type upgrade, we have to use higher precision because otherwise the attack fails due to low precision after running for 23 hours. The attacks run quite slowly with high precision and did not recover secrets after 25 days, except in one case where a binary secret with h = 22 was recovered with block size 55 in 414 hours, roughly 17 days.

With rearranging the rows and the adaptive float type upgrade, we ran n = 256 and log 2 q = 20 with block size 50 -55 for binary/ternary secrets, and n = 256 and log 2 q = 18 with block size 65 for binary/ternary secrets. See Table 18 for running times and h . For example, for log 2 q = 20 , a ternary secret with h = 25 was recovered in 280 hours, roughly 12 days, and for log 2 q = 18 , a binary secret with h = 20 was found in ≈ 11 days. When the block size used is lower than predicted by the estimator (50 instead of 52 for log 2 q = 20 and 65 instead of 67 for log 2 q = 18 , see Table 17, 18), the uSVP attack succeeds in recovering only a few secrets out of many which were tried.

The concrete experiments allow us to validate to some extent the predictions of the Estimator in many cases, giving confidence in the comparison with VERDE. Running the uSVP attack with block size 70 or larger didn't finish the first BKZ loop in 3 days, so we expect longer attack time for Gaussian secrets and for binary and ternary secrets with lower q .

Gaussian secrets. VERDE achieves partial Gaussian secret recovery for small h , reducing the secret recovery to a lattice problem in tiny dimension ( h ). Because the preprocessing time and per epoch time does not vary with secret distribution, VERDE's attack time on Gaussian secrets is comparable to on binary secrets (see Table 15, 19). We note that preprocessing takes longer for n = 350 and log 2 q = 27 due to precision issues. This is an important observation because lattice problems are supposed to be harder for smaller q . In contrast, with classical attacks, the Estimator predicts significantly larger block sizes required, and longer running times (Table 20), than for binary secrets. VERDE compares favorably to classical attacks on Gaussian secrets, especially on small q (where the problem is harder), e.g., VERDE recovers Gaussian secrets with h = 5 -6 in 4 . 5 -15 hours for n = 256 , log 2 q = 12 , where the cost of best classical attacks is predicted to be 2 91 rop.

Peer reviews:
comments: SUMMARY:
This paper introduces a novel ML attack that has the capability to recover sparse binary, ternary, and small Gaussian secrets. The proposed approach exhibits effectiveness in attacking LWE systems with larger dimensions and smaller moduli, while requiring less preprocessing time.

STRENGTHS:
1. The paper is well-written.
2. The SALSA VERDE achieves a harder attack with larger dimensions and smaller moduli, which makes the attack more practical on LWE-based systems.
4. The improved preprocessing method significantly speeds up the attack process, improving its efficiency.
5. The authors provide a theoretical explanation for the performance of the attack, adding to its overall understanding.

WEAKNESSES:
1. It would be beneficial to include an explanation or insights regarding the reasons why full recovery of Gaussian secrets is infeasible.

2. More ablation experiments and comparisons should be conducted to showcase the individual contributions and benefits of each proposed enhancement.

3. Regarding the model architecture, additional results or explanations are necessary to justify the replacement of the positional embedding method and beam search, especially when the performances are similar.

QUESTIONS:
Please refer to the weaknesses section.

LIMITATIONS:
Please refer to the weaknesses section.
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2023-06-10

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper considers the problem of adapting machine learning for the cryptanalysis of LWE --- an important cryptographically hard problem that forms the basis of several modern post-quantum cryptosystems. The LWE problem requires recovery of a secret \\bf{s} given many noisy inner products b = \\bf{a} \\cdot \\bf{s} + e mod q.  LWE is also an ideal candidate problem for cryptanalysis using ML techniques because of the linear structure in the computation. \n\nThe high-level approach is to train an ML model using samples {(\\bf{a}, b)}. Next, this trained model can predict a value close to \\bf{a} \\cdot \\bf{s}  mod q for new values of \\bf{a}.  Finally, this prediction can recover \\bf{s}. This approach was first considered in prior work Salsa/Picante. Salsa could only work for binary secrets with 3/4 non-zero entries. In contrast, Picante supplemented the above approach with some insights from lattice algorithms. Specifically, Picante showed that by appropriately using BKZ lattice reduction algorithm in preprocessing, they could attack binary secrets but with larger non-zero entries. \n\nHowever, a significant gap remains between the parameter choices these attacks can handle and those used in LWE-based cryptosystems. This paper makes progress in reducing this gap.\n\nSTRENGTHS:\n+ The paper makes progress on various strengths. \n+ The paper can beat state-of-the-art lattice attacks not using ML. This demonstrated that ML could play a crucial role in the pipeline for improvement on lattice attacks. \n+ I like the effort in trying to give a theoretical explanation of why the attacks only seem to work for working\n\nWEAKNESSES:\n- The paper is a bit dense and talks about various parameters. Having some text that helps provide a unifying framework from the various parameter choices the authors try to use will be helpful.\n\nQUESTIONS:\n- How do you quantify that your attacks are better than classical lattice reduction attacks? I missed the concrete performance comparison on the same. Could the performance boost be attributable to more optimizations/use of hardware specialized for ML tasks? \n- Several choices in the paper seem unexplained. For example, the authors on page 5 say that they use \\sigma = 3 and that FHE standards suggest \\sigma = 3.2. I understand the authors are using a \\sigma close to what is suggested, but why not use 3.2?\n\nLIMITATIONS:\n- The improvements in the paper are still not significant enough to show that ML/transformers can help significantly improve the attacks against LWE.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-03"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe authors propose an ML based attack scheme for the learning with errors post quantum cryptography scheme. Their proposed attack is able to recover sparse, binary, and ternary Gaussian secrets in a more efficient fashion than the Salsa and Picante schemes in prior work.\n\nSTRENGTHS:\nI have to admit that I am not an expert in post quantum cryptography, nor I am familiar with previous literature. Therefore, I am not able to confidently appreciate the strengths of the paper with respect to prior work. I like the clarity of the presentation in most parts; the paper is written well and provides a decent introduction to the problem of learning with errors.\n\nWEAKNESSES:\n1. To me the purpose of the paper is not clear. The authors claim that they improve on previous schemes. But these schemes have already demonstrated that LWE is breakable and won't be used in practice anyway, so what is the novelty of the paper? This should be made clear in a better way.\n\n2. It seems that the difference to previous schemes is just a different matrix factorization in combination with techniques from [14] and [17], as explained in Section 2. I don't think that this contribution alone is sufficient for acceptance to NeuRIPS.\n\n3. The part of the paper related to learning is not well developed and presented as an afterthought, despite the choice of the architecture may significantly affect the performance. The proposed scheme leverages the same architecture as in previous works without giving any rationale why a transformer architecture is the best choice and why attention is necessarily required. It seems that in the LWE encoding the noise sequence is drawn iid from a Gaussian distribution, so I don't understand why the learning architecture needs to impose a Markovian structure.\n\nQUESTIONS:\nPlease see my questions under Weaknesses.\n\nLIMITATIONS:\nThe authors have stated the need for post quantum cryptography, and thus, the societal impact of breaking classical cryptography via Shor's algorithm. Their work contributes to the task of finding the best post quantum crypto scheme which does not depend on factoring large numbers into products of primes.", "TITLE": "Official Review", "RECOMMENDATION": 5, "REVIEWER_CONFIDENCE": 2, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-15"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe authors present VERDE, an improved ML based attack on the LWE problem, a source of mathematical hardness underpinning post-quantum cryptography schemes such as Homomorphic Encryption. Their method improves upon prior versions of this form of attack, SALSA and PICANTE, by improving the runtime characteristics of the preprocessing and the performance and generality of the secret recovery step. Additionally, their error analysis yields insights into the hardness of SALSA-style attacks on the LWE problem, revealing an avenue for potential improvement based on improving the distribution of the training data to increase the chance of success for such attacks.\n\nSTRENGTHS:\n- Introduces key performance improvements to the existing previous art by subtle but impactful modifications: reducing the complexity of the preprocessing matrix operations, and improving their floating point error tolerance.\n\n- Secret discovery procedure is improved by applying a simple (but not trivial) fact from machine learning - generalization to a shifted distribution is hard. Switching to verification on a held out set of preprocessed vectors. i.e. \"in-distribution\", yields improved performance.\n\n- Secret discovery procedure is extended to ternary secrets by taking a novel two step approach, where step one is similar to the binary secret recovery problem. (novelty is taken for granted, not very familiar with literature)\n\n- (Highlight) Error analysis yields NoMod, which allows them to first descriptively develop an explanation for different success rates as a function of modulus, but then further admits a potential improvement via attempting to increase the NoMod factor of a given training set by permutation.\n\nWEAKNESSES:\n- The encoder-only model architecture proposal empiricals are mixed, and theoretical or intuitive justification is missing. Would be useful to include training runtime differences in Table 8 or their own table, my sense is that epochs until success doesn't tell full story since training complexity for the two architectures is likely different. Claim that the encoder only model may generalize to larger n is not sufficiently supported by Table 8, could be omitted, or such discussions moved to future work section as more experimentation is necessary. \n\n- (Minor) Rationale for omission of other secret recovery techniques - direct, cross-attention - is not fully convincing. Latter could be included for the seq2seq architecture as they are proposing the encoder-only variant in this work, rather than adopting it as a baseline.\n\nQUESTIONS:\n- Can slightly more detail be provided about full recovery in the Gaussian case? \"This is feasible via other methods\" leaves reader wondering whether identifying non-zero entities is in fact most of overall lift. A more detailed explanation for how to complete recovery in the gaussian case should be included, else claims that VERDE covers the gaussian case should be qualified elsewhere.\n\n- To strengthen the already decisive insight of the NoMod analysis, can anything be said analytically about the likelihood of a given permutation achieving a high NoMod percentage given the observation of failure on the initial un-permuted version? Working this analysis might reveal an avenue for further tuning of the permutation procedure to increase the success of this trick. Alternately, this could provide an avenue for robustness analysis of this attack under certain assumptions about the distributions of training data.\n\nLIMITATIONS:\n- Key limitation, as the author's state, is gap between the settings they can attack successfully, and the realistic parameter schemes in standardized PQC. However, this is not actually any failure of the authors, and they do in fact achieve results at more realistic settings than prior work.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-23"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper continues a recent line of work on leveraging machine learning (specifically, transformers) for cryptanalysis. The focus is specifically on the learning with errors (LWE) problem. The LWE problem is one of the core problems in lattice-based cryptography, and the basis for many of the recently standardized post-quantum cryptographic systems. The paper targets one particular version of LWE (with *sparse* secret keys).\n\nThe (search) LWE problem is to learn a noisy linear function, where the noise is over a ring: given samples (A, s^T A + e mod q) for a secret vector s, random (wide) matrix A, and small (discrete) Gaussian noise e, recover the secret s. The variant of LWE considered here is where the secret s is sparse. While this is not the standard version of LWE, it is used as an optimization for some fully homomorphic encryption (FHE) schemes.\n\nCompared to previous approaches (Salsa and Picante), this paper describes generalizations to a ternary and (sparse) Gaussian error distributions as well as a better preprocessing step (responsible for generating more examples via the given LWE challenge, which is in turn used to train the transformer). The paper provides some empirical measurements showing that the attack is successful in recovering the secret for some small instances.\n\nSTRENGTHS:\nStudying and understanding the hardness of lattice assumptions is an important problem in cryptography, especially given the current move towards standardizing and implementing post-quantum cryptography. This paper improves upon an ML-based approach for understanding the hardness of certain LWE instances.\n\nWhile previous approaches considered the more restrictive setting of LWE with sparse binary secrets, this paper extends the analysis to support LWE instances with sparse ternary secrets. This is a more useful setting as this is a more common mode used in certain FHE implementations (though far from what I would consider a \"standard\" LWE instance). The idea is to first use the binary distinguisher approach from prior work (which focuses on identifying the zero vs. non-zero indices of the errors) and then applies a post-processing step that identifies whether two non-zero entries in the candidate secret are equal or not (to identify the set of coordinates that are 1 vs. -1).\n\nWEAKNESSES:\nI found the contributions in the paper to be somewhat incremental relative to the previous work. The main improvements seem to be better preprocessing relative to the previous Picante system. While I appreciate that there is a significant speed-up in the new approach for generating LWE samples from a small initial challenge, the core idea is very similar: resample followed by lattice reduction. A more refined application of lattice reduction compared to Picante yields the performance improvement.\n\nThe second feature that distinguishes this work from prior work is the extension to ternary and sparse Gaussian secret key distributions. The extension to ternary builds on the binary distinguisher approach of prior work and essentially add a post-processing distinguisher that decides whether two components are equal/unequal. This technique is very tailored to the ternary case, and it is not clear how general it is or whether this has implications on more standard LWE secret key distributions (e.g., uniformly random or (non-sparse) discrete Gaussian).\n\nFrom a cryptographic perspective, I view LWE with sparse binary/ternary secret keys to be a very risky assumption. The known reductions from LWE to worst-case lattice problems (e.g., gap shortest vector problem) apply only to LWE with uniform secrets (and also LWE with discrete Gaussian secrets). I do not see a solid basis for the hardness of LWE with very sparse binary/ternary secrets, except for the fact that we do not yet know how to break these assumptions. From this perspective, I am not sure if the results in the paper provide insight on the hardness of the standard LWE assumption where we have better evidence for hardness (and which is the basis of schemes in the NIST post-quantum standardization process).\n\nThe paper describes attacks on LWE with sparse Gaussian secrets, but this seems like an unusual choice. Normally, when we consider LWE with Gaussian secrets, there is no sparsity condition. Are there concrete settings where this version of the LWE assumption is used? The attack here seems to rely on identifying the non-zero entries (using the binary distinguisher approach from earlier) and then brute force guessing the values in the non-zero indices. This seems rather inefficient and unlikely to scale to even somewhat-dense solutions. The attacks in the paper only consider a very sparse regime, which again corresponds to a setting where I consider an attack to not be particularly surprising.\n\nFrom the machine learning perspective, I think the paper mostly relies on existing models and architectures as opposed to introducing new architectures tailored for cryptanalyzing LWE. I think this is a fine approach to take, albeit one with less novelty from a machine learning perspective.\n\nQUESTIONS:\nAs mentioned above, using a *sparse* Gaussian secret key distribution seems unusual for LWE? Do you have examples where this is used or preferred over a binary/ternary key distribution (sparse Gaussian secrets are not captured by reductions to worst-case lattice problems, and do not seem to confer better efficiency than just using binary/ternary keys).\n\nWhen you compare the running time of your attack to the estimated security level of the instances you consider, can you also report the running time in terms of the number of bit operations (or CPU cycles) for the attack? From Table 15, it looks like you assume full parallelization, so it is not clear how the running time translates to the actual amount of compute used. Does your algorithm suggest that the security level for small LWE instances (as determined by the LWE estimator) is much lower than currently reported? How big is this gap? I think analyzing this would require computing the actual amount of compute (taking into consideration the parallelism) used in the attack and not just a run time measurement.\n\nWhen you compare the effectiveness of your attack against known classical algorithms, are you comparing against the best state-of-the-art attacks (it seems the lattice estimator suggest different algorithms in Table 16)? Are the algorithms you compare against tuned for standard LWE instances (e.g., with uniform or Gaussian secret keys)? I would like to understand the extent to which this is an apples-to-apples comparison.\n\nOn a similar note, are you comparing against approaches with similar levels of compute? Your algorithm assumes full parallelization; does this apply to the previous algorithms you compare against?\n\nLIMITATIONS:\nI found the comparisons with other classical approaches to be one of the more interesting aspects of this work, and would have liked to see some of this discussion in the main body of the paper. It would be great if the paper could provide some more fine-grained information on the amount of compute needed for the ML-based approaches and what the implications these attacks have for improving our hardness estimates for LWE with sparse secret distributions.", "TITLE": "Official Review", "RECOMMENDATION": 4, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-25"}