Skip to content

fix: prefix RSA encode bytes#5

Merged
g11tech merged 3 commits into
mainfrom
enum
Oct 27, 2025
Merged

fix: prefix RSA encode bytes#5
g11tech merged 3 commits into
mainfrom
enum

Conversation

@GrapeBaBa
Copy link
Copy Markdown
Member

@GrapeBaBa GrapeBaBa commented Oct 27, 2025

This PR help fix zig/rust/go protobuf encoding difference, zig omits the value 0. It makes the peerid calculation inconsistent with rust/go when using RSA key.

This could be improved when we forked and changed the gremin protobuf lib.

Signed-off-by: Chen Kai <281165273grape@gmail.com>
@GrapeBaBa GrapeBaBa requested review from Copilot and g11tech October 27, 2025 13:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the encoding of RSA public keys when creating peer IDs by adding the protobuf type field prefix that the encoder omits for the default RSA key type. This ensures compatibility with other libp2p implementations that expect this prefix when hashing protobuf-encoded keys.

Key Changes:

  • Modified fromPublicKey to detect RSA keys and prepend the protobuf type field (0x08, 0x00) before hashing
  • Changed protobuf_public_key from const to var to allow reassignment for RSA keys

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/id.zig Outdated
Signed-off-by: Chen Kai <281165273grape@gmail.com>
Signed-off-by: Chen Kai <281165273grape@gmail.com>
@g11tech g11tech merged commit 0e85f33 into main Oct 27, 2025
1 check passed
@g11tech g11tech deleted the enum branch October 27, 2025 16:44
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.

3 participants