libp2phttp: HTTP Peer ID Authentication
This enables HTTP peers to authenticate each other's peer ID. This would allow users to use an http transport that has a peer id component (e.g. /dns/example.com/http/p2p/12Foo). I think it's nice to have this for completeness so that an http transport has the same semantics as a libp2p stream transport when doing HTTP with regard to Peer IDs.
There's more testing I want to do here, but I think this is more or less ready for a review.
For a high level overview of the authentication protocol refer to the overview in the spec: https://github.com/libp2p/specs/blob/45006f17d2fa0cede50b2db2311a55061011a3fc/http/peer-id-auth.md#mutual-client-and-server-peer-id-authentication-overview
I can't use base64's appendencode since it was only introduced in go 1.22. Easy enough to backport though.
I've completely refactored this. The handshake logic is now neatly in internal/handshake. The Client API is simpler, and the Server API changed a little bit (in a way that makes it hopefully easier to use). The server uses HMAC to authenticate the opaque and the token. And it's also close to 10x faster (still could be improved, but this might be good enough for now).
~The main missing thing is the test that generates the examples for the spec. I'll work on that next, but otherwise I think this is ready.~ Done.
when you get a chance, could I get a review here and in the spec https://github.com/libp2p/specs/pull/564 @sukunrt .
The new spec is much nicer! Thanks @MarcoPolo