mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-03-06 05:28:17 +01:00
akwizgran created page: BSP
12
BSP.markdown
12
BSP.markdown
@@ -2,7 +2,7 @@ BSP is an application layer data synchronisation protocol for delay-tolerant net
|
||||
|
||||
BSP synchronises data between two devices referred to as the local and remote peers. The data to be synchronised consists of messages posted to channels. A message is simply a sequence of bytes, and a channel is simply a set of messages.
|
||||
|
||||
Each channel on the local peer belongs to an application. The application decides which messages stored on the local peer should be synchronised to the remote peer, and which messages synchronised from the remote peer should be stored on the local peer.
|
||||
Each channel on the local peer belongs to an application. The application decides which messages stored on the local peer should be synchronised to the remote peer (the sharing policy), and which messages synchronised from the remote peer should be stored on the local peer (the storage policy).
|
||||
|
||||
### Crypto primitives
|
||||
|
||||
@@ -10,14 +10,12 @@ BSP uses a cryptographic hash function, H(m), with an output length of hash_len
|
||||
|
||||
### Channel identifiers
|
||||
|
||||
Each channel has a unique identifier hash_len bytes long. This identifier is supplied by the application and is not interpreted by BSP. To prevent collisions, the identifier must either be randomly generated, or must be the cryptographic hash of some application data structure describing the channel. If a hash is used, a randomly generated application identifier hash_len bytes long must be prepended to the application data structure before hashing. This prevents collisions between applications with similar data structures.
|
||||
Each channel has a unique identifier hash_len bytes long. This identifier is supplied by the application and is not interpreted by BSP. To prevent collisions, the identifier must either be randomly generated, or must be the cryptographic hash of an application data structure describing the channel. If a hash is used, a randomly generated application identifier hash_len bytes long must be prepended to the application data structure before hashing to prevent collisions between applications with similar data structures.
|
||||
|
||||
### Message format
|
||||
|
||||
Each message consists of one or more blocks. Each block is block_len bytes long, except the last, which may be shorter. The blocks form the leaves of a binary hash tree. Each internal node of the tree consists of the concatenated hashes of its children, and the root hash of the tree uniquely identifies the message.
|
||||
Each message consists of one or more blocks, each block_len bytes long, except the last block, which may be shorter. The blocks form the leaves of a binary hash tree. Each parent node consists of the concatenated hashes of its children.
|
||||
|
||||
A message header is prepended to each node of the tree before hashing. The message header consists of the channel identifier, a timestamp indicating when the message was posted, the depth of the tree, and the message type.
|
||||
The message's unique identifier is calculated by hashing a message header followed by the root node of the hash tree. The message header consists of the channel identifier, a timestamp, the message type, and the depth of the tree.
|
||||
|
||||
The timestamp is a 64-bit big-endian integer representing seconds since the Unix epoch. The depth of the tree is an 8-bit integer. The message type is a single byte that is not interpreted by BSP; the application may use it to respond appropriately to partially synchronised messages. The total length of the message header is hash_len + 10 bytes.
|
||||
|
||||
Prepending the message header to each node before hashing ensures that all blocks with a given message identifer have consistent message headers; this simplifies the validation of blocks received from the remote peer.
|
||||
The timestamp is a 64-bit big-endian integer representing the time at which the message was created, measured in seconds since the Unix epoch. The message type is a single byte that is supplied by the application and not interpreted by BSP. The depth of the tree is an 8-bit integer. The total length of the message header is hash_len + 10 bytes.
|
||||
|
||||
Reference in New Issue
Block a user