HNHacker News
TopNewBestAskShowJobs

pbsd

2,790 karma · joined November 14, 2011

submissionscomments
pbsd··on Elligator: Elliptic-curve points indistinguishable from uniform random strings (2013)
Koblitz in "Elliptic Curve Cryptosystems" [1] dedicated section 3 to how to embed binary strings into points and back, which is of course necessary for elliptic curve ElGamal.

[1] https://doi.org/10.1090/S0025-5718-1987-0866109-5

pbsd··on Convolutions, Fast Fourier Transform and polynomials (2022)
Pollard [1], Nicholson [2], and Schonhage-Strassen [3] seem to have come up with it independently around the same time, using different approaches. Strassen is said to have discovered the Pollard approach in 1968 but there is no (written) record of it.

It should also be noted that, while it was not exactly the birth of the FFT, Cooley-Tukey's 1965 paper [4] on it was what kickstarted research on FFT and its applications. This was just a few years after that.

[1] https://doi.org/10.1090/S0025-5718-1971-0301966-0

[2] https://doi.org/10.1016/S0022-0000(71)80014-4

[3] https://doi.org/10.1007/BF02242355

[4] https://doi.org/10.1090/S0025-5718-1965-0178586-1

pbsd··on The XAES-256-GCM extended-nonce AEAD
The multiplication in CMAC is there to distinguish between full and partial final input blocks. It can't be simply a xor with a constant because that would be easily cancelable in the input, and wouldn't satisfy the required xor-universal-like properties required by the security proof.

The input here is highly restricted so there's no point to it.

pbsd··on Zero Tolerance for Bias
This is the Rao-Sandelius shuffle [1].

[1] https://doi.org/10.1145/3009909

pbsd··on Why is x & -x equal to the largest power of 2 that divides x?
An alternative, more arithmetic, argument:

- x is 2^b*k for some odd k < 2^(n-b)

- -x is 2^n - 2^b*k = 2^b*(2^(n-b)-k)

- k is odd by definition, and (2^(n-b)-k) + k = 0 (mod 2^(n-b)). This means that the LSB must be 1 in both operands, which results in a carry out, and in the following ith bits we have that the sum is 0 mod 2^i if and only if the ith bits of (2^(n-b)-k) and k are distinct. Thus x & -x = 2^b.

pbsd··on The prospects for 128 bit processors (John R. Mashey, 1995)
No, you're thinking of PS{R,L}LQ.
pbsd··on The prospects for 128 bit processors (John R. Mashey, 1995)
The 128-bit wide shifts PS{L,R}LDQ only have byte granularity. They're a special case of a byte shuffle.
pbsd··on Secure Randomness in Go 1.22
Actually it wasn't Knuth; only the 1997 3rd edition contains the lagged Fibonacci name. The first instance of the name I can find is Marsaglia-Tsay in 1985 [1] (and possibly Marsaglia's 1984 "A current view of random number generators", which is impossible to find online).

[1] https://doi.org/10.1016/0024-3795(85)90192-2

pbsd··on Secure Randomness in Go 1.22
The name itself might be due to Knuth; they were initially known as additive generators in other early literature.
pbsd··on Secure Randomness in Go 1.22
Go 1's math/rand would more accurately be called an additive lagged Fibonacci generator. The first publication of it is due to Green, Smith, and Klem [1].

[1] https://doi.org/10.1145/320998.321006

pbsd··on Decoding UTF8 with parallel extract
Brilliant. Can be further simplified to 0x10880 & (0x2240 << i).
pbsd··on Decoding UTF8 with parallel extract
The overlong lookup can also be written without a memory lookup as

    0x10000U >> ((0x1531U >> (i*5)) & 31);
On most current x86 chips this has a latency of 3 cycles -- LEA+SHR+SHR -- which is better than an L1 cache hit almost everywhere.
pbsd··on Automated integer hash function discovery
This bias testing is essentially ruling out candidates with very high probability truncated differentials of Hamming weight 1. In a cryptographic primitive you want to rule out _all_ high-probability differentials, which requires different methods. You also want to rule out other high-probability statistical distinguishing properties, such as linear approximations, higher-order differentials, etc.

That being said, this sort of quick-and-dirty testing is useful to filter out obviously bad candidates at the early design phase of, say, an ARX primitive.

pbsd··on How hard can generating 1024-bit primes be?
The best asymptotic bound is somewhere between n^(1/8sqrt(e) + eps) and n^(1/6.568sqrt(e) + eps), per [1].

[1] https://doi.org/10.1007/BFb0030409

pbsd··on How hard can generating 1024-bit primes be?
You only need to try the _prime_ bases up to 2 log^2(n). So the total number of bases here would be 79060.
pbsd··on Morton: Bit Interleaving in C/C++
Keccak (and other ciphers only using bit rotation and bitwise ops) can use bit interleaving to avoid slow 64-bit rotations on 32-bit hardware, by replacing 1 64-bit rotation by 2 independent 32-bit rotations on the interleaved words [1, §2.1].

[1] https://keccak.team/files/Keccak-implementation-3.2.pdf

pbsd··on Randar: A Minecraft exploit that uses LLL lattice reduction to crack server RNG
Personally I think https://crypto.stackexchange.com/a/86548 is a better answer. It turns the LCG state recovery into a hidden number-like problem, and works out the solution that way. It is easy to go from there to (EC)DSA key recovery.
pbsd··on A quick post on Chen's algorithm
SVP is NP-hard for approximation factors much smaller than this algorithm reaches. This algorithm solves approximation factors of at best O(n^4.5), but NP-hardness is only shown for approximation factors well below n^(1/2). See Figure 1 in page 2 of [1] for a breakdown of the hardness of various approximation factors.

[1] https://cims.nyu.edu/~regev/papers/cvpconp.pdf

pbsd··on Show HN: Matrix Multiplication with Half the Multiplications
It's not quite forgotten. It kind of lives on in the pseudo-dot product Wegman-Carter authenticators like UMAC. See Section 3 of [1] for context.

[1] https://cr.yp.to/antiforgery/pema-20071022.pdf

pbsd··on iMessage with PQ3 Cryptographic Protocol
The LWE problem is one level of abstraction away from the fundamental lattice problems it reduces to. It is somewhat analogous to the Diffie-Hellman problem that many constructions reduce to, which itself is related to the lower-level discrete logarithm problem.

The lattice equivalent of integer factorization is the shortest vector problem: you're given n vectors of length m, and you have to find the sum of integer multiples of those vectors that comes closest to (or a small factor away from the closest) the zero vector. Say you have the 4 vectors

    [ 3 92  4  2]
    [54  0 92 41]
    [19 91 61 48]
    [39 59 40 14].
The shortest vector that you can obtain from adding integer multiples of these vectors is [19 -8 -15 2], which you can obtain by 3*[39 59 40 14] + [19 91 61 48] - 2*[54 0 92 41] - 3*[ 3 92 4 2].

With only 4 vectors it is easy to find the solution here. But the hardness grows exponentially with the dimension, and the dimensions in cryptographically relevant lattices are in the hundreds to thousands.

pbsd··on Magical Fibonacci Formulae
A different way to get a result like this is to observe that the nth Fibonacci number is obtainable as the coefficient of x in x^n mod (x^2-x-1) via the usual matrix exponentiation argument, apply Kronecker substitution, and compute pow(b, n, b**2-b-1)//b.
pbsd··on Popcount walks: next, previous, toward and nearest
x=0 is the last solution to be hit the way I wrote it.
pbsd··on Popcount walks: next, previous, toward and nearest
A simple way to do the latter is

  for(u64 x = -m & m; ;x = (x - m) & m) {
    const u64 r = x ^ m;
    for(u64 t = -x & x; ; t = (t - x) & x) {
      const u64 z = r | t;
      // Use (x,z)
      if(t == 0) break;
    }
    if(x==0) break;
  }
pbsd··on Reasons to Prefer Blake3 over Sha256
While there is more confidence now on the security of SHA-2, or rather the lack of transference of the SHA-1 approach to SHA-2, this was not the case in 2005-2006 when NIST decided to hold the SHA-3 competition. See for example the report on Session 4 of the 2005 NIST workshop on hash functions [1].

[1] https://csrc.nist.gov/events/2005/first-cryptographic-hash-w...

pbsd··on Passive SSH Key Compromise via Lattices [pdf]
Suppose you wanted to find a root of f(x) = x^3 - a mod N. If there is a root smaller than N^(1/3), this reduces to simply computing the integer cube root of a, since there is no wrap-around.

But imagine if the problem is slightly changed to f(x) = (x + padding)^3 - a mod N, for some large but known padding. Now you can't simply compute an integer cube root, and the above doesn't work anymore. But you can look for a product of f(x) by some other polynomial g(x): f(x)g(x) necessarily contains the roots of f(x), but may have smaller coefficients such that evaluating f(x)g(x) at the root you're looking for does not wrap around N.

Now look into what this multiplication looks like: f(x)g(x) = c_0 f(x) + c_1 x f(x) + c_2 x^2 f(x) + ..., where c_i are the unknown coefficients of g(x). This is a sum of integer multiples of known coefficient vectors and, to find the set of coefficients c_i such that this sum is a small as possible is exactly the same as finding a short vector in the lattice (f(x), xf(x), x^2f(x), ...), where the vectors are the coefficients of each (shifted) polynomial. You also have to weight the coefficients according to their exponent, to account for the fact that the coefficient of, say, x^3 needs to be smaller than x to avoid wrap-around.

Once lattice reduction gives you back an f(x)g(x) with small enough coefficients you compute its integer roots, which is doable very quickly, and check which of them work for f(x). That's the gist of it. The full-fledged method also includes powers of f(x) modulo powers of N instead of simply multiplying it by g(x), and that was the trick Coppersmith introduced, but if you understand the simple version the full version is straightforward.

pbsd··on C++23: Removing garbage collection support
extern templates are a C++11 feature. export templates are the removed C++98 feature.
pbsd··on Debunking NIST's calculation of the Kyber-512 security level
FWIW, there are two NTRUs: the original one, which had no djb involvement, and NTRU Prime, which does.
pbsd··on STX – C++17 and C++ 20 error-handling and utility extensions
This is generally known as "freestanding" in the C/C++ world -- https://en.cppreference.com/w/cpp/freestanding
pbsd··on Breaking SHA256: length extension attacks in practice
With appropriate padding to ensure each s is in its own separate input block, that is called "envelope" or "sandwich" MAC, and its security can be reduced to the compression function's security using mostly the same techniques as HMAC.

[1] https://doi.org/10.1007/978-3-540-73458-1_26

[2] https://eprint.iacr.org/2013/248

[3] https://eprint.iacr.org/2021/097

pbsd··on EABitTricks.h
"This" as in finding the next combination. Gosper's trick does.
← PreviousPage 2 of 26Next →