def decode_authentication(ciphertext)
      raise RLPxSessionError, 'must not be initiator' if initiator?
      raise ArgumentError, 'invalid ciphertext length' unless ciphertext.size >= 307

      result = nil
      begin
        result = decode_auth_plain ciphertext
      rescue AuthenticationError
        result = decode_auth_eip8 ciphertext
        @got_eip8_auth = true
      end
      size, sig, initiator_pubkey, nonce, version = result

      @auth_init = ciphertext[0, size]

      token = @ecc.get_ecdh_key initiator_pubkey
      @remote_ephemeral_pubkey = Crypto.ecdsa_recover(Utils.sxor(token, nonce), sig)
      raise InvalidKeyError, 'invalid remote ephemeral pubkey' unless Crypto::ECCx.valid_key?(@remote_ephemeral_pubkey)

      @initiator_nonce = nonce
      @remote_pubkey = initiator_pubkey
      @remote_version = version

      ciphertext[size..-1]
    end
def decode_authentication(ciphertext)
      raise RLPxSessionError, 'must not be initiator' if initiator?
      raise ArgumentError, 'invalid ciphertext length' unless ciphertext.size >= 307

      result = nil
      begin
        result = decode_auth_plain ciphertext
      rescue AuthenticationError
        result = decode_auth_eip8 ciphertext
        @got_eip8_auth = true
      end
      size, sig, initiator_pubkey, nonce, version = result

      @auth_init = ciphertext[0, size]

      token = @ecc.get_ecdh_key initiator_pubkey
      @remote_ephemeral_pubkey = Crypto.ecdsa_recover(Utils.sxor(token, nonce), sig)
      raise InvalidKeyError, 'invalid remote ephemeral pubkey' unless Crypto::ECCx.valid_key?(@remote_ephemeral_pubkey)

      @initiator_nonce = nonce
      @remote_pubkey = initiator_pubkey
      @remote_version = version

      ciphertext[size..-1]
    end
3. optionally, remote decrypts and verifies auth (checks that recovery of
   signature == H(ephemeral-pubk))
 4. remote generates authAck from remote-ephemeral-pubk and nonce (authAck
   = authRecipient handshake)

 optional: remote derives secrets and preemptively sends
 protocol-handshake (steps 9,11,8,10)