From 7b7d5729847575f2f72ad89d7a01525400534b21 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 20 Jun 2016 21:48:24 -0700 Subject: [PATCH] lndc: fix bug in pubkeyhash based authentication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call to copy used incorrect slicing on `greetingMsg` which caused the remote node to always reject the auth attempt as all zeroes (0000..) was being sent as the local node’s guess to the remote node’s public key identity. --- lndc/conn.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lndc/conn.go b/lndc/conn.go index 8d0147bb..2128a758 100644 --- a/lndc/conn.go +++ b/lndc/conn.go @@ -92,7 +92,7 @@ func (c *LNDConn) Dial( } ourEphemeralPub := ourEphemeralPriv.PubKey() - // Sned 1. Send my ephemeral pubkey. Can add version bits. + // Send 1. Send my ephemeral pubkey. Can add version bits. if _, err = writeClear(c.Conn, ourEphemeralPub.SerializeCompressed()); err != nil { return err } @@ -209,7 +209,7 @@ func (c *LNDConn) authPKH( // Send 53 bytes: our pubkey, and the remote's pubkey hash. var greetingMsg [53]byte copy(greetingMsg[:33], myId.PubKey().SerializeCompressed()) - copy(greetingMsg[:33], theirPKH) + copy(greetingMsg[33:], theirPKH) if _, err := c.Conn.Write(greetingMsg[:]); err != nil { return err }