Skip to main content

hekate_core/
config.rs

1// SPDX-FileCopyrightText: 2026 Andrei Kochergin <andrei@oumuamua.dev>
2// SPDX-FileCopyrightText: 2026 Oumuamua Labs <info@oumuamua.dev>
3// SPDX-License-Identifier: AGPL-3.0-only
4
5use core::fmt;
6
7use crate::errors;
8
9/// Production soundness floor, per Fiat-Shamir round: a proof
10/// is as strong as its weakest round (round-by-round soundness).
11pub const MIN_PRODUCTION_BITS: usize = 128;
12
13/// Most row variables one table may carry. The verifier
14/// rejects a proof that claims a taller table.
15pub const MAX_TABLE_VARS: usize = 32;
16
17/// Largest `fold_arity_log`: bounds the leaf width and the
18/// verifier's interpolation for a bundle-supplied config.
19pub const MAX_FOLD_ARITY_LOG: usize = 4;
20
21/// Outer row-code rate `1/2^OUTER_RATE_LOG2`.
22/// Below 2 the quadratic test has no soundness.
23pub const OUTER_RATE_LOG2: u32 = 4;
24
25/// Target row count of the outer AUX oracle.
26pub const OUTER_ROWS: usize = 32;
27
28/// Precision of `log2_ratio_fixed`:
29/// 32 holds the truncation error below
30/// `num_queries · 2⁻³²`, under one bit.
31pub(crate) const LOG2_FRAC_BITS: u32 = 32;
32
33/// The multiplicity `m` of the Guruswami-Sudan decoder
34/// behind the Johnson estimate, which runs at proximity
35/// `1 − (1 + 1/(2m))·√ρ`.
36const JOHNSON_MULTIPLICITY: u128 = 64;
37
38/// Failures of the `Config` checks and the `CodeRate` decode.
39#[derive(Clone, Copy, Debug, Eq, PartialEq)]
40pub enum Error {
41    /// Estimated security of `round` fell below `min_security_bits`.
42    SecurityTooLow {
43        round: &'static str,
44        estimated_bits: usize,
45        min_bits: usize,
46    },
47
48    /// No scalar to mask;
49    /// a pad of length zero hides nothing.
50    EmptyOuterStatement,
51
52    /// No column opening;
53    /// an unopened oracle proves nothing.
54    ZeroOuterQueries,
55
56    /// The outer code outgrew the largest
57    /// additive-FFT domain we encode.
58    OuterDomainTooLarge { code_len: usize, max_log2: u32 },
59
60    /// `log_inv_rate` decodes to no [`CodeRate`]:
61    /// only 1 (rate 1/2) and 2 (rate 1/4) do.
62    UnsupportedCodeRate { log_inv_rate: u32 },
63
64    /// `fold_arity_log` is 0 or above [`MAX_FOLD_ARITY_LOG`].
65    FoldArity { fold_arity_log: usize },
66
67    /// `early_stop_vars + 1 < fold_arity_log`: some
68    /// heights then admit no stop with whole rounds.
69    EarlyStopBelowArity {
70        early_stop_vars: usize,
71        fold_arity_log: usize,
72    },
73
74    /// The largest polynomial has fewer variables
75    /// than one committed round binds.
76    PoolBelowArity {
77        num_vars: usize,
78        fold_arity_log: usize,
79    },
80
81    /// The codeword of `num_vars + log_inv_rate` index bits
82    /// does not fit a machine word, where shifts would wrap.
83    PoolAboveWord {
84        num_vars: usize,
85        log_inv_rate: usize,
86    },
87
88    /// The uniform blocks of polynomial `poly` cannot hold its
89    /// noise: its unopened leaves would be fixed by the witness.
90    TableBelowNoise {
91        poly: usize,
92        row_vars: usize,
93        noise_cells: usize,
94    },
95}
96
97impl fmt::Display for Error {
98    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
99        match self {
100            Self::SecurityTooLow {
101                round,
102                estimated_bits,
103                min_bits,
104            } => write!(
105                f,
106                "Security too low ({round}): estimated {estimated_bits} bits, \
107                 but {min_bits} required",
108            ),
109            Self::EmptyOuterStatement => {
110                write!(f, "outer statement masks no scalars")
111            }
112            Self::ZeroOuterQueries => write!(f, "outer_queries cannot be zero"),
113            Self::OuterDomainTooLarge { code_len, max_log2 } => write!(
114                f,
115                "outer code length {code_len} needs a domain above the 2^{max_log2} cap",
116            ),
117            Self::UnsupportedCodeRate { log_inv_rate } => {
118                write!(f, "code rate 1/2^{log_inv_rate} is not one of 1/2, 1/4")
119            }
120            Self::FoldArity { fold_arity_log } => write!(
121                f,
122                "fold_arity_log ({fold_arity_log}) must lie in 1..={MAX_FOLD_ARITY_LOG}",
123            ),
124            Self::EarlyStopBelowArity {
125                early_stop_vars,
126                fold_arity_log,
127            } => write!(
128                f,
129                "early_stop_vars ({early_stop_vars}) must be at least \
130                 fold_arity_log - 1 ({fold_arity_log} - 1)",
131            ),
132            Self::PoolBelowArity {
133                num_vars,
134                fold_arity_log,
135            } => write!(
136                f,
137                "largest polynomial has {num_vars} variables, \
138                 below one fold round of {fold_arity_log}",
139            ),
140            Self::PoolAboveWord {
141                num_vars,
142                log_inv_rate,
143            } => write!(
144                f,
145                "largest polynomial has {num_vars} variables at rate 2^-{log_inv_rate}, \
146                 past the {}-bit codeword index",
147                usize::BITS,
148            ),
149            Self::TableBelowNoise {
150                poly,
151                row_vars,
152                noise_cells,
153            } => write!(
154                f,
155                "polynomial {poly}: uniform blocks of 2^{row_vars} rows \
156                 cannot hold its {noise_cells} noise cells",
157            ),
158        }
159    }
160}
161
162/// RS code rate `1/inv_rate` of every fold codeword.
163#[derive(Clone, Copy, Debug, Eq, PartialEq)]
164#[repr(u32)]
165pub enum CodeRate {
166    Half = 1,
167    Quarter = 2,
168}
169
170impl CodeRate {
171    pub const fn log_inv_rate(self) -> u32 {
172        self as u32
173    }
174
175    pub const fn inv_rate(self) -> usize {
176        1 << self.log_inv_rate()
177    }
178}
179
180impl TryFrom<u32> for CodeRate {
181    type Error = Error;
182
183    fn try_from(log_inv_rate: u32) -> Result<Self, Error> {
184        match log_inv_rate {
185            1 => Ok(Self::Half),
186            2 => Ok(Self::Quarter),
187            _ => Err(Error::UnsupportedCodeRate { log_inv_rate }),
188        }
189    }
190}
191
192#[derive(Clone, Debug)]
193pub struct Config {
194    /// Code rate of the fold's RS codewords;
195    /// [`Config::prod_at`] derives the query count from it.
196    pub code_rate: CodeRate,
197
198    /// Number of LDT spot-check queries.
199    pub num_queries: usize,
200
201    /// Variables one committed round of the fold binds;
202    /// its leaves hold `2^fold_arity_log` symbols.
203    pub fold_arity_log: usize,
204
205    /// Bound on the variables of the fold's final layer;
206    /// [`crate::fold::FoldLayout`] derives the stop under it.
207    pub early_stop_vars: usize,
208
209    /// Fold layouts and draws whose estimated
210    /// bits fall below this are rejected.
211    pub min_security_bits: usize,
212
213    /// Column openings of the outer argument.
214    pub outer_queries: usize,
215
216    /// Blind units, one-time pad and outer
217    /// argument on; `false` proves in the clear.
218    pub zero_knowledge: bool,
219}
220
221impl Default for Config {
222    fn default() -> Self {
223        Self::prod()
224    }
225}
226
227impl Config {
228    /// Production parameters: 128-bit soundness with the
229    /// `MIN_PRODUCTION_BITS` acceptance threshold. The `Default`.
230    pub fn prod() -> Self {
231        Self::prod_at(CodeRate::Half)
232    }
233
234    /// [`Config::prod`] at `code_rate`.
235    pub fn prod_at(code_rate: CodeRate) -> Self {
236        Self::at_bits(MIN_PRODUCTION_BITS, code_rate)
237    }
238
239    /// `bits` of soundness at `code_rate`: the fewest fold
240    /// and outer queries whose query terms clear `bits`,
241    /// which every draw, layout and hasher is then held to.
242    pub fn at_bits(bits: usize, code_rate: CodeRate) -> Self {
243        Self {
244            code_rate,
245            num_queries: fold_floor_queries(bits, code_rate),
246            fold_arity_log: 4,
247            early_stop_vars: 11,
248            min_security_bits: bits,
249            outer_queries: outer_floor_queries(bits),
250            zero_knowledge: true,
251        }
252    }
253
254    /// Fast, low-soundness parameters for tests and experiments;
255    /// `min_security_bits = 0` accepts weak layouts. Never deploy.
256    pub fn dev() -> Self {
257        Self {
258            num_queries: 4,
259            min_security_bits: 0,
260            outer_queries: 4,
261            zero_knowledge: false,
262            ..Self::prod()
263        }
264    }
265
266    /// Blind columns committed with the whole eval master.
267    pub fn blind_units(&self) -> usize {
268        usize::from(self.zero_knowledge)
269    }
270
271    /// Rejects a fold arity outside `1..=MAX_FOLD_ARITY_LOG`
272    /// and an early stop below one fold round.
273    pub fn check_fold(&self) -> errors::Result<()> {
274        let arity_log = self.fold_arity_log;
275
276        if !(1..=MAX_FOLD_ARITY_LOG).contains(&arity_log) {
277            return Err(Error::FoldArity {
278                fold_arity_log: arity_log,
279            }
280            .into());
281        }
282
283        if self.early_stop_vars < arity_log - 1 {
284            return Err(Error::EarlyStopBelowArity {
285                early_stop_vars: self.early_stop_vars,
286                fold_arity_log: arity_log,
287            }
288            .into());
289        }
290
291        Ok(())
292    }
293
294    /// Rejects a draw whose [`Config::draw_bits`]
295    /// fall below `min_security_bits`; 0 waives it.
296    pub fn check_draw(
297        &self,
298        round: &'static str,
299        field_bits: usize,
300        events: u128,
301    ) -> errors::Result<()> {
302        if self.min_security_bits == 0 {
303            return Ok(());
304        }
305
306        let bits = self.draw_bits(field_bits, events);
307
308        if bits < self.min_security_bits {
309            return Err(Error::SecurityTooLow {
310                round,
311                estimated_bits: bits,
312                min_bits: self.min_security_bits,
313            }
314            .into());
315        }
316
317        Ok(())
318    }
319
320    /// One Fiat-Shamir draw from a `2^field_bits` field that at most
321    /// `events` values defeat, in bits: `field_bits − ⌈log₂ events⌉`.
322    pub fn draw_bits(&self, field_bits: usize, events: u128) -> usize {
323        let log_events = events
324            .max(1)
325            .checked_next_power_of_two()
326            .map_or(u128::BITS, u128::ilog2) as usize;
327
328        field_bits.saturating_sub(log_events)
329    }
330
331    /// Rejects a `digest_bytes`-wide hash whose collision resistance,
332    /// half its bits, falls below `min_security_bits`; 0 waives it.
333    pub fn check_digest(&self, digest_bytes: usize) -> errors::Result<()> {
334        let bits = 4 * digest_bytes;
335
336        if self.min_security_bits != 0 && bits < self.min_security_bits {
337            return Err(Error::SecurityTooLow {
338                round: "digest",
339                estimated_bits: bits,
340                min_bits: self.min_security_bits,
341            }
342            .into());
343        }
344
345        Ok(())
346    }
347}
348
349/// `floor(log₂(n / m) · 2^LOG2_FRAC_BITS)` for `n > m >= 1`.
350/// The Q60 mantissa keeps the squaring `y² < 2¹²²`, inside `u128`.
351pub(crate) const fn log2_ratio_fixed(n: u128, m: u128) -> u128 {
352    const S: u32 = 60;
353
354    let mut scaled_m = m;
355    let mut int_part: u128 = 0;
356
357    while scaled_m <= n / 2 {
358        scaled_m <<= 1;
359        int_part += 1;
360    }
361
362    // m·2^int_part ∈ (n/2, n],
363    // y = n/(m·2^int_part) ∈ [1, 2) in Q_S.
364    let mut y = (n << S) / scaled_m;
365    let mut frac: u128 = 0;
366
367    let mut i = 0;
368    while i < LOG2_FRAC_BITS {
369        y = (y * y) >> S;
370
371        if y >= 2u128 << S {
372            y >>= 1;
373            frac |= 1u128 << (LOG2_FRAC_BITS - 1 - i);
374        }
375
376        i += 1;
377    }
378
379    (int_part << LOG2_FRAC_BITS) | frac
380}
381
382/// Returns the bits `num_queries` queries prove at unique decoding:
383/// `⌊t · log₂(2/(1 + ρ))⌋` in integers, as libm `powf`/`log2` are not
384/// bit-reproducible and prover and verifier derive one geometry.
385pub(crate) const fn unique_query_bits(num_queries: usize, log_inv_rate: usize) -> usize {
386    let inv_rate = 1u128 << log_inv_rate;
387    let log2_ratio = log2_ratio_fixed(2 * inv_rate, inv_rate + 1);
388
389    ((num_queries as u128 * log2_ratio) >> LOG2_FRAC_BITS) as usize
390}
391
392/// Returns the bits `num_queries` queries prove at the
393/// Johnson radius: `⌊t · (ω/2 − log₂(1 + 1/(2m)))⌋`.
394pub(crate) const fn johnson_query_bits(num_queries: usize, log_inv_rate: usize) -> usize {
395    let m = JOHNSON_MULTIPLICITY;
396    let gap_upper = log2_ratio_fixed(2 * m + 1, 2 * m) + 1;
397    let per_query = ((log_inv_rate as u128) << (LOG2_FRAC_BITS - 1)) - gap_upper;
398
399    ((num_queries as u128 * per_query) >> LOG2_FRAC_BITS) as usize
400}
401
402/// Returns the log₂ of the factor the Johnson proximity error
403/// puts on `|D|²/|F|`, rounded up: `(m + ½)^7 / (3ρ^{3/2})`
404/// (ePrint 2024/1571 Thm 2).
405pub(crate) const fn johnson_factor_log2(log_inv_rate: usize) -> usize {
406    let two_m_plus_one = 2 * JOHNSON_MULTIPLICITY + 1;
407    let upper = log2_ratio_fixed(two_m_plus_one.pow(7), 3 << 7)
408        + 1
409        + ((3 * log_inv_rate as u128) << (LOG2_FRAC_BITS - 1));
410
411    upper.div_ceil(1 << LOG2_FRAC_BITS) as usize
412}
413
414/// Returns the most codewords within the Johnson-radius proximity
415/// of any word: `⌈(m + ½)/√ρ⌉` (ePrint 2024/1571 Prop. 1).
416pub(crate) const fn johnson_list_bound(log_inv_rate: usize) -> u128 {
417    let two_m_plus_one = 2 * JOHNSON_MULTIPLICITY + 1;
418    let target = (two_m_plus_one * two_m_plus_one) << log_inv_rate;
419
420    let mut bound = 1;
421    while 4 * bound * bound < target {
422        bound += 1;
423    }
424
425    bound
426}
427
428/// Fewest queries whose fold term clears `bits` at `code_rate`.
429const fn fold_floor_queries(bits: usize, code_rate: CodeRate) -> usize {
430    let log_inv_rate = code_rate.log_inv_rate() as usize;
431    let johnson = bits <= MIN_PRODUCTION_BITS;
432
433    let mut queries = 1;
434    loop {
435        let term = match johnson {
436            true => johnson_query_bits(queries, log_inv_rate),
437            false => unique_query_bits(queries, log_inv_rate),
438        };
439
440        if term >= bits {
441            return queries;
442        }
443
444        queries += 1;
445    }
446}
447
448/// Fewest outer queries clearing `bits` (Ligero journal Lemma 4.6).
449const fn outer_floor_queries(bits: usize) -> usize {
450    let inv_rate = 1u128 << OUTER_RATE_LOG2;
451    let per_query = log2_ratio_fixed(2 * inv_rate, inv_rate + 2);
452
453    let mut queries = 1;
454    while ((queries as u128 * per_query) >> LOG2_FRAC_BITS) < bits as u128 {
455        queries += 1;
456    }
457
458    queries
459}
460
461#[cfg(test)]
462mod tests {
463    use super::*;
464
465    #[test]
466    fn default_is_prod() {
467        assert_eq!(Config::default().min_security_bits, MIN_PRODUCTION_BITS);
468        assert_eq!(Config::default().num_queries, Config::prod().num_queries);
469    }
470
471    #[test]
472    fn prod_queries_are_fewest_clearing_fold_floor() {
473        for (rate, queries) in [(CodeRate::Half, 262), (CodeRate::Quarter, 130)] {
474            let t = Config::prod_at(rate).num_queries;
475            let log_inv_rate = rate.log_inv_rate() as usize;
476
477            assert_eq!(t, queries);
478            assert!(johnson_query_bits(t, log_inv_rate) >= MIN_PRODUCTION_BITS);
479            assert!(johnson_query_bits(t - 1, log_inv_rate) < MIN_PRODUCTION_BITS);
480        }
481    }
482
483    #[test]
484    fn at_bits_derives_fold_and_outer_queries() {
485        for (bits, half, quarter, outer) in [
486            (100, 205, 102, 121),
487            (128, 262, 130, 155),
488            (220, 531, 325, 266),
489        ] {
490            let config = Config::at_bits(bits, CodeRate::Half);
491
492            assert_eq!(config.min_security_bits, bits);
493            assert_eq!(config.num_queries, half);
494            assert_eq!(config.outer_queries, outer);
495            assert_eq!(
496                Config::at_bits(bits, CodeRate::Quarter).num_queries,
497                quarter
498            );
499        }
500
501        assert_eq!(
502            Config::prod().outer_queries,
503            outer_floor_queries(MIN_PRODUCTION_BITS)
504        );
505    }
506
507    #[test]
508    fn digest_clears_half_its_bits() {
509        let prod = Config::prod();
510        let wide = Config::at_bits(220, CodeRate::Half);
511
512        assert!(prod.check_digest(32).is_ok());
513        assert!(wide.check_digest(64).is_ok());
514        assert!(Config::dev().check_digest(16).is_ok());
515
516        assert!(matches!(
517            wide.check_digest(32),
518            Err(errors::Error::Config(Error::SecurityTooLow {
519                round: "digest",
520                estimated_bits: 128,
521                min_bits: 220,
522            }))
523        ));
524        assert!(prod.check_digest(16).is_err());
525    }
526
527    #[test]
528    fn unique_query_bits_matches_float_within_one_bit() {
529        for rate in [CodeRate::Half, CodeRate::Quarter] {
530            let inv_rate = rate.inv_rate();
531            let per_query = (1.0 + 1.0 / inv_rate as f64) / 2.0;
532
533            for num_queries in (50..=400).step_by(7) {
534                let reference = (-per_query.powf(num_queries as f64).log2()).floor();
535                let integer = unique_query_bits(num_queries, rate.log_inv_rate() as usize) as f64;
536
537                assert!(
538                    (integer - reference).abs() <= 1.0,
539                    "rate 1/{inv_rate}, {num_queries} queries: {integer} vs {reference}",
540                );
541            }
542        }
543    }
544
545    #[test]
546    fn draw_sits_on_production_floor_edge() {
547        let prod = Config::prod();
548        let edge = 1u128 << (128 - MIN_PRODUCTION_BITS);
549
550        assert_eq!(prod.draw_bits(128, edge), MIN_PRODUCTION_BITS);
551        assert_eq!(prod.draw_bits(128, edge + 1), MIN_PRODUCTION_BITS - 1);
552
553        assert!(prod.check_draw("bus draw", 128, edge).is_ok());
554        assert!(matches!(
555            prod.check_draw("bus draw", 128, edge + 1),
556            Err(errors::Error::Config(Error::SecurityTooLow {
557                round: "bus draw",
558                ..
559            }))
560        ));
561    }
562
563    #[test]
564    fn draw_clears_for_one_event_and_dev_configs() {
565        let prod = Config::prod();
566
567        assert_eq!(prod.draw_bits(128, 0), 128);
568        assert_eq!(prod.draw_bits(128, 1), 128);
569        assert!(prod.check_draw("bus draw", 128, 0).is_ok());
570
571        let dev = Config::dev();
572
573        assert_eq!(dev.min_security_bits, 0);
574        assert!(dev.check_draw("bus draw", 128, 1 << 60).is_ok());
575    }
576
577    #[test]
578    fn draw_saturates_past_u128_events() {
579        assert_eq!(Config::prod().draw_bits(256, u128::MAX), 128);
580    }
581
582    #[test]
583    fn bus_weight_past_128_bit_floor_clears_at_256_bits() {
584        let prod = Config::prod();
585        let weight = 1u128 << 30;
586
587        assert!(prod.check_draw("bus draw", 128, weight).is_err());
588        assert!(prod.check_draw("bus draw", 256, weight).is_ok());
589    }
590
591    #[test]
592    fn code_rate_decodes_only_half_and_quarter() {
593        for rate in [CodeRate::Half, CodeRate::Quarter] {
594            assert_eq!(CodeRate::try_from(rate.log_inv_rate()), Ok(rate));
595        }
596
597        for log_inv_rate in [0, 3, u32::MAX] {
598            assert_eq!(
599                CodeRate::try_from(log_inv_rate),
600                Err(Error::UnsupportedCodeRate { log_inv_rate })
601            );
602        }
603    }
604
605    #[test]
606    fn johnson_query_bits_matches_float_within_one_bit() {
607        let gap = (1.0 + 1.0 / (2 * JOHNSON_MULTIPLICITY) as f64).log2();
608        for rate in [CodeRate::Half, CodeRate::Quarter] {
609            let log_inv_rate = rate.log_inv_rate() as usize;
610            let per_query = log_inv_rate as f64 / 2.0 - gap;
611
612            for num_queries in (50..=400).step_by(7) {
613                let reference = (num_queries as f64 * per_query).floor();
614                let integer = johnson_query_bits(num_queries, log_inv_rate) as f64;
615
616                assert!(
617                    (integer - reference).abs() <= 1.0,
618                    "rate 1/{}, {num_queries} queries: {integer} vs {reference}",
619                    rate.inv_rate(),
620                );
621            }
622        }
623    }
624
625    #[test]
626    fn johnson_factor_and_list_bound_round_up() {
627        let half_m = JOHNSON_MULTIPLICITY as f64 + 0.5;
628        for log_inv_rate in [1, 2] {
629            let rho = 0.5f64.powi(log_inv_rate as i32);
630            let factor = (half_m.powi(7) / (3.0 * rho.powf(1.5))).log2().ceil();
631            let list = (half_m / rho.sqrt()).ceil();
632
633            assert_eq!(johnson_factor_log2(log_inv_rate), factor as usize);
634            assert_eq!(johnson_list_bound(log_inv_rate), list as u128);
635        }
636    }
637
638    #[test]
639    fn johnson_list_bound_covers_counting_bound() {
640        let m = JOHNSON_MULTIPLICITY as f64;
641
642        for log_inv_rate in [1, 2] {
643            let rho = 0.5f64.powi(log_inv_rate as i32);
644            let alpha = (1.0 + 1.0 / (2.0 * m)) * rho.sqrt();
645            let counting = (alpha - rho) / (alpha * alpha - rho);
646
647            assert!(
648                counting < johnson_list_bound(log_inv_rate) as f64,
649                "rate 1/{}: {counting}",
650                1 << log_inv_rate
651            );
652        }
653    }
654
655    #[test]
656    fn johnson_binding_error_clears_floor_through_36_vars() {
657        let polys = 64.0f64;
658        let m = JOHNSON_MULTIPLICITY as f64;
659        let floor = 2f64.powi(-(MIN_PRODUCTION_BITS as i32));
660
661        for rate in [CodeRate::Half, CodeRate::Quarter] {
662            let log_inv_rate = rate.log_inv_rate() as usize;
663            let omega = log_inv_rate as f64;
664            let queries = Config::prod_at(rate).num_queries as f64;
665
666            let kappa = (m + 0.5).powi(7) * 2f64.powf(1.5 * omega) / 3.0;
667            let nu = johnson_list_bound(log_inv_rate) as f64;
668            let per_query = (1.0 + 1.0 / (2.0 * m)) * 2f64.powf(-omega / 2.0);
669
670            let error = |vars: f64| {
671                let domain = 2f64.powf(vars + omega);
672                let degrees = (polys + 1.0) * kappa * domain * domain
673                    + nu * (2.0 * polys - 1.0 + vars)
674                    + 2.0 * vars * nu;
675
676                degrees * 2f64.powi(-256) + per_query.powf(queries)
677            };
678
679            for vars in 1..=36 {
680                assert!(
681                    error(vars as f64) < floor,
682                    "rate 1/{}, {vars} vars",
683                    rate.inv_rate()
684                );
685            }
686
687            assert!(error(37.0) >= floor, "rate 1/{}", rate.inv_rate());
688        }
689    }
690}