-
Notifications
You must be signed in to change notification settings - Fork 1
spec: ECSM
#655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: spec/main
Are you sure you want to change the base?
spec: ECSM
#655
Changes from all commits
884c5ad
1c274bd
d2d08d8
3a46d5a
bd64b62
d098975
47a5be3
b9530a9
5ae2283
e3848b5
fe4e3dd
7e12156
7988057
6db8da4
aab3904
0a9d87e
d9a1c3e
33d65ea
bac746b
f604cd5
18a815a
d7cefb2
1b4a50d
1764697
93c7eb0
33e846e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| name = "EC_SCALAR" | ||
|
|
||
| [[variables.input]] | ||
| name = "timestamp" | ||
| type = "DWordWL" | ||
| desc = "timestamp at which to serve the constant" | ||
| pad = 0 | ||
|
|
||
| [[variables.input]] | ||
| name = "ptr" | ||
| type = "DWordWL" | ||
| desc = "pointer to the first byte of the scalar" | ||
| pad = 0 | ||
|
Comment on lines
+9
to
+13
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we doing a bunch of MEMWs in this chip? The calling ECSM has already read all of K into byte limbs, so we can just take in the limb as input and decompose it, right? I guess the reason is that EC_SCALAR recurses onto itself, reducing the interactions in the ECSM table, but I think for total area it'd be better feed in the bytes directly; at which point, there may be some tradeoff between how many bits EC_SCALAR does at once for width vs depth, but again probably total area tells us to just make it 256 wide?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There may even be some approach where we avoid the recursion of ECDAS as well, and simply let the EC_SCALAR chip emit the sequence of double/add steps that need to be performed. Not entirely sure if that wouldn't introduce too many more interactions atm, but it's potentially cleaner than having to reason about the recursion stopping. |
||
|
|
||
| [[variables.input]] | ||
| name = "offset" | ||
| type = "Byte" | ||
| desc = "index of limb" | ||
| pad = 0 | ||
|
|
||
| [[variables.auxiliary]] | ||
| name = "limb_bits" | ||
| type = ["Bit", 8] | ||
| desc = "bit-decomposition of the limb being read" | ||
| pad = ["arr", 0, 0, 0, 0, 0, 0, 0, 0] | ||
|
|
||
| [[variables.auxiliary]] | ||
| name = "last_limb" | ||
| type = "Bit" | ||
| desc = "whether this is the last limb to read" | ||
| pad = 0 | ||
|
|
||
| [[variables.virtual]] | ||
| name = "limb" | ||
| type = "Byte" | ||
| desc = "limb being read" | ||
| def = {poly=["sum", ["=", "i", 0], 7, ["*", ["^", 2, "i"], ["idx", "limb_bits", "i"]]]} | ||
|
|
||
| [[variables.multiplicity]] | ||
| name = "μ" | ||
| type = "Bit" | ||
| desc = "" | ||
| pad = 0 | ||
|
|
||
| [[assumptions]] | ||
| desc = "$#`ptr` + #`offset`$ does not overflow the bottom limb" | ||
|
|
||
| [[constraint_groups]] | ||
| name = "recv" | ||
|
|
||
| [[constraints.recv]] | ||
| kind = "interaction" | ||
| tag = "SERVE_K" | ||
| input = ["timestamp", "ptr", "offset"] | ||
| multiplicity = ["-", "μ"] | ||
|
|
||
| [[constraints.recv]] | ||
| kind = "template" | ||
| tag = "IS_BIT" | ||
| input = ["μ"] | ||
|
|
||
| [[constraint_groups]] | ||
| name = "read" | ||
|
|
||
| [[constraints.read]] | ||
| kind = "interaction" | ||
| tag = "MEMW" | ||
| input = [0, ["+", "ptr", ["arr", ["cast", "offset", "Word"], 0]], ["arr", "limb", 0, 0, 0, 0, 0, 0, 0], ["+", "timestamp", ["cast", 1, "DWordWL"]], 0, 0, 0] | ||
| output = ["arr", "limb", 0, 0, 0, 0, 0, 0, 0] | ||
| multiplicity = "μ" | ||
|
|
||
| [[constraints.read]] | ||
| kind = "template" | ||
| tag = "IS_BIT" | ||
| input = [["idx", "limb_bits", "i"]] | ||
| iter = ["i", 0, 7] | ||
|
|
||
|
|
||
| [[constraint_groups]] | ||
| name = "serve" | ||
|
|
||
| [[constraints.serve]] | ||
| kind = "interaction" | ||
| tag = "BIT" | ||
| input = ["timestamp", ["+", ["*", 8, "offset"], "i"]] | ||
| iter = ["i", 0, 7] | ||
| multiplicity = ["idx", "limb_bits", "i"] | ||
|
|
||
| [[constraints.serve]] | ||
| kind = "arith" | ||
| constraint = "$#`limb_bits`_i = 1 => #`μ` = 1$" | ||
| poly = ["*", ["idx", "limb_bits", "i"], ["not", "μ"]] | ||
| iter = ["i", 0, 7] | ||
|
|
||
| [[constraint_groups]] | ||
| name = "recurse" | ||
|
|
||
| [[constraints.recurse]] | ||
| kind = "template" | ||
| tag = "IS_BIT" | ||
| input = ["last_limb"] | ||
|
|
||
| [[constraints.recurse]] | ||
| kind = "arith" | ||
| constraint = "$#`last_limb` = 1 => #`μ` = 1$" | ||
| poly = ["*", "last_limb", ["not", "μ"]] | ||
|
|
||
| [[constraints.recurse]] | ||
| kind = "arith" | ||
| constraint = "$#`last_limb` = 1 => #`offset` = 0$" | ||
| poly = ["*", "last_limb", "offset"] | ||
|
|
||
| [[constraints.recurse]] | ||
| kind = "interaction" | ||
| tag = "SERVE_K" | ||
| input = ["timestamp", "ptr", ["-", "offset", 1]] | ||
| multiplicity = ["-", "μ", "last_limb"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe interesting to make this
-11instead, so that we essentially reserve some extra space for more hashes?