1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Reusable example statements over the [`Session`] facade.
//!
//! The constructions here are *statements*, not chiplets: pure drivers of
//! the public DAG surface, shared between the test suite and the
//! `src/bin/` benches so a construction is written (and audited) once.
use Vec;
use crate::;
/// Build `P(−x)` by two different DAG shapes over the modulus pinned at
/// `bound_ptr` and return the two accumulators — equal in value (so
/// canonical interning lands them on one ptr and
/// [`uint_is`](Session::uint_is) closes), distinct in hash (genuinely
/// different DAGs).
///
/// `coeffs` is `c₀ ‥ c_N` (little-endian by degree), `N = coeffs.len() − 1
/// ≥ 1`; every value must already be reduced below the modulus.
///
/// - **Path A** subtracts from a typed zero: `n = 0 − x`, then the plain Horner `(((c_N)·n +
/// c_{N−1})·n + …)·n + c₀` — `1` sub, `N` muls, `N` adds.
/// - **Path B** sign-flips the odd coefficients instead, absorbing every negation into a
/// subtraction: Horner over `x` itself with `A_i = x·A_{i+1} ± c_i` (`+` for even `i`, `−` for
/// odd), and an odd *leading* coefficient folded into the first step (`A_{N−1} = c_{N−1} −
/// c_N·x`) so no negation is ever needed — `N` muls, `N` adds/subs.
///
/// Per degree, the statement costs `2N` `UintMul` and `2N + 1` `UintAdd`
/// relation ops (plus the `N + 3` value leaves and the closing `Is`),
/// which is what makes it a uint-throughput workload: arithmetic
/// dominates, keccak chiplets stay empty. The paths' accumulators
/// coincide in *value* at every even step (path A holds `(−1)^i·A_i`),
/// so roughly half of path B's intermediates dedup onto path A's store
/// blocks — canonical interning exercised mid-chain, not just at the
/// ends.