Optimised announces to 151 bytes

This commit is contained in:
Mark Qvist 2021-05-20 16:56:08 +02:00
parent 9c995b33dd
commit db527b6759
4 changed files with 10 additions and 12 deletions

View File

@ -156,10 +156,7 @@ class Destination:
signature = self.identity.sign(signed_data)
# TODO: Check if this could be optimised by only
# carrying the hash in the destination field, not
# also redundantly inside the signed blob as here
announce_data = self.hash+self.identity.get_public_key()+random_hash+signature
announce_data = self.identity.get_public_key()+random_hash+signature
if app_data != None:
announce_data += app_data

View File

@ -149,16 +149,16 @@ class Identity:
if packet.packet_type == RNS.Packet.ANNOUNCE:
RNS.log("Validating announce from "+RNS.prettyhexrep(packet.destination_hash), RNS.LOG_DEBUG)
destination_hash = packet.destination_hash
public_key = packet.data[10:Identity.KEYSIZE//8+10]
random_hash = packet.data[Identity.KEYSIZE//8+10:Identity.KEYSIZE//8+20]
signature = packet.data[Identity.KEYSIZE//8+20:Identity.KEYSIZE//8+20+Identity.KEYSIZE//8]
public_key = packet.data[:Identity.KEYSIZE//8]
random_hash = packet.data[Identity.KEYSIZE//8:Identity.KEYSIZE//8+10]
signature = packet.data[Identity.KEYSIZE//8+10:Identity.KEYSIZE//8+10+Identity.KEYSIZE//8]
app_data = b""
if len(packet.data) > Identity.KEYSIZE//8+20+Identity.KEYSIZE//8:
app_data = packet.data[Identity.KEYSIZE//8+20+Identity.KEYSIZE//8:]
if len(packet.data) > Identity.KEYSIZE//8+10+Identity.KEYSIZE//8:
app_data = packet.data[Identity.KEYSIZE//8+10+Identity.KEYSIZE//8:]
signed_data = destination_hash+public_key+random_hash+app_data
if not len(packet.data) > Identity.KEYSIZE//8+20+Identity.KEYSIZE//8:
if not len(packet.data) > Identity.KEYSIZE//8+10+Identity.KEYSIZE//8:
app_data = None
announced_identity = Identity(create_keys=False)

View File

@ -186,6 +186,7 @@ class Packet:
self.packed = True
self.update_hash()
def unpack(self):
self.flags = self.raw[0]
self.hops = self.raw[1]

View File

@ -672,8 +672,8 @@ Binary Packet Format
wire size including all fields.
- Path Request : 33 bytes
- Announce : 323 bytes
- Link Request : 141 bytes
- Announce : 151 bytes
- Link Request : 182 bytes
- Link Proof : 205 bytes
- Link RTT packet : 86 bytes
- Link keepalive : 14 bytes