bytes = *OCTET

; Packet codes 0 - 127 are reserved for Waku protocol
packet-code      = 0 / 1 / 2 / 3 / [ x4-127 ]

packet-format    = "[" packet-code packet-format "]"

; packet-format needs to be paired with its corresponding packet-format
packet           = "[" required-packet / [ optional-packet ] "]"

required-packet  = 0 status / 1 messages / 2 pow-requirement / 3 bloom-filter

optional-packet  = 126 p2p-request / 127 p2p-message

packet-format    = "[" packet-code packet-format "]"

status           = "[" version pow-requirement [ bloom-filter ] [ light-node ] "]"

; version is "an integer (as specified in RLP)"
version          = DIGIT

messages         = *whisper-envelope

; pow is "a single floating point value of PoW. This value is the IEEE 754 binary representation of 64-bit floating point number. Values of qNAN, sNAN, INF and -INF are not allowed. Negative values are also not allowed."
pow-requirement  = pow

; bloom filter is "a byte array"
bloom-filter     = bytes

light-node       = BIT

p2p-request      = whisper-envelope

p2p-message      = whisper-envelope

whisper-envelope = "[" expiry ttl topic data nonce "]"

; 4 bytes (UNIX time in seconds)
expiry           = bytes

; 4 bytes (time-to-live in seconds)
ttl              = bytes

; 4 bytes of arbitrary data
topic            = bytes

; byte array of arbitrary size (contains encrypted message)
data             = bytes

; 8 bytes of arbitrary data (used for PoW calculation)
nonce            = bytes
