-
Notifications
You must be signed in to change notification settings - Fork 283
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
Implement a wrapper around c-kzg jni bindings #6520
Conversation
.loadBytes(path) | ||
.orElseThrow(() -> new FileNotFoundException("Not found")); | ||
|
||
File temp = File.createTempFile("resource", ".tmp"); |
Check warning
Code scanning / CodeQL
Local information disclosure in a temporary directory
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.
Makes sense to me to leave CkzgLoader
as a decoupling layer in case we'll different libraries in the future to choose from.
I provided some initial comments
* @param path a path to a trusted setup file in filesystem | ||
* @throws KzgException if file not found or arguments from file are incorrect | ||
*/ | ||
void loadTrustedSetup(final String path) throws KzgException; |
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.
we don't use final
in interfaces
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.
My bad, fixed
* @param blobs Blobs | ||
* @return the aggregated proof | ||
*/ | ||
KZGProof computeAggregateKzgProof(List<Bytes> blobs); |
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.
shouldn't we have throws KzgException;
on all methods here?
return kzgImpl.verifyKzgProof(kzgCommitment, z, y, kzgProof); | ||
} | ||
|
||
private static String copyResourceToTempFile(final String path) throws IOException { |
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.
could we pass-through the file if it is a local path?
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.
yes, but I guess we will need absolute path
also how could I recognize it?
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.
is you switch path from String
to URI
and then getScheme().equalsIgnoreCase("file")
?
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.
Thank you
also I decided to pass URL there instead of String, so it's clear that it comes with scheme and not just path
KZG.loadTrustedSetup(resourcePath); | ||
KZG.resetTrustedSetup(); | ||
} | ||
|
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.
We could add another test named like testKzgLoadTrustedSetupTwice
to verify that we cannot load a setup without resetting the previous one
Worth also checking what happens if we call the kzg functions without having previously loaded any setup |
throws KzgException { | ||
try { | ||
return CKzg4844JNI.verifyAggregateKzgProof( | ||
blobs.stream().reduce(Bytes::wrap).orElseThrow().toArray(), |
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.
empty blobs and commitments are actually a thing: ethereum/consensus-specs#3093
I think we should cover the case here and in tests
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.
yeah, doing it already, nice catch!
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.
LGTM.
we should do an optimization round. I'll track it in the epic backlog
PR Description
I'm pretty unsure on everything here, but need to start from something
Some notes:
KZGLoader
hereminimal
setup anywhereFixed Issue(s)
Fixes #6470
Documentation
doc-change-required
label to this PR if updates are required.Changelog