Commit 9635d76
authored
Introduce the ciphertext registry (ethereum#2)
This commit introduces the ciphertext registry, with its three main
components:
* protected storage space for persistent registry entries
* ciphertext handles
* in-memory ciphertext registry that persist for the lifetime of the
transaction/call
The protected storage space is implemented as a separate contract,
linked to the actual one. When we create a contract, we take its address
and run it through SHA256 to get the address of the corresponding
protected storage contract. See more in evm.go, Create().
A ciphertext handle is the SHA256 hash of a ciphertext. It is generated
by the call to the `verifyCiphertext()` precompiled contract.
If a handle is stored in contract storage, we persist the actual
ciphertext in protected storage, along with some metadata. One piece of
metadata is the reference count. In essense, if a handle is stored in
contract storage via SSTORE, the refcount is bumped by 1. If a handle is
overwritten, the refcount is reduced by 1. Additionally, we
automatically verify any handle that points to a ciphertext on SLOAD.
Verifying a ciphertext essentially means storing it in an in-memory map
from hash(ciphertext) => {ciphertext, verified_at_stack_depth}. A
ciphertext is verified only for a particular stack depth and further on.
On the RETURN opcode, we remove entries from the map that are no longer
verified. More information to follow on that approach.
More features and code cleanup will be added in future commits.1 parent 7804a56 commit 9635d76
File tree
7 files changed
+371
-218
lines changed- core/vm
- crypto
- tests/solidity/zama
7 files changed
+371
-218
lines changedLarge diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
| |||
145 | 143 | | |
146 | 144 | | |
147 | 145 | | |
148 | | - | |
149 | 146 | | |
150 | 147 | | |
151 | 148 | | |
| |||
164 | 161 | | |
165 | 162 | | |
166 | 163 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | 164 | | |
178 | 165 | | |
179 | 166 | | |
| |||
225 | 212 | | |
226 | 213 | | |
227 | 214 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 215 | + | |
234 | 216 | | |
235 | 217 | | |
236 | 218 | | |
| |||
293 | 275 | | |
294 | 276 | | |
295 | 277 | | |
296 | | - | |
| 278 | + | |
297 | 279 | | |
298 | 280 | | |
299 | 281 | | |
| |||
334 | 316 | | |
335 | 317 | | |
336 | 318 | | |
337 | | - | |
| 319 | + | |
338 | 320 | | |
339 | 321 | | |
340 | 322 | | |
| |||
383 | 365 | | |
384 | 366 | | |
385 | 367 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
| 368 | + | |
396 | 369 | | |
397 | 370 | | |
398 | 371 | | |
| |||
524 | 497 | | |
525 | 498 | | |
526 | 499 | | |
527 | | - | |
528 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
529 | 514 | | |
530 | 515 | | |
531 | 516 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
513 | 514 | | |
514 | 515 | | |
515 | 516 | | |
516 | | - | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
517 | 530 | | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
522 | 537 | | |
523 | 538 | | |
524 | | - | |
525 | | - | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
526 | 542 | | |
527 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
528 | 558 | | |
529 | 559 | | |
530 | | - | |
531 | | - | |
| 560 | + | |
532 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
533 | 581 | | |
534 | 582 | | |
535 | 583 | | |
| |||
538 | 586 | | |
539 | 587 | | |
540 | 588 | | |
541 | | - | |
542 | | - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
543 | 652 | | |
544 | | - | |
| 653 | + | |
545 | 654 | | |
546 | 655 | | |
547 | 656 | | |
| |||
817 | 926 | | |
818 | 927 | | |
819 | 928 | | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
820 | 936 | | |
821 | 937 | | |
822 | 938 | | |
| |||
0 commit comments