js-libp2p
js-libp2p copied to clipboard
go-js echo / plaintext fails to send message
- Version: 0.35.8
- Platform: Darwin [REDACTED]-Mac-mini.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64
- Subsystem: Insecure
Severity: Medium
Description:
I tried to dial the JS echo listener example from the Go echo dialer example and vice versa over plaintext and in both cases it failed during the handshake.
It seems that the Data property of the pubkey in Exchange is inconsistent where Go simply uses the marshalled value of the encrypted public key and JS includes the entire pubkey object re-encoded as a protobuf.
There also seems to be an issue with the samples themselves where the Go sample uses newline to signify the end of a message and JS does not.
Steps to reproduce the error:
- Change 'noise' in the js example to 'plaintext'.
- In the JS sample folder run
> node listener
- In the Go sample folder run
> ./echo -l 9012 -d /ip4/127.0.0.1/tcp/10333/p2p/QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm -insecure
@gitaaron what is the problem / use case you are trying to solve?
hi @lidel thanks for looking at this! The use case is to assist in development/debugging go-js interop issues.
Here is a little more context in case it is helpful. I was looking at go-js webrtc interop which I believe is still an issue tagged with help wanted.
To assist myself in debugging the problem I figured it might help to look at the traffic over wireshark. This is when I discovered the go-js interop issue over plaintext (more specifically the discrepancy in the exchange object passed).
So I figured I might create a new issue and submit a PR with the fix in case someone else might also find it useful.
I am new to libp2p so your feedback/advice is appreciated.
linked to https://github.com/libp2p/js-libp2p/pull/1111
Triage notes: @gitaaron could you try with latest version and Plaintext encryption?
Unfortunately, still not working for me.
When I try to dial from Go to JS over plaintext echo I see the following error msg in Go -
* [/ip4/127.0.0.1/tcp/10333] failed to negotiate security protocol: proto: required field "Type" not set
When I try to dial JS to Go I see the following error message -
[AggregateError: All promises were rejected] {
[errors]: [
InvalidCryptoExchangeError: Remote did not provide its public key
at encrypt (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/insecure/index.js:58:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Plaintext.secureOutbound (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/insecure/index.js:81:16)
at async DefaultUpgrader._encryptOutbound (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/upgrader.js:447:20)
at async DefaultUpgrader.upgradeOutbound (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/upgrader.js:184:21)
at async TCP.dial (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/node_modules/@libp2p/tcp/dist/src/index.js:50:22)
at async DefaultTransportManager.dial (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/transport-manager.js:77:20)
at async DialRequest.dialAction (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/connection-manager/dialer/index.js:175:20)
at async file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/connection-manager/dialer/dial-request.js:67:28
at async Promise.any (index 0) {
code: 'ERR_ENCRYPTION_FAILED'
}
]
}
Last I looked into it there was a mismatch in the protobuf 'Exchange' message where on the JS side the 'pubkey' seemed to be nested as an additional Exchange.
Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.
Closing as stale