tuweni / org.apache.tuweni.rlpx / RLPxConnectionFactory

RLPxConnectionFactory

class RLPxConnectionFactory (source)

Factory creating RLPxConnection, either from initiating a handshake or responding to a handshake request.

Constructors

<init>

RLPxConnectionFactory()

Factory creating RLPxConnection, either from initiating a handshake or responding to a handshake request.

Functions

createConnection

static fun createConnection(initiator: Boolean, initiatorMessage: Bytes, responderMessage: Bytes, ourEphemeralPrivateKey: SecretKey, peerEphemeralPublicKey: PublicKey, initiatorNonce: Bytes32, responderNonce: Bytes32, ourPublicKey: PublicKey, peerPublicKey: PublicKey): RLPxConnection

Creates a RLPxConnection based off the complete handshake exchange.

createHandshake

static fun createHandshake(keyPair: KeyPair, remotePublicKey: PublicKey, initAndResponse: Function<Bytes, AsyncResult<Bytes>>): AsyncResult<RLPxConnection>

Creates a complete interaction to run a handshake with a remote peer.

generateRandomBytes32

static fun generateRandomBytes32(): Bytes32

Generates a new random 32 byte array.

init

static fun init(keyPair: KeyPair, remotePublicKey: PublicKey, ephemeralKeyPair: KeyPair, initiatorNonce: Bytes32): Bytes

Creates a handshake initiation message using ephemeral keys and a random nonce.

messageSize

static fun messageSize(msgBytes: Bytes): Int

Identify the size of a handshake message based on elements of the common MAC.

readResponse

static fun readResponse(response: Bytes, privateKey: SecretKey): HandshakeMessage

Decrypts the handshake response using our private key.

respondToHandshake

static fun respondToHandshake(initiatorMessageBytes: Bytes, keyPair: KeyPair, responseHandler: Consumer<Bytes>): RLPxConnection

Creates a RLPxConnection in response to a handshake initiation message.