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

RLPx p2p crypto layer (work in progress, do not merge) #262

Closed
wants to merge 34 commits into from

Conversation

zelig
Copy link
Contributor

@zelig zelig commented Jan 18, 2015

implements the RLPx crypto spec

return
}
// check previous session token
if sessionToken == nil {

Choose a reason for hiding this comment

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

To limit potential resource abuse from malicious peers, we can move this check to the top of the function, to avoid unnecessary CPU work of converting remotePubKeyDER and generating the shared ECIES key if not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Gustav.
This code is just my initial stab, not ready to review really, plus the spec is a moving target too.

- correct sizes for the blocks : sec signature 65, ecies sklen 16, keylength 32
- added allocation to Xor (should be optimized later)
- no pubkey reader needed, just do with copy
- restructuring now into INITIATE, RESPOND, COMPLETE -> newSession initialises the encryption/authentication layer
- crypto identity can be part of client identity, some initialisation when server created
- add session token check and fallback to shared secret in responder call too
- use explicit length for the types of new messages
- fix typo resp[resLen-1] = tokenFlag
- abstract the entire handshake logic in cryptoId.Run() taking session-relevant parameters
- changes in peer to accomodate how the encryption layer would be switched on
- modify arguments of handshake components
- fixed test getting the wrong pubkey but it till crashes on DH in newSession()
- set proper public key serialisation length in pubLen = 64
- reset all sizes and offsets
- rename from DER to S (we are not using DER encoding)
- add remoteInitRandomPubKey as return value to respondToHandshake
- add ImportPublicKey with error return to read both EC golang.elliptic style 65 byte encoding and 64 byte one
- add ExportPublicKey falling back to go-ethereum/crypto.FromECDSAPub() chopping off the first byte
- add Import - Export tests
- all tests pass
…ince this is directly copied in the auth message
- add const length params for handshake messages
- add length check to fail early
- add debug logs to help interop testing (!ABSOLUTELY SHOULD BE DELETED LATER)
- wrap connection read/writes in error check
- add cryptoReady channel in peer to signal when secure session setup is finished
- wait for cryptoReady or timeout in TestPeersHandshake
- read/write timeout constants moved to messenger
- add writeLoop (temporarily a method on Peer) that feeds on a channel and writes to bufconn
- add outgoing message channel to proto readwriter
- outgoing message channel is a field of Peer and shared between protocols (no need to lock)
- setting write timeout per message is no longer possible!
- read and write loops share error channel. both watched by the dispatch loop in peer
- remove it, its redundant
- remove duplicate code in peer.writeProtoMsg, now falling back to proto.WriteMsg
- remove peer.writeMu, no need for mutex
- no timer set in p.WriteMsg,
- write will be async for the protocol anyway, so no write timeout argument anywhere, only constant set for conn writeDeadline
- implement peer readLoop and writeLoop as internals to Messenger
- cryptoid.Run -> NewSession
- returns a func(net.Conn) MsgChanReadWriter
- MsgChanReadWriter channel read writer interface
- SecureMessenger embeds Messenger
- Peer fields bufconn moved to Messenger
- no more need for short-lived outgoingMsgC
- modify peer.loop to use a MsgChanReadWriter
- take readwriter out of crypto
- cryptoId.NewSession now gets a reader and writer simply and wraps them in a encrypted MsgReadWriter which it returns if handshake is successful
- refactor reader/writers MsgReadWriter and Messenger
- message got NewMsgFromRLP method
- remove package-wide readMsg and writeMsg (they need to be scoped under the encryption scheme)
- writeProtoMsg back to peer
- peer has new field CryptoType
- add errAuthentication and errEncryption to peer Errors
- testPeer has to wait till handshake done (rw is set up) <-peer.cryptoReady
@zelig
Copy link
Contributor Author

zelig commented Jan 26, 2015

This PR and branch discontinued.
see reworked version: #271

@zelig zelig closed this Jan 26, 2015
@zelig zelig removed the in progress label Jan 26, 2015
@gbalint gbalint deleted the p2p.crypto branch May 25, 2018 14:45
ngtuna added a commit to ngtuna/tomochain that referenced this pull request Nov 10, 2018
fix error panic in func RemoveItemFromArray
Zergity added a commit to Zergity/go-ethereum that referenced this pull request Apr 28, 2020
core/vm: implement ethash precompile contract at 0xFE
weiihann pushed a commit to weiihann/go-ethereum that referenced this pull request Nov 30, 2023
activate proof generation on fork  + remove code dups

use go-verkle's post-state API to verify proofs (ethereum#262)

use prague as the verkle activation fork (ethereum#263)

upgrade to latest go-ipa

activate verkle transition in "miner" (ethereum#265)

fix: do not force cancunTime upon verkle activation

workaround: do not use root translation in replay

workaround: deactivate overlay transition for now

fixes from trying to get the devnet to work (ethereum#267)

this line was left out from the previous commit

upgrade to go-verkle with fixed newvalue serialization

fix: ensure point cache isn't nil in copy (ethereum#268)

fix: dependency cycle in tests (ethereum#269)

upgrade to latest go-verkle

fix: write trie preimage data to db (ethereum#274)

fix: zero-root in produced block + sync (ethereum#275)

upgrade go-ipa

fix build

fix typo

include review feedback

add switch to add proofs to blocks (ethereum#278)

add fee recipient to witness (ethereum#279)

touch all fields in withdrawal account header (ethereum#277)
sduchesneau pushed a commit to streamingfast/go-ethereum that referenced this pull request Jan 4, 2024
arbitrum apiBackend: GetEVM handles nil blockContext
luanxu-mxc pushed a commit to MXCzkEVM/mxc-geth that referenced this pull request Sep 2, 2024
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.

None yet

2 participants