spec: ECSM#655
Conversation
Codex Code ReviewFindings
No other concrete PR-diff issues found in this pass. |
Code Review — ECSM Accelerator SpecGood overall structure. The three-chip decomposition (ECSM → ECDAS → EC_SCALAR) is clean, and the soundness argument for why the point-at-infinity can never appear during double-and-add is well-reasoned. Issues foundMathematical error (spec/ecsm.typ:23) Typo (spec/ecsm.typ:158) Ref typo (spec/src/ecdas.toml:316) Assumption inconsistency (spec/src/ecsm.toml:199) Minor observations
|
Indeed. Fixed it.
Fixed it |
Technically, this is already addressed: the introduction mentions that it accelerates points in
Fixed
It is in the same document, but a section earlier. Disregarding the comment. |
RobinJadoul
left a comment
There was a problem hiding this comment.
- I do wonder how much potential optimization we're leaving on the table by treating
pas a generic prime, rather than using the structure it has - A more descriptive name for the
BITandSERVE_Kinteractions may be in order - The complex arith constraints for equalities mod p tend to have a different order between their "constraint" and "poly", which makes checking correspondence a bit tedious and error-prone
- I have some thoughts about the presentation of the "theory"/background, but trying to focus on the more technical things first
edffcf6 to
32117c5
Compare
RobinJadoul
left a comment
There was a problem hiding this comment.
Mostly concerned about the idx_k thing, the rest is either a quick edit or double checking calculations
|
|
||
| [[variables.constant]] | ||
| name = "id" | ||
| type = "Bit" |
There was a problem hiding this comment.
Technically not a bit if we want it to be extensible
| Applying @limbs:cor:carry-upper-bound with $(L, n) = (2^8, 32)$, we find that | ||
| $ | ||
| #`c0`_i &in [-8160, 8159],\ | ||
| #`c1`_i &in [-24477, 24478].\ |
There was a problem hiding this comment.
I think you're off by a few from what I tried to compute quickly, but it's wider than what I got, so should be safe anyway
There was a problem hiding this comment.
| #`c1`_i &in [-24477, 24478].\ | |
| #`c1`_i &in [-24478, 24477].\ |
RobinJadoul
left a comment
There was a problem hiding this comment.
Decided to quickly script the carry calculations to double check everything.
def M(n, L, mu, alpha):
assert L >= 4
delta = int(mu < alpha)
return mu * n * (L - 1) + alpha - mu - delta
def bounds(n, L, mu_pos, alpha_pos, mu_neg, alpha_neg):
min = -M(n, L, mu_neg, alpha_neg)
max = M(n, L, mu_pos, alpha_pos)
print(f"[{min}, {max}] => [0, {max - min}]")
print("ECSM")
bounds(32, 256, 1, 0, 1, 1)
bounds(32, 256, 3, 0, 3, 1)
print("\nECDA")
bounds(33, 256, 3, 0, 4, 1)
bounds(33, 256, 2, 0, 1, 3)
bounds(33, 256, 2, 0, 2, 2)| #render_constraint_table(ecsm_chip, config, groups: "write_xR") | ||
|
|
||
| == Carry offsets | ||
| We close by deriving the values of `carry_offsets`. |
There was a problem hiding this comment.
naming mismatch: offsets or carry_offsets
| Applying @limbs:cor:carry-upper-bound with $(L, n) = (2^8, 32)$, we find that | ||
| $ | ||
| #`c0`_i &in [-8160, 8159],\ | ||
| #`c1`_i &in [-24477, 24478].\ |
There was a problem hiding this comment.
| #`c1`_i &in [-24477, 24478].\ | |
| #`c1`_i &in [-24478, 24477].\ |
| #`c0`_i &in [-8160, 8159],\ | ||
| #`c1`_i &in [-24477, 24478].\ | ||
| $ | ||
| When we selectc $#`carry_offsets` = (8160, 24477)$, we arrive at |
There was a problem hiding this comment.
| When we selectc $#`carry_offsets` = (8160, 24477)$, we arrive at | |
| When we selectc $#`carry_offsets` = (8160, 24478)$, we arrive at |
This PR introduces the
ECSM(Elliptic Curve Scalar Multiplication) accelerator.