Skip to content

6. Datascript protocol overview

Nanocat edited this page Sep 14, 2017 · 15 revisions

orwelldb protocol

All protocol based on network bitcoin types, like var_int, var_str and other. You can find this types and parser/builder for that in my another package: bitPony Datascript is constructed from four levels.

transport level

first byte of transport level - its flag. If flag equal - 0xef - its vector of datascript (vector - var_int(count) + datascript[]), else if flag equal 0xee or something else byte - its just one datascript item.

datascript level

first byte of datascript level its op_flag, that contain type of datascript. In version 0.0.1 supported operation is create (0x19), settings (0x21), write (0x20). After first byte - var_str dataset name, and after that - var_str datascript.

datascript

Datascript can be encrypted and open. Datascript its a script system, stack-based and processed from left to right. It is purposefully not Turing-complete, with no loops. Look like bitcoin script and support some operations from bitcoin. Full list of operators:

DATA_ENCRYPTIONALGORITHM =  0x52,
DATA_HEXJSONENCRYPTED =  0x53,
DATA_HEXJSON =  0x54,
DATA_HASH =  0x58,

PUSHDATA_DBWRITEPUBLICKEY =  0x55,
PUSHDATA_DBREADPRIVATEKEY =  0x56,

OP_DECRYPT =  0x57,
OP_EQUAL =  0x87,
OP_HASH256 =  0x59,
OP_CHECKDBPRIVILEGES =  0x60,

DATA_* operators mean that next bytes after this operator is var_str with special data. PUSHDATA_* operators mean that need put you special data into stack OP_* its operators

So, datascript look like:

  1. open: 0x54 + jsonhex_bytes
  2. encrypted 0x53 + var_str + 0x56 + (0x1 or 0x2) + 0x57 + 0x59 + 0x58 + char[32] + 0x87

jsonhex level

jsonhex read here

Clone this wiki locally