Skip to content

Commit

Permalink
remove CBOR from docs and rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Mar 9, 2023
1 parent acbca3c commit f427459
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
8 changes: 4 additions & 4 deletions docs/pages/zencode-cookbook-given.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Link file with relative path:
# The *Given* phase: reading and verifying input

The *Given* keyword marks the first phase of Zencode execution, where input is read and processed and first internal variables are set. More precisely:
- Read data from files, passed using the *--data* and *--keys* parameters, formatted in JSON or CBOR (where JSON is the default and CBOR needs to be specified)
- Read data from files, passed using the *--data* and *--keys* parameters, formatted in JSON
- Validate the input, both synctatically and cryptographically.
- State the identity of the script executor.

Expand All @@ -22,7 +22,7 @@ The *Given* keyword marks the first phase of Zencode execution, where input is r


Zencode allows you to load a very broad spectrum of input by:
- Reading input data as ***JSON*** or ***CBOR***
- Reading input data as ***JSON***
- Importing and validating several simple ***data types*** as well as complex data structures
- Reading data coming with different ***encodings***, which are crucial in cryptographic operations. Zencode's default encoding is ***base64*** but many crypto-operation will work with data in ***hex*** and for example *bitcoin* uses ***base58*** encoding - Zenroom can read all of these, and more.

Expand Down Expand Up @@ -149,7 +149,7 @@ Given I am 'Alice'
```

This statement is typically used when:
- Executing cryptographic operations that will need a key or a keyring: the keys are passed to Zenroom (via *-a* and *-k* parameters) as JSON or CBOR files, using a format that includes the owner of the keys. In the next example we'll indeed a *keyring*.
- Executing cryptographic operations that will need a key or a keyring: the keys are passed to Zenroom (via *-a* and *-k* parameters) as JSON files, using a format that includes the owner of the keys. In the next example we'll indeed a *keyring*.
- In scripts where the identity is a condition for the execution of the script.

Note: this statement has a number of alias, so you these you can use the same statement with the syntax:
Expand Down Expand Up @@ -180,7 +180,7 @@ And you will need to pass the identity in a parameter, looking like this:
}
```

The paramater can be passed to Zenroom (via *-a* and *-k* parameters) as JSON or CBOR files.
The paramater can be passed to Zenroom (via *-a* and *-k* parameters) as JSON files.


## *Given I have*: load data from nested JSON file (part 2)
Expand Down
8 changes: 3 additions & 5 deletions docs/pages/zencode-cookbook-when.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,10 @@ An example, from the scenario 'petition':
When I create the petition signature 'nameOfThePetitionIWantToSign'
```

And an exotic version of the statement is the one used to transform the formatting of an object to CBOR (if originally in JSON) or to JSON (if originally in CBOR):
A statement is available also to transform a binary object to a JSON string:

```gherkin
When I create the cbor of 'myJsonObject'
When I create the json of 'myCborObject'
When I create the json of 'myObject'
```

We're sparing you the full list of **schemas** that you can create, but the best place to see a full and updated list is <a href="https://apiroom.net">https://apiroom.net</a>.
Expand All @@ -139,12 +138,11 @@ We're sparing you the full list of **schemas** that you can create, but the best

In the second group we gathered the *When* statements that can create new objects and assign values to them.


The "create" statements can ***generate random numbers*** (or arrays thereof), with different parameters.

The "set" statements allow you to ***create an object and assign a value to it***.

The "create the cbor of" statement allows you ***render an object to CBOR***. The statement also has a counterpart to render to JSON: "create the json of".
The "create the json of" statement allows you ***render an object to a JSON string***, which at the end can be printed as a string and is internal to the main JSON output returned by Zencode: it is a JSON string inside a JSON dictionary value.

A special case is the stament "create key", which we see in two flavours, one ***creates a key from a random seed***, one ***from a known seed***.

Expand Down
8 changes: 4 additions & 4 deletions docs/pages/zencode-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Rules are *optional*, they are used to define input and output formats of the sm

```txt
rule input encoding [ url64 | base64 | hex | bin ]
rule input format [ json | cbor ]
rule input format [ json ]
```

For example, a valid config is:
Expand Down Expand Up @@ -63,7 +63,7 @@ There are different ways to state who you are in order to use **my** statements
```

Data provided as input (from **data** and **keys**) is all imported
automatically from **JSON** or [CBOR](https://tools.ietf.org/html/rfc7049) binary formats.
automatically from the **JSON** string format.
There can also be no input to the code, in this case can be checked the emptiness with:

```gherkin
Expand Down Expand Up @@ -158,12 +158,12 @@ Each of the following scenario enable a set of sentences:

# *Then*

Output is all exported in JSON or CBOR
Output is all exported in JSON

[](../_media/zencode_utterances_reworked.yaml ':include :fragment=then :type=code gherkin')

Settings:
```txt
rule output encoding [ url64 | base64 | hex | bin ]
rule output format [ json | cbor ]
rule output format [ json ]
```
10 changes: 0 additions & 10 deletions docs/pages/zencode-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,3 @@ The ***rule check version*** statement, will validate the script's syntax to mak
rule check version 1.0.0
```

# Rule input/output format: using JSON or CBOR

Zenroom's default file format is JSON, but it can also manage CBOR. You can switch between the two by using the ***rule format*** statement, like for example:

```gherkin
Rule input format CBOR
Rule output format JSON
```

This two statements will make sure that CBOR data is imported, and then the output is printed in JSON.
6 changes: 3 additions & 3 deletions src/lua/zencode_data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@
if what == 'json' or what == 'JSON' then
return { fun = JSON.auto,
name = 'json' }
elseif what == 'cbor' or what == 'CBOR' then
return { fun = CBOR.auto,
name = 'cbor' }
-- elseif what == 'cbor' or what == 'CBOR' then
-- return { fun = CBOR.auto,
-- name = 'cbor' }
end
error("Conversion format not supported: "..what, 2)
return nil
Expand Down

0 comments on commit f427459

Please sign in to comment.