An open API service indexing awesome lists of open source software.

https://github.com/blockchaincommons/bc-dcbor-cli

A command line Deterministic CBOR ("dCBOR") validation and diagnostic tool.
https://github.com/blockchaincommons/bc-dcbor-cli

Last synced: 7 months ago
JSON representation

A command line Deterministic CBOR ("dCBOR") validation and diagnostic tool.

Awesome Lists containing this project

README

          

# Blockchain Commons command line parser/validator for deterministic CBOR ("dCBOR")

### _by Wolf McNally_

---

`dcbor` is a command line Deterministic CBOR ("dCBOR") validation and diagnostic tool based on [the crate of the same name](https://crates.io/crates/dcbor).

* Validates dCBOR inputs.
* Receives inputs in hex or binary format.
* Formats output several different ways:
* CBOR diagnostic notation (compact or annotated).
* Hexadecimal (compact or annotated).
* Binary

## Related Projects

* [dCBOR Overview](https://github.com/BlockchainCommons/crypto-commons/blob/master/dcbor.md)
* [dCBOR Library for Rust](https://github.com/BlockchainCommons/bc-dcbor-rust)
* [dCBOR Library for Swift](https://github.com/BlockchainCommons/BCSwiftDCBOR)

## Installation

To install from crates.io, run:

```bash
cargo install dcbor-cli
```

To install from source, clone this repo, change to its root directory and run:

```bash
cargo install --path .
```

## Command Line Syntax

This is the command line syntax as output by typing `dcbor --help`:

```
Command line parser/validator for deterministic CBOR ("dCBOR").

Usage: dcbor [OPTIONS] [INPUT] [COMMAND]

Commands:
array Compose a dCBOR array from the provided elements
map Compose a dCBOR map from the provided keys and values
help Print this message or the help of the given subcommand(s)

Arguments:
[INPUT]
Input dCBOR in the format specified by `--in`. If not provided here or input format is binary, input is read from STDIN

Options:
-i, --in
The input format

[default: diag]

Possible values:
- diag: CBOR diagnostic notation
- hex: Hexadecimal
- bin: Raw binary

-o, --out
The output format

[default: hex]

Possible values:
- diag: CBOR diagnostic notation
- hex: Hexadecimal
- bin: Raw binary
- none: No output: merely succeeds on validation of input

-a, --annotate
Output diagnostic notation or hexadecimal with annotations. Ignored for other output formats

-h, --help
Print help (see a summary with '-h')

-V, --version
Print version
```

## Examples

### Convert CBOR diagnostic notation to hexadecimal

> **NOTE:** The default input format is `diag` and the default output format is `hex`. This is not the same as previous versions of `dcbor`. This change was made to facilitate the use of `dcbor` as a compositional tool for dCBOR in scripts.

This example shows how to convert a simple CBOR diagnostic notation input (a number) to its serialized hexadecimal form:

```
$ dcbor '42'
182a
```

Floating point numbers work the same way:

```
$ dcbor '3.14'
fb40091eb851eb851f
```

In diagnostic notation, text strings must be enclosed in double quotes, so you must do so on the command line, which requires escaping the double quotes:

```
$ dcbor '"Hello"'
6548656c6c6f
```

To avoid escaping no matter the complexity of the input, you can use a "here document" (a.k.a. "heredoc"). This example is the same as the previous one, but it uses a heredoc to avoid escaping the double quotes:

```
$ dcbor <test.bin

# Read it back in from the same file.
$ dcbor --in bin | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |
| Wolf McNally | Lead Researcher/Engineer | [@WolfMcNally](https://github.com/wolfmcnally) | \ | 9436 52EE 3844 1760 C3DC  3536 4B6C 2FCF 8947 80AE |

## Responsible Disclosure

We want to keep all of our software safe for everyone. If you have discovered a security vulnerability, we appreciate your help in disclosing it to us in a responsible manner. We are unfortunately not able to offer bug bounties at this time.

We do ask that you offer us good faith and use best efforts not to leak information or harm any user, their data, or our developer community. Please give us a reasonable amount of time to fix the issue before you publish it. Do not defraud our users or us in the process of discovery. We promise not to bring legal action against researchers who point out a problem provided they do their best to follow the these guidelines.

### Reporting a Vulnerability

Please report suspected security vulnerabilities in private via email to ChristopherA@BlockchainCommons.com (do not use this email for support). Please do NOT create publicly viewable issues for suspected security vulnerabilities.

The following keys may be used to communicate sensitive information to developers:

| Name | Fingerprint |
| ----------------- | -------------------------------------------------- |
| Christopher Allen | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |

You can import a key by running the following command with that individual’s fingerprint: `gpg --recv-keys ""` Ensure that you put quotes around fingerprints that contain spaces.