mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
6d503ea4f8 Rename elements/jets.c c68063f9ef Add testcases that are an even multiple of 1000 milliWU 92887000e6 Add minCost parameter 82d6260ed8 Remove intermedite primitive directory 09b4eee340 Make raw environment struct tags elements specific a93cd359df Make environment struct tags elements specific 26de216e24 Make primitive.h functions indirect 35d188a247 rename elementsJets.* to jets.* 7fd6dbe2ca simplicity_computeCmr -> simplicity_elements_computeCmr git-subtree-dir: src/simplicity git-subtree-split: 6d503ea4f8859ec63ad22a22c0ccef067b1a0b5d
41 lines
2 KiB
C
41 lines
2 KiB
C
/* Implements the required callbacks for the Elements Simplicity application.
|
|
*/
|
|
#ifndef SIMPLICITY_ELEMENTS_PRIMITIVE_H
|
|
#define SIMPLICITY_ELEMENTS_PRIMITIVE_H
|
|
|
|
#include "../bitstream.h"
|
|
#include "../typeInference.h"
|
|
|
|
/* Allocate a fresh set of unification variables bound to at least all the types necessary
|
|
* for all the jets that can be created by 'decodeJet', and also the type 'TWO^256',
|
|
* and also allocate space for 'extra_var_len' many unification variables.
|
|
* Return the number of non-trivial bindings created.
|
|
*
|
|
* However, if malloc fails, then return 0.
|
|
*
|
|
* Precondition: NULL != bound_var;
|
|
* NULL != word256_ix;
|
|
* NULL != extra_var_start;
|
|
* extra_var_len <= 6*DAG_LEN_MAX;
|
|
*
|
|
* Postcondition: Either '*bound_var == NULL' and the function returns 0
|
|
* or 'unification_var (*bound_var)[*extra_var_start + extra_var_len]' is an array of unification variables
|
|
* such that for any 'jet : A |- B' there is some 'i < *extra_var_start' and 'j < *extra_var_start' such that
|
|
* '(*bound_var)[i]' is bound to 'A' and '(*bound_var)[j]' is bound to 'B'
|
|
* and, '*word256_ix < *extra_var_start' and '(*bound_var)[*word256_ix]' is bound the type 'TWO^256'
|
|
*/
|
|
size_t simplicity_elements_mallocBoundVars(unification_var** bound_var, size_t* word256_ix, size_t* extra_var_start, size_t extra_var_len);
|
|
|
|
/* Decode an Elements specific jet from 'stream' into 'node'.
|
|
* All jets begin with a bit prefix of '1' which needs to have already been consumed from the 'stream'.
|
|
* Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if the stream's prefix doesn't match any valid code for a jet.
|
|
* Returns 'SIMPLICITY_ERR_BITSTRING_EOF' if not enough bits are available in the 'stream'.
|
|
* In the above error cases, 'dag' may be modified.
|
|
* Returns 'SIMPLICITY_NO_ERROR' if successful.
|
|
*
|
|
* Precondition: NULL != node
|
|
* NULL != stream
|
|
*/
|
|
simplicity_err simplicity_elements_decodeJet(dag_node* node, bitstream* stream);
|
|
|
|
#endif
|