perlin-network / noise

A decentralized P2P networking stack written in Go.
https://godoc.org/github.com/perlin-network/noise
MIT License
1.79k stars 211 forks source link

Extend cryptographic keys API, reduce frequency of OnMessageSent being called, improve cache locality of Kademlia routing table. #274

Closed iwasaki-kenta closed 4 years ago

iwasaki-kenta commented 4 years ago

Few security considerations were implemented alongside helper methods for dealing with cryptographic keys. After benchmarking with software written on top of Noise, a switch from using a pre-allocated slice to a linked list was done for representing Kademlia routing tables.

client, node: have OnMessageSent called less frequently
kademlia/protocol, kademlia/table: switch from using a slice to a linked list for representing the routing table to make id updates more efficient, and add Last() to get the last entry of a bucket near a target public key
client, node, keys: add LoadKeysFromHex to load a private key from hex, add Signature type to represent cryptographic signatures, and add UnmarshalSignature which uses unsafe hackery to convert a byte slice into a signature
client: add missing check for length of overlay handshake