DhtItems

object DhtItems

Free functions mirroring the file-scope helpers in src/kademlia/item.cpp: item_target_id, sign_mutable_item, verify_mutable_item.

Functions

Link copied to clipboard
fun immutableTargetId(bencodedValue: ByteArray): Sha1Hash

Target hash for an immutable item, from sha1_hash item_target_id(span<char const> v) in item.cpp. The argument is the already bencoded value; the target is simply its SHA-1.

Link copied to clipboard
fun mutableTargetId(publicKey: ByteArray, salt: ByteArray = EMPTY): Sha1Hash

Target hash for a mutable item, from sha1_hash item_target_id(span<char const> salt, public_key const& pk) in item.cpp: sha1(public_key || salt) (salt omitted when empty).

Link copied to clipboard
fun signMutableItem(bencodedValue: ByteArray, salt: ByteArray, seq: Long, publicKey: ByteArray, secretKey: ByteArray): ByteArray

Produce an ed25519 signature over the canonical BEP-44 buffer. This is the port of signature sign_mutable_item(...). bencodedValue must be valid bencoding.

Link copied to clipboard
fun verifyMutableItem(bencodedValue: ByteArray, salt: ByteArray, seq: Long, publicKey: ByteArray, signature: ByteArray): Boolean

Verify an ed25519 signature over the canonical BEP-44 buffer. This is the port of bool verify_mutable_item(...).