Class: BIP150

net.BIP150

new BIP150(bip151, host, outbound, db, key)

Represents a BIP150 input/output stream.

Parameters:
Name Type Description
bip151 BIP151
host String
outbound Boolean
db AuthDB
key Buffer

Identity key.

Properties:
Name Type Description
bip151 BIP151
input BIP151Stream
output BIP151Stream
hostname String
outbound Boolean
db AuthDB
privateKey Buffer
publicKey Buffer
peerIdentity Buffer
challengeReceived Boolean
replyReceived Boolean
proposeReceived Boolean
challengeSent Boolean
auth Boolean
completed Boolean
Source:

Methods

(private) _init()

Initialize BIP150.

Source:

(private) _wait(timeout, resolve, reject)

Wait for handshake to complete.

Parameters:
Name Type Description
timeout Number
resolve function
reject function
Source:

challenge(hash) → {Buffer}

Handle a received challenge hash. Returns an authreply signature.

Parameters:
Name Type Description
hash Buffer
Source:
Throws:

on auth failure

Returns:
Type
Buffer

(private) cleanup() → {Job}

Cleanup wait job.

Source:
Returns:
Type
Job

destroy()

Destroy the BIP150 stream and any current running wait job.

Source:

findAuthorized(hash) → {Buffer|null}

Find an authorized peer in the Auth DB based on a proposal hash. Note that the hash to find is specific to the state of BIP151. This results in an O(n) search.

Parameters:
Name Type Description
hash Buffer
Source:
Returns:
Type
Buffer | null

getAddress() → {Base58String}

Serialize the peer's identity key as a BIP150 "address".

Source:
Returns:
Type
Base58String

hash(sid, ch, key) → {Buffer}

Create a hash using the session ID.

Parameters:
Name Type Description
sid Buffer
ch String
key Buffer
Source:
Returns:
Type
Buffer

isAuthed() → {Boolean}

Test whether the state should be considered authed. This differs for inbound vs. outbound.

Source:
Returns:
Type
Boolean

propose(hash) → {Buffer}

Handle a received propose hash. Returns an authchallenge hash.

Parameters:
Name Type Description
hash Buffer
Source:
Returns:
Type
Buffer

(private) reject(err)

Reject the current wait job.

Parameters:
Name Type Description
err Error
Source:

rekey(sid, key, req, res) → {Buffer}

Derive new cipher keys based on BIP150 data. This differs from the regular key derivation of BIP151.

Parameters:
Name Type Description
sid Buffer

Sesson ID

key Buffer

k1 or k2

req Buffer

Requesting Identity Key

res Buffer

Response Identity Key

Source:
Returns:
Type
Buffer

rekeyInput()

Rekey the BIP151 input stream using BIP150-style derivation.

Source:

rekeyOutput()

Rekey the BIP151 output stream using BIP150-style derivation.

Source:

reply(data) → {Buffer}

Handle a received reply signature. Returns an authpropose hash.

Parameters:
Name Type Description
data Buffer
Source:
Throws:

on auth failure

Returns:
Type
Buffer

(private) resolve(result)

Resolve the current wait job.

Parameters:
Name Type Description
result Object
Source:

toChallenge() → {AuthChallengePacket}

Create initial authchallenge hash for the peer. The peer's identity key must be known.

Source:
Returns:
Type
AuthChallengePacket

wait(timeout) → {Promise}

Wait for handshake to complete.

Parameters:
Name Type Description
timeout Number
Source:
Returns:
Type
Promise

(static) address() → {Base58String}

Serialize an identity key as a BIP150 "address".

Source:
Returns:
Type
Base58String