Documentation
¶
Overview ¶
Package bit256 provides a 256-bit Kademlia key implementation.
Index ¶
Constants ¶
const KeyLen = 32
KeyLen is the length of a 256-bit key in bytes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is a 256-bit Kademlia key.
func NewKeyFromArray ¶
NewKeyFromArray creates a Key from a 32-byte array without intermediate copying. This is more efficient than NewKey when the caller already has a [32]byte array.
func (Key) CommonPrefixLength ¶
CommonPrefixLength returns the number of leading bits the key shares with another key of the same type.
func (Key) Compare ¶
Compare compares the numeric value of the key with another key of the same type.
func (Key) HexString ¶
HexString returns a string containing the hexadecimal representation of the key.
func (Key) MarshalBinary ¶
MarshalBinary marshals the key into a byte slice. The bytes may be passed to NewKey to construct a new key with the same value.