-
Notifications
You must be signed in to change notification settings - Fork 773
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
client: save preimages feature #3143
Changes from all commits
0906767
1409a05
5e76ea0
c2938eb
3e1984a
76a3876
63a9e61
9f0bf8e
d6af5a9
fe8022a
dbbd07f
50d85b8
6c32301
b338b99
c9ed40a
e0a4baf
8787ac5
157debe
88c85af
5b2cf25
3c63902
7954bb6
a603635
53af5f2
36a8d36
1a34e71
1091eb3
cae6302
3519605
1ac77fa
e2af8de
ba47683
2521755
3a665ff
0a3ae52
7979286
6b10752
626644e
6c8b3f4
fabfba4
939cf9b
760822f
4bf589e
7d001e6
cba0448
f299ad6
5d24fa8
d4eb8e6
3b714fa
ba54f16
9ac950d
e2e5330
66bef47
fa647f2
ec52976
1f1cf19
5a51cb8
0a79975
c0c02f9
c21ef84
562fac2
2eb862e
077b83a
7ddd761
a003c89
89959b7
1c36ec4
142c453
bb6d298
cdb35be
3758656
9b8a5bc
9d1e945
af803b0
6aee56a
58c8ecd
b7214cd
66b18a5
80a2503
73c034d
b4cbeb0
8c59302
3a459fe
cb76436
d128cf6
6bbd14f
0e589de
1c413fa
d5a6ca8
92ac258
e3843bc
0b366a2
1408e29
ad72130
a50ee60
7a0842d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DBKey, MetaDBManager } from '../util/metaDBManager' | ||
|
||
/** | ||
* The `PreImagesManager` saves the preimages of hashed keys. This is necessary for the Verkle transition. | ||
* A "PreImage" of a hash is whatever the input is to the hashed function. So, if one calls `keccak256(X)` with | ||
* output `Y` then `X` is the preimage of `Y`. It thus serves to recover the input to the trapdoor hash function, | ||
* which would otherwise not be feasible. | ||
*/ | ||
export class PreimagesManager extends MetaDBManager { | ||
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. Nit: I would prefer the name 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. I believe that Preimage is actually the correct casing. Preimage is the correct mathematical term (i.e. not pre-image). See for e.g. https://en.wiktionary.org/wiki/preimage |
||
/** | ||
* Returns the preimage for a given hashed key | ||
* @param key the hashed key | ||
* @returns the preimage of the hashed key | ||
*/ | ||
async getPreimage(key: Uint8Array): Promise<Uint8Array | null> { | ||
return this.get(DBKey.Preimage, key) | ||
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. I now realize that this class "only" maps 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. I agree that this API relevance is quite minimal, however I do like that it's abstracting away the concept of "DBKey". Also, we could imagine extending this eventually with more complexity (e.g. handling multiple hashing algorithms, deleting/updating in the context of the transition), so I think this creates a better structure to build upon. |
||
} | ||
|
||
/** | ||
* Saves a preimage to the db for a given hashed key. | ||
* @param key The hashed key | ||
* @param preimage The preimage to save | ||
*/ | ||
async savePreimage(key: Uint8Array, preimage: Uint8Array) { | ||
await this.put(DBKey.Preimage, key, preimage) | ||
} | ||
} |
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.
TBH: I still have my problems to understand what a preimage even is. Can we give this some explicit documentation/explanation? A link to some source also wound't hurt.
Maybe starting here and give the class some line of code docs where an explanation is included.