Files
LithosAnanke/logs/20261120-fe25519
Claude 1990a40f09 fe25519: take the carry out by multiplying, not by a left shift of a negative value
fe25519_carry's c << 51, with c negative after fe25519_sub, is
undefined in C99; the nightly's sanitized mesh boot stopped on it
(2026-11-20, run 333), reaching it through CI's signed capsules.
c * 2^51 is the same value. test_fe25519 (16 checks: values that
send a limb negative, and RFC 8032 tests 1 and 2 signed and verified)
runs in make -C v4 test and under ASan+UBSan in sanitize; it failed
first under UBSan at fe25519.c:31:26. Gates pass, POST 990/990.
The acceptance protocol runs before it reaches a PR (ruled: the next
PR, not #198).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-20 14:01:15 +00:00
..

The nightly's v4-checks failure of 2026-11-20 (run 333, job 923, on master fdf9c194), reproduced
without the capsule-signing key.

CI:    san-mesh-boot: kernel/src/crypto/fe25519.c:31:26: runtime error: left shift of negative value -1
Here:  repro.c, built with the sanitize gate's flags (-O1 -fsanitize=address,undefined
       -fno-sanitize-recover=all) against kernel/src/crypto/fe25519.c alone: run.txt, the same line.

Cause: fe25519_carry computes c = v[i] >> 51 and then v[i] -= c << 51. After fe25519_sub, a limb is
negative, c is -1, and a left shift of a negative value is undefined in C99. The comment says the
code "works for negative limbs too (arithmetic shift preserves sign)", which holds for the right
shift, not the left. Line 35 (limb 4) has the same form.

Why locally the sanitize gate passes: with no signing key the capsules are unsigned, and the mesh
boot never verifies an Ed25519 signature, so this code does not run there. CI has the key.

Not fixed (reported to Captain Bob).