Skip to content

identify protocol should validate received public keys #5706

@jameshiew

Description

@jameshiew

Description

A remote peer can provide any public key as part of the identify protocol. This could be validated to match the remote peer's ID. Go/JS libp2p do this sort of validation:

The received public_key is exposed via identify::Event::Received events. e.g. logged to console in the identify-example

// Prints out the info received via the identify event
SwarmEvent::Behaviour(identify::Event::Received { info, .. }) => {
println!("Received {info:?}")
}

Motivation

If downstream users depend on info.public_key (e.g. public_key.to_peer_id()), they may expect it to match the remote peer like in the Go/JS libp2p implementations.

Current Implementation

I couldn't find code in protocols/identify that validated remote peer public keys, testing it out it accepts any public key.

Are you planning to do it yourself in a pull request ?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions