MutableItem

A mutable BEP-44 item: the signed variant of dht::item. It holds the ed25519 public key, a salt (possibly empty), a 64-bit sequence number and a signature over DhtItems.signMutableItem's canonical buffer.

target is SHA-1(publicKey + salt), so the same key + salt always map to the same slot and a higher seq supersedes a lower one (the DHT keeps the highest sequence number it can verify). Construct an unsigned shell with of, then call sign; or rebuild a received item with received.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val bencodedValue: ByteArray

The exact bencoding of value: the bytes that travel as a["v"].

Link copied to clipboard
open override val isMutable: Boolean

True for a BEP-44 mutable (signed) item.

Link copied to clipboard

True once a non-null signature is present.

Link copied to clipboard

ed25519 public key, 32 bytes, from pk().

Link copied to clipboard

Salt, possibly empty, from salt().

Link copied to clipboard
var seq: Long

Sequence number, from seq(). Defaults to 0 like libtorrent's m_seq{0}.

Link copied to clipboard

ed25519 signature, 64 bytes, or null until signed. From sig().

Link copied to clipboard
open override val target: Sha1Hash

The DHT key this item is stored under.

Link copied to clipboard
open override val value: Entry

The item's value as an editable Entry.

Functions

Link copied to clipboard
fun sign(secretKey: ByteArray, pubKey: ByteArray = publicKey): ByteArray

Sign this item with the given ed25519 key pair, storing the resulting signature. This mirrors item::assign(entry v, salt, seq, pk, sk), which signs the bencoded value and remembers m_sig.

Link copied to clipboard

The exact bytes that are (or would be) signed: the BEP-44 canonical buffer for this item's value, seq and salt. Exposed so callers can audit or re-verify.

Link copied to clipboard

Verify this item's stored signature against its public key. This is the port of the verify_mutable_item check in item::assign(bdecode_node, salt, seq, pk, sig). Returns false if unsigned.