0150 - Deferred - Standards - March 23, 2016 (10 years, 3 months ago)
23
2016
BIP: 150
Layer: Peer Services
Title: Peer Authentication
Author: Jonas Schnelli <[email protected]>
Comments-Summary: Discouraged for implementation (one person)
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP 150
Status: Deferred
Type: Standards Track
Created: 2016-03-23
License: PD
This BIP describes a way for peers to authenticate to other peers to guarantee node ownership and/or allow peers to access additional or limited node services, without the possibility of fingerprinting.
We assume peer operators want to limit the access of different node services or increase datastream priorities to a selective subset of peers. Also we assume that peers want to connect to specific peers to broadcast or filter transactions (or similar actions that reveal sensitive information) and therefore operators want to authenticate the remote peer and ensure that they have not connected to a MITM (man-in-the-middle) attacker.
Benefits of peer authentication:
A simple authentication scheme based on elliptic cryptography will allow peers to identify each other and selectively allow access to restricted services or reject the connection if the peer identity cannot be verified.
The authentication scheme proposed in this BIP uses ECDSA, secrets will never be transmitted .
Authentication initialization must only happen if encrypted channels have been established (according to BIP 151 [1]).
The encryption-session-ID is available once channels are encrypted (according to BIP 151 [1]).
The identity-public-keys used for the authentication must be pre-shared over a different channel (mail/PGP, physical paper exchange, etc.). This BIP does not cover a "trust on first use" (TOFU) concept.
The authentication state must be kept until the encryption/connection terminates.
Only one authentication process is allowed per connection. Re-authentication require re-establishing the connection.
Each peer that supports p2p authentication must provide two user-editable "databases".
Each peer can configure multiple identity-keys (ECC, 32 bytes). Peers should make sure that each network interface (IPv4, IPv6, tor) has its own identity-key (otherwise it would be possible to link a tor address to a IPvX address). The identity-public-key(s) can be shared over a different channel with other node-operators (or non-validating clients) to grant authorized access.
Authentication based on this BIP will require both sides to authenticate. Signatures/public-keys will only be revealed if the remote peer can prove that they already know the remote identity-public-key.
AUTHCHALLENGE
(hash)
AUTHREPLY
(signature)
AUTHPROPOSE
(hash)
AUTHCHALLENGE
(hash)
AUTHREPLY
(signature)
For privacy reasons, dropping the connection or aborting during the authentication process must not be allowed.
AUTHCHALLENGE
message
A peer can send an authentication challenge to see if the responding
peer can produce a valid signature with the expected responding peer's
identity-public-key by sending an
AUTHCHALLENGE
-message to
the remote peer.
The responding peer needs to check if the hash matches the hash calculated with his own local identity-public-key. Fingerprinting the requesting peer is not possible.
| Field Size | Description | Data type | Comments |
|---|---|---|---|
|
32bytes |
challenge-hash |
hash |
|
challenge_type
is a single character.
i
if
the
AUTHCHALLENGE
-message is the first, requesting
challenge or
r
if it's the second, remote peers challenge
message.
AUTHREPLY
message
A peer must reply an
AUTHCHALLENGE
-message with an
AUTHREPLY
-message.
| Field Size | Description | Data type | Comments |
|---|---|---|---|
|
64bytes |
signature |
normalized comp.-signature |
A signature of the encryption-session-ID done with the identity-key |
If the challenge-hash from the
AUTHCHALLENGE
-message did
not match the local authentication public-key, the signature must
contain 64 bytes of zeros.
The requesting peer can check the responding peer's identity by checking the validity of the sent signature against with the pre-shared remote peers identity-public-key.
If the signature was invalid, the requesting peer must still proceed
with the authentication by sending an
AUTHPROPOSE
-message
with 32 random bytes.
AUTHPROPOSE
message
A peer can propose authentication of the channel by sending an
AUTHPROPOSE
-message to the remote peer.
If the signature sent in
AUTHREPLY
was invalid, the peer
must still send an
AUTHPROPOSE
-message containing 32 random
bytes.
The
AUTHPROPOSE
message must be answered with an
AUTHCHALLENGE
-message - even if the proposed
requesting-peers identity-public-key has not been found in the
authorized-peers database. In case of no match, the responding
AUTHCHALLENGE
-message must contains 32 bytes of zeros.
| Field Size | Description | Data type | Comments |
|---|---|---|---|
|
32bytes |
auth-propose-hash |
hash |
|
After the second
AUTHREPLY
message (requesting peer's
signature -> responding peer), both clients must re-key the symmetric
encryption according to BIP 151 while using
a slightly different
re-key key derivation hash
.
Both peers re-key with
hash(encryption-session-ID || old_symmetric_cipher_key || requesting-peer-identity-public-key || responding-peer-identity-public-key)
The peers should display/log the identity-public-key as an
identity-address to the users, which is a base58-check encoded
ripemd160(sha256) hash. The purpose of this is for better visual
comparison (logs, accept-dialogs). The base58check identity byte is
0x0F
followed by an identity-address version number
(=
0xFF01
).
An identity address would look like
TfG4ScDgysrSpodWD4Re5UtXmcLbY5CiUHA
and can be interpreted
as a remote peer's fingerprint.
This proposal is backward compatible. Non-supporting peers will
ignore the new
AUTH*
messages.
Before authentication (once during peer setup or upgrade)
Authentication
AUTHCHALLENGE
message
AUTHCHALLENGE:
[32 bytes, hash(encryption-session-ID || "i" ||
)]
(encryption-session-ID || "i" || <remote-peers-expected-identity-public-key>)
with its local identity-public-key
AUTHREPLY
message containing 64bytes of zeros.
AUTHREPLY
message
AUTHREPLY:
[64 bytes normalized compact ECDSA signature (H)] (sig of the encryption-session-ID done with the identity-key)
remote-peers-identity-public-key
AUTHREPLY
message containing 32 random bytes
AUTHPROPOSE
message
AUTHPROPOSE:
[32 bytes, hash(encryption-session-ID || "p" ||
)]
AUTHCHALLENGE
message containing 32 bytes of zeros.
AUTHCHALLENGE
message with the hashed client
public-key
AUTHCHALLENGE:
[32 bytes, hash(encryption-session-ID || "r" ||
)]
AUTHREPLY
message containing
64 bytes of zeros if server failed to authenticate
AUTHREPLY
message
AUTHREPLY:
[64 bytes normalized compact ECDSA signature (H)] (sig of the encryption-session-ID done with the identity-key)
The protocol may be slow if a peer has a large authorized-peers database due to the requirement of iterating and hashing over all available authorized peer identity-public-keys.
This work is placed in the public domain.