NegentropyEncoder class

Negentropy Protocol V1 codec, as specified in the NIP-77 appendix.

See https://github.com/hoytech/negentropy/blob/master/docs/negentropy-protocol-v1.md

Constructors

NegentropyEncoder()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

bytesToHex(List<int> bytes) → String
Converts bytes to hex string
calculateFingerprint(List<Uint8List> ids) → Uint8List
Calculates the fingerprint of a range: the first 16 bytes of SHA256(sum of the IDs mod 2^256, little-endian || varint(count)).
createInitialMessage(List<NegentropyItem> items, [int itemIdSize = idSize]) → Uint8List
Creates the initial message an initiator sends in NEG-OPEN.
decodeBound(Uint8List data, [int offset = 0, int lastTimestamp = 0]) → (int, Uint8List, int)
Decodes a bound. lastTimestamp is the timestamp of the previously decoded bound in the same message (0 at the start of every message).
decodeVarint(Uint8List data, [int offset = 0]) → (int, int)
Decodes a varint from bytes, returns (value, bytesConsumed)
encodeBound(int timestamp, Uint8List idPrefix, {int lastTimestamp = 0}) → Uint8List
Encodes a bound. Timestamps are delta encoded against lastTimestamp, which is the timestamp of the previously encoded bound in the same message (0 at the start of every message).
encodeVarint(int value) → Uint8List
Encodes an integer as a varint (base-128, most significant digit first)
hexToBytes(String hex) → Uint8List
Parses a hex string to bytes
reconcile(Uint8List message, List<NegentropyItem> items) → (Uint8List, List<String>, List<String>)
Reconciles a message received from the other side as the initiator.
respond(Uint8List message, List<NegentropyItem> items) → Uint8List
Reconciles a message received from an initiator, as the responding side.

Constants

fingerprintSize → const int
Size of fingerprint in bytes
idSize → const int
Size of event ID in bytes (32 bytes = 64 hex chars)
infiniteTimestamp → const int
Reserved "infinity" timestamp. The spec reserves 2**64 - 1, which does not survive dart2js; this sentinel is the largest exactly representable integer on both native and web, and never touches the wire (infinity is always encoded as 0).
modeFingerprint → const int
modeIdList → const int
modeSkip → const int
Mode constants
protocolVersion → const int
Protocol version byte (version 1)