Skip to content

Instantly share code, notes, and snippets.

@matiu
Created April 24, 2014 00:46
Show Gist options
  • Save matiu/11237601 to your computer and use it in GitHub Desktop.
Save matiu/11237601 to your computer and use it in GitHub Desktop.
Copay peer handshake
Alice Bob
=================================================
.generates Extended PrivKey, PubKey
CopayerId=pubkey
PeerId=hash(CopayerId)
PeerID is provided to the PeerJS/WebRTC
P2P facilitator server
.Connects server with PeerId.
.Sends CopayerId to Alice
using an off channel.
.generates Extended
PrivKey, PubKey
CopayerId=pubkey
PeerId=hash(CopayerId)
.Connects server with PeerId.
BobPeerId = hash(CopayerId)
.Asks for a Bob's p2p channel
to the server using BobPeerId
.receives connection request
.sign a "HELLO"
using HMAC / Bob's
pubkey. See its
pubkey ring.
.check sig of HELLO.
start signing messages using ECDSA
and checking Alice message using her
public key.
Only the HELLO message is signed/verified using HMAC.
Then all messages are signed using ECDSA.
This attemps to remove the need of trust from
the PeerJS server.
@matiu
Copy link
Author

matiu commented Apr 24, 2014

  • The initial exchange using HMAC in the HELLO message is only to allow Bob to send an authenticated message
    to Alice, so it is only the pubkey (not extended).
  • Once both parties are authenticated, the extended pub keys are shared using PubKeyRing.

Encryption should be easy to implement once we have EC encryption support on bitcore (bitpay/bitcore#287), and using the same pubkeys for signing and encrypting data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment