-
Notifications
You must be signed in to change notification settings - Fork 25
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
Remove usage of web3j library #148
Conversation
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.
Looking good. Just a few minor things and a couple of queries.
src/main/java/org/ethereum/beacon/discovery/util/Functions.java
Outdated
Show resolved
Hide resolved
src/test/java/org/ethereum/beacon/discovery/schema/NodeSessionTest.java
Outdated
Show resolved
Hide resolved
private static final int RECIPIENT_KEY_LENGTH = 16; | ||
private static final int INITIATOR_KEY_LENGTH = 16; | ||
private static final int AUTH_RESP_KEY_LENGTH = 16; | ||
private static final int MS_IN_SECOND = 1000; | ||
|
||
private static final Supplier<SecureRandom> SECURE_RANDOM = Suppliers.memoize(SecureRandom::new); | ||
|
||
private static boolean SKIP_SIGNATURE_VERIFY = false; | ||
static { | ||
Security.addProvider(PROVIDER = new BouncyCastleProvider()); |
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.
It would be better to init PROVIDER
inline and then just have
Security.addProvider(PROVIDER = new BouncyCastleProvider()); | |
Security.addProvider(PROVIDER); |
That said, I don't see where PROVIDER
is being used. Why did this move from Hashes
to here?
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.
Why did this move from Hashes to here?
Good question, by some (static) magic it run before everything until this update and doesn't run anymore. I've refactored it a bit to be sure it runs before anything BC
-dependent
src/main/java/org/ethereum/beacon/discovery/util/Functions.java
Outdated
Show resolved
Hide resolved
src/main/java/org/ethereum/beacon/discovery/util/Functions.java
Outdated
Show resolved
Hide resolved
src/main/java/org/ethereum/beacon/discovery/util/Functions.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Adrian Sutton <adrian@symphonious.net>
Co-authored-by: Adrian Sutton <adrian@symphonious.net>
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. Nice work.
PR Description
Removes
web3j-crypto
andweb3j-rlp
usage across code in favor oftuweni
Design consideration:
There is a
SecretKey
intuweni-crypto
withBytes32
source of the private key which is not copied until you use some guardedBytes
source, thisSecretKey
implements finalize filling source with00
's, and when you create anotherSecretKey
with the sameBytes32
source and secondSecretKey
marked to be collected with GC, private key is erased in both as both uses the same instance ofBytes32
(it was not actually copied). From one side it's a good thing to guarantee erasure of data but it forces to use singleSecretKey
instance all over the library avoiding to create it when really needed.I've considered wrapping
SecretKey
with someSigner
interface to hide implementation and benefit from test'sNoopSigner
, but when parameterized it goes straight fromIdentitySchemaInterpreter
toNodeRecord
which is used almost in every class in the package and should take more time to implement while I already spent more time than I should on this task.Fixed Issue(s)
Fixes #147