Browse Source

Merge pull request #876 from tendermint/p2p-extract-key-lex-check-to-variable-for-clarity

p2p: use bytes.Equal for key comparison
pull/884/head
Ethan Buchman 7 years ago
committed by GitHub
parent
commit
c695c53259
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      p2p/secret_connection.go

+ 5
- 1
p2p/secret_connection.go View File

@ -67,8 +67,12 @@ func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey crypto.PrivKeyEd25
// Sort by lexical order.
loEphPub, hiEphPub := sort32(locEphPub, remEphPub)
// Check if the local ephemeral public key
// was the least, lexicographically sorted.
locIsLeast := bytes.Equal(locEphPub[:], loEphPub[:])
// Generate nonces to use for secretbox.
recvNonce, sendNonce := genNonces(loEphPub, hiEphPub, locEphPub == loEphPub)
recvNonce, sendNonce := genNonces(loEphPub, hiEphPub, locIsLeast)
// Generate common challenge to sign.
challenge := genChallenge(loEphPub, hiEphPub)


Loading…
Cancel
Save