1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* This module provides functions for deserializing Simplicity's bit-wise prefix coding. */
/* Decode a length-prefixed Simplicity DAG from 'stream'.
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' the length prefix's value is too large.
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if some node's child isn't a reference to one of the preceding nodes.
* Returns 'SIMPLICITY_ERR_FAIL_CODE' if the encoding of a fail expression is encountered
* (all fail subexpressions ought to have been pruned prior to deserialization).
* Returns 'SIMPLICITY_ERR_STOP_CODE' if the encoding of a stop tag is encountered.
* Returns 'SIMPLICITY_ERR_HIDDEN' if there are illegal HIDDEN children in the DAG.
* Returns 'SIMPLICITY_ERR_HIDDEN_ROOT' if the root of the DAG is a HIDDEN node.
* Returns 'SIMPLICITY_ERR_BITSTRING_EOF' if not enough bits are available in the 'stream'.
* Returns 'SIMPLICITY_ERR_MALLOC' if malloc fails.
* In the above error cases, '*dag' is set to NULL.
* If successful, returns a positive value equal to the length of an allocated array of (*dag).
*
* Precondition: NULL != dag
* NULL != stream
*
* Postcondition: if the return value of the function is positive
* then (dag_node (*dag)[return_value] and '*dag' is a well-formed dag without witness data);
* '*census' contains a tally of the different tags that occur in 'dag' when the return value
* of the function is positive and when NULL != census;
* NULL == *dag when the return value is negative.
*/
int32_t ;
/* Decode a string of up to 2^31 - 1 bits from 'stream'.
* This is the format in which the data for 'WITNESS' nodes are encoded.
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if the encoded string of bits exceeds this decoder's limits.
* Returns 'SIMPLICITY_ERR_BITSTRING_EOF' if not enough bits are available in the 'stream'.
* If successful, '*witness' is set to the decoded bitstring,
* and 'SIMPLICITY_NO_ERR' is returned.
*
* If an error is returned '*witness' might be modified.
*
* Precondition: NULL != witness;
* NULL != stream;
*/
simplicity_err ;