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

fix: add DER decoder and allow passing protobuf digest #3013

Merged
merged 5 commits into from
Feb 27, 2025

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Feb 26, 2025

Adds enough of a DER decoder/encoder to parse/store public keys from PKIX bytes and private keys in PKCS#1 bytes.

Also allows passing the digest of a public key in to publicKeyFromProtobuf so we can avoid having to recalculate it.

This becomes a big bottleneck when loading a routing table's worth of peers from the peer store where many of them are RSA peers.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

Adds enough of a DER decoder to parse public keys from PKIX bytes.

Also allows passing the digest of a public key in to `publicKeyFromProtobuf`
so we can avoid having to recalculate it.

This becomes a big bottleneck when loading a routing table's worth
of peers from the peer store where many of them are RSA peers.
@achingbrain achingbrain requested a review from a team as a code owner February 26, 2025 17:50
achingbrain added a commit that referenced this pull request Feb 26, 2025
This with the changes from #3013 roughly doubles the throughput of
loading RSA peers from the peer store which is a massive bottleneck
when restarting the amino bootstrapper.

Before:

```
 % node benchmarks/load-peers.js
read all x 5.94 ops/sec ±1.37% (33 runs sampled)
```

After:

```
% node benchmarks/load-peers.js
read all x 12.43 ops/sec ±1.18% (63 runs sampled)
```
achingbrain added a commit that referenced this pull request Feb 26, 2025
This with the changes from #3013 roughly doubles the throughput of
loading RSA peers from the peer store which is a massive bottleneck
when restarting the amino bootstrapper.

Before:

```
 % node benchmarks/load-peers.js
read all x 5.94 ops/sec ±1.37% (33 runs sampled)
```

After:

```
% node benchmarks/load-peers.js
read all x 12.43 ops/sec ±1.18% (63 runs sampled)
```
@achingbrain achingbrain merged commit 9acccaa into main Feb 27, 2025
33 checks passed
@achingbrain achingbrain deleted the fix/add-der-decoder branch February 27, 2025 16:36
@achingbrain achingbrain mentioned this pull request Feb 27, 2025
achingbrain added a commit that referenced this pull request Feb 27, 2025
This with the changes from #3013 roughly doubles the throughput of loading RSA peers from the peer store which is a massive bottleneck when restarting the amino bootstrapper.

Before:

```
 % node benchmarks/load-peers.js
read all x 5.94 ops/sec ±1.37% (33 runs sampled)
```

After:

```
% node benchmarks/load-peers.js
read all x 12.43 ops/sec ±1.18% (63 runs sampled)
```
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.

1 participant