Unsaturated Solinas Heuristics infer too large a number of limbs for p521 x32
JasonGross opened this issue · 1 comments
./src/ExtractionOCaml/unsaturated_solinas 'p521' 32 '(auto)' '2^521 - 1'
suggests 19 limbs, but ./src/ExtractionOCaml/unsaturated_solinas 'p521' 32 18 '2^521 - 1'
succeeds. I thought the overflow check at
fiat-crypto/src/UnsaturatedSolinasHeuristics.v
Lines 369 to 411 in 457cb5e
If I compute @get_num_limbs 1 (2^521) [(1,1)] 32 (Auto 0)
, the loose upperbound list for 18 is [1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 1610612736; 805306368]
(hex: [0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x60000000, 0x30000000]
), squaremod
of this is [85604421717058387968; 83010348331692982272; 80416274946327576576; 77822201560962170880; 75228128175596765184; 72634054790231359488; 70039981404865953792; 67445908019500548096; 64851834634135142400; 62257761248769736704; 59663687863404331008; 57069614478038925312; 54475541092673519616; 51881467707308113920; 49287394321942708224; 46693320936577302528; 45396284243894599680; 44099247551211896832]
. The Z.log2
of these are [66; 66; 66; 66; 66; 65; 65; 65; 65; 65; 65; 65; 65; 65; 65; 65; 65; 65]
. This is off from 64 = 2*32
, so I'm confused how 18 limbs manages to boundscheck...
cc @jadephilipoom @andres-erbsen do you know what's going on here?
Ah, nevermind, synthesizing with 18 limbs results in use of 128-bit integers