devp2p icon indicating copy to clipboard operation
devp2p copied to clipboard

sig missing from handshake's auth spec

Open ryandotsmith opened this issue 3 years ago • 3 comments

auth = auth-size || enc-auth-body
auth-size = size of enc-auth-body, encoded as a big-endian 16-bit integer
auth-vsn = 4
auth-body = [sig, initiator-pubk, initiator-nonce, auth-vsn, ...]
enc-auth-body = ecies.encrypt(recipient-pubk, auth-body || auth-padding, auth-size)
auth-padding = arbitrary data

Looking at various implementations, it seems like sig is:

sig = secp256k1.sign(ephemeral-privkey , shared-secret ^ initiator-nonce)

and shared-secret is:

shared-secret = ecdh.agree(privkey, remote-pubk)

ryandotsmith avatar Nov 15 '22 22:11 ryandotsmith

Also, there might need to be a definition for auth-padding and clarification on auth-size.

Is auth-size = len(auth-body || auth-padding) instead of size of enc-auth-bod

ryandotsmith avatar Nov 15 '22 23:11 ryandotsmith

Ah, I suppose that auth-size can be known prior to ecies encryption using: len(auth-body || auth-padding) + 113. Does that sound correct?

ryandotsmith avatar Nov 15 '22 23:11 ryandotsmith

Ah, I suppose that auth-size can be known prior to ecies encryption using: len(auth-body || auth-padding) + 113. Does that sound correct?

Yes, 113 is the fixed ecies overhead which can be used to pre-calculate the total size.

kdeme avatar Nov 16 '22 15:11 kdeme