Skip to content
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

Optimization: no need to instantiate SecureRandom on sign() calls #246

Merged
merged 2 commits into from
Jul 14, 2022

Conversation

Nashatyrev
Copy link
Collaborator

Currently Secp256k1PrivateKey.sign() instantiates SecureRandom on every call.
It's obsolete, as BouncyCastle uses it's own SecureRandom singleton when not supplied one.

Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

import org.bouncycastle.asn1.ASN1Primitive
import org.bouncycastle.asn1.ASN1Sequence
import org.bouncycastle.asn1.DERSequenceGenerator
import org.bouncycastle.asn1.*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use * imports normally? I'm not overly fussed just checking.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's kind of historically:

kotlinter {
    disabledRules = arrayOf("no-wildcard-imports")
}

Tried to remove this line. The formatter was unable to fix this automatically. So leaving this 'as is' for now. Have no strong preference of this or that option

@Nashatyrev Nashatyrev merged commit 3529c1b into libp2p:develop Jul 14, 2022
@Nashatyrev Nashatyrev deleted the optimization/sign-no-new-random branch July 18, 2022 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants