Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust/signed-doc): Add deserializer for Catalyst Signed Documents #101

Merged
merged 82 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
a92c089
fix(rust/signed_doc): replace ULID with UUIDv7
saibatizoku Dec 10, 2024
8ee9c02
fix(rust/signed_doc): update meta.schema.json with definitions for uu…
saibatizoku Dec 10, 2024
de6cb2c
wip(rust/signed_doc): add basic structure for catalyst signed documen…
saibatizoku Dec 11, 2024
e12da32
wip(rust/signed_doc): add API methods to get document metadata uuids
saibatizoku Dec 11, 2024
9327287
fix(rust/signed_doc): fix README
saibatizoku Dec 11, 2024
56ce553
wip(rust/signed_doc): Impl Display for CatalystSignedDocument, add in…
saibatizoku Dec 16, 2024
9014d36
wip(rust/signed_doc): print cose sign example
saibatizoku Dec 16, 2024
c8e3d19
feat(rust/signed-doc): add hex crate
saibatizoku Dec 16, 2024
e1e86e7
feat(rust/signed-doc): implement TryFrom<Vec<u8>> for CatalystSignedD…
saibatizoku Dec 17, 2024
33ab474
fix(rust/signed_doc): cleanup and fix to DocumentRef serde
saibatizoku Dec 17, 2024
b5b09a3
feat(rust/signed-doc): decode CoseSign from tagged or untagged bytes
saibatizoku Dec 19, 2024
c41bbb5
feat(rust/signed-doc): add subcommand to inspect cose sign from hex-e…
saibatizoku Dec 19, 2024
ea0bebd
fix(rust/signed_doc): remove alg from top-level protected header
saibatizoku Dec 19, 2024
d942e1e
feat(rust/signed-doc): refactor metadata into a module
saibatizoku Dec 19, 2024
875aa31
feat(rust/signed-doc): add types for UUIDv4 and UUIDv7
saibatizoku Dec 26, 2024
7e2425d
fix(rust/signed_doc): update code and examples with Uuid types
saibatizoku Dec 26, 2024
c28635d
fix(rust/signed_doc): refactor Metadata impl TryFrom<coset::cbor::Value>
saibatizoku Dec 26, 2024
8002c05
fix(rust/signed_doc): refactor impl TryFrom<&coset::cbor::Value> for …
saibatizoku Dec 26, 2024
5c88eb7
fix(rust/signed-doc): remove unused dependency
saibatizoku Dec 29, 2024
cc00f14
Merge branch 'main' into fix/replace-ulid-with-uuidv7
stevenj Jan 3, 2025
2d61209
fix(rust): Fix cargo.toml broken after merge
stevenj Jan 3, 2025
ce5d44c
Merge branch 'main' into fix/replace-ulid-with-uuidv7
stevenj Jan 3, 2025
13b7ac7
fix(rust/signed-doc): Update rust/signed_doc/src/lib.rs
saibatizoku Jan 3, 2025
5cd299f
feat(rust/signed-doc): add type for Key ID
saibatizoku Jan 3, 2025
2a2aea1
feat(rust/signed-doc): add types for Metadata fields.
saibatizoku Jan 4, 2025
3f77f5e
docs(docs): Add formal specification for the RBAC KID URL format.
stevenj Jan 5, 2025
9fe1835
Merge branch 'fix/replace-ulid-with-uuidv7' of github.com:input-outpu…
stevenj Jan 5, 2025
6111dd2
Merge branch 'main' into fix/replace-ulid-with-uuidv7
stevenj Jan 5, 2025
3dfe9ca
fix(docs): Fix the example Kid URI
stevenj Jan 5, 2025
83a293e
Merge branch 'fix/replace-ulid-with-uuidv7' of github.com:input-outpu…
stevenj Jan 5, 2025
642b8de
feat(rust): Update the KidURI struct to match the formal spec (#139)
stevenj Jan 5, 2025
276b4ac
feat(rust/signed-doc): add mod payload
saibatizoku Jan 5, 2025
9c94aa5
chore(rust/signed-doc): tidy up metadata mod
saibatizoku Jan 5, 2025
e7f651f
wip(rust/signed_doc): use Content type for document payload
saibatizoku Jan 5, 2025
aa69d7b
fix(rust/signed_doc): ser/de for ContentType and ContentEncoding.
saibatizoku Jan 6, 2025
97af0ff
fix(rust/signed_doc): update metadata to require content type
saibatizoku Jan 7, 2025
1486b87
fix(rust/signed_doc): update payload type
saibatizoku Jan 8, 2025
effde77
Merge remote-tracking branch 'origin/main' into fix/replace-ulid-with…
saibatizoku Jan 8, 2025
f920619
fix(rust/signed_doc): add brotli decompression
saibatizoku Jan 8, 2025
55dd3f5
fix(rust/signed_doc): add metadata fields
saibatizoku Jan 8, 2025
d38f82b
wip(rust/signed_doc): use catalyst-types crate for kid uri
saibatizoku Jan 8, 2025
a6e33d6
wip(rust/signed_doc): use catalyst-types crate for uuids
saibatizoku Jan 8, 2025
2fb1abf
wip(rust/signed_doc): use catalyst-types crate for kid uri
saibatizoku Jan 8, 2025
2f877b6
Merge remote-tracking branch 'origin/main' into fix/replace-ulid-with…
saibatizoku Jan 8, 2025
1804fef
remove redundant signatures field
Mr-Leshiy Jan 9, 2025
6af9ab5
update cose_protected_header_find function
Mr-Leshiy Jan 9, 2025
e06aa2f
fix DocumentId, DocumentRef structs
Mr-Leshiy Jan 9, 2025
b57b38f
rename has_error to is_valid
Mr-Leshiy Jan 9, 2025
8ee9a67
rename crate
Mr-Leshiy Jan 9, 2025
bb0e29a
remove cose_raw
Mr-Leshiy Jan 9, 2025
782c7b9
move additional_fields into another mod
Mr-Leshiy Jan 9, 2025
5c74471
change Try to TryFrom
Mr-Leshiy Jan 9, 2025
2b9282f
fix(rust/signed_doc): decode and validate signatures
saibatizoku Jan 9, 2025
4455ed2
update document content
Mr-Leshiy Jan 10, 2025
f8f4235
remove parsing check
Mr-Leshiy Jan 10, 2025
40acd23
wip
Mr-Leshiy Jan 10, 2025
aca802a
refactor Metadata decoding
Mr-Leshiy Jan 10, 2025
b713b8e
fix(rust/signed_doc): add serde::Serialize to AdditionalFields and Do…
saibatizoku Jan 11, 2025
68b1989
Merge remote-tracking branch 'origin/main' into fix/replace-ulid-with…
saibatizoku Jan 11, 2025
8c23786
fix(rust/signed_doc): wip fixes to examples
saibatizoku Jan 13, 2025
fbf4584
feat(rust/signed-doc): serialize DocumentRef to cbor value
saibatizoku Jan 13, 2025
b37fcb7
fix(rust/signed-doc): add missing metadata aditional fields
saibatizoku Jan 13, 2025
4dd828b
fix(rust/signed-doc): encode metadata aditional fields as REST items
saibatizoku Jan 13, 2025
90d0622
fix(rust/signed-doc): handle validation errors with crate::error::Error
saibatizoku Jan 13, 2025
7a0fa43
remove author field
Mr-Leshiy Jan 13, 2025
e81df07
add doc_meta getter
Mr-Leshiy Jan 14, 2025
128a800
fix(rust/signed_doc): use minicbor encode/decode
saibatizoku Jan 15, 2025
ce90bd0
Merge remote-tracking branch 'origin/main' into fix/replace-ulid-with…
saibatizoku Jan 15, 2025
28369b2
fix(rust/signed-doc): remove unused dependencies
saibatizoku Jan 15, 2025
2b68bdd
chore(docs): update spelling dictionary
saibatizoku Jan 15, 2025
7d1537a
fix(rust/signed-doc): update catalyst-types
saibatizoku Jan 15, 2025
1254bb4
update CatalystSignedDocument decoding
Mr-Leshiy Jan 15, 2025
723dbe4
fix
Mr-Leshiy Jan 15, 2025
ebd29d1
make minicbor imports public
Mr-Leshiy Jan 15, 2025
3cfc329
fix(rust/signed_doc): cleanup examples, fix signatures decoding
saibatizoku Jan 15, 2025
ebcc8e4
Merge remote-tracking branch 'origin/main' into fix/replace-ulid-with…
saibatizoku Jan 15, 2025
8e5879e
fix(rust/signed_doc): more cleanup
saibatizoku Jan 15, 2025
00c3d81
fix(rust/signed-doc): fix spelling
saibatizoku Jan 15, 2025
886672d
update Readme.md
Mr-Leshiy Jan 16, 2025
cd817a4
fix README.md
Mr-Leshiy Jan 16, 2025
2f0c186
fix earthfile
Mr-Leshiy Jan 16, 2025
ffb1f46
Merge branch 'main' into fix/replace-ulid-with-uuidv7
stevenj Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ coverallsapp
cpus
crontabs
crontagged
csprng
cstring
dalek
dashmap
Expand Down Expand Up @@ -122,6 +123,7 @@ jorm
jormungandr
Jörmungandr
jsonschema
kiduri
lcov
Leay
Leshiy
Expand Down Expand Up @@ -209,6 +211,8 @@ reqwest
retriggering
ristretto
rlib
rngs
rsplit
rulelist
RULENAME
runable
Expand All @@ -235,6 +239,7 @@ smac
stevenj
stringzilla
subsec
subnetwork
symlinkat
syscall
tacho
Expand Down Expand Up @@ -262,8 +267,11 @@ unlinkat
upnp
ureq
userid
userinfo
utimensat
UTXO
uuidv4
uuidv7
vitss
Vkey
vkeywitness
Expand Down
3 changes: 3 additions & 0 deletions docs/src/architecture/08_concepts/rbac_kid_uri/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: RBAC KID (Key Identifier) URI
arrange:
- kiduri.md
180 changes: 180 additions & 0 deletions docs/src/architecture/08_concepts/rbac_kid_uri/kiduri.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
Title: RBAC Key Identifier URI Specification
Category: Catalyst
Status: Proposed
Authors:
- Steven Johnson <[email protected]>
Implementors:
- Catalyst Fund 14
Discussions: []
Created: 2025-01-05
License: CC-BY-4.0
---

* [Abstract](#abstract)
* [Motivation: why is this CIP necessary?](#motivation-why-is-this-cip-necessary)
* [Specification](#specification)
* [URI](#uri)
* [`scheme`](#scheme)
* [`authority`](#authority)
* [`authority` - `host`](#authority---host)
* [List of defined hosts](#list-of-defined-hosts)
* [`authority` - `userinfo`](#authority---userinfo)
* [Lists of defined subnetwork `userinfo` values](#lists-of-defined-subnetwork-userinfo-values)
* [Cardano](#cardano)
* [`path`](#path)
* [Reference Implementation](#reference-implementation)
* [Test Vectors](#test-vectors)
* [Rationale: how does this CIP achieve its goals?](#rationale-how-does-this-cip-achieve-its-goals)
* [Path to Active](#path-to-active)
* [Acceptance Criteria](#acceptance-criteria)
* [Implementation Plan](#implementation-plan)
* [Copyright](#copyright)

## Abstract

Definition of a [URI] which allows for RBAC keys used for different purposes to be easily and
unambiguously identified.

## Motivation: why is this CIP necessary?

There is a need to identify which Key from a RBAC registration was used to sign data.
RBAC defines a universal keychain of different keys that can be used for different purposes.
They can be used not only for Signatures, but also Encryption.

Therefore, there needs to be an unambiguous and easy to lookup identifier to signify which key was
used for a particular purpose.

This document defines a [URI] scheme to unambiguously define a particular key with reference to a
particular RBAC keychain.

## Specification

### URI

The RBAC Kid is formatted using a [Universal Resource Identifier].
Refer to [RFC3986] for the specification of the URI format.

### `scheme`

The [scheme](https://datatracker.ietf.org/doc/html/rfc3986#section-3.1) **MUST** be `kid.catalyst-rbac`;

### `authority`

The [authority](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2) references the blockchain or network
the key was registered within.

It is perfectly valid for a Kid to reference a different network than the place where the Key is used.
For example, a `cardano` KID can be used to post documents to `IPFS`.
Its purpose is to define WHERE the key was registered, and nothing more.

The Authority will consist of a `host` and optional `userinfo`.

#### `authority` - `host`

The [host](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2)
refers to the network type where the RBAC registration was made.
It **IS NOT** resolvable with **DNS**, and **IS NOT** a public host name.
It is used as a decentralized network identifier.
The consumer of the `KID` must be able to resolve these host names.

##### List of defined hosts

| `host` | Description |
| --- | --- |
| `cardano` | Cardano Blockchain |
| `midnight` | Midnight Blockchain |
| `ethereum` | Ethereum Blockchain |
| `cosmos` | Cosmos Blockchain |

#### `authority` - `userinfo`

The [userinfo](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1)
is used to distinguish a subnetwork from the primary main network.
The absence of `userinfo` is used to indicate the primary main network.

##### Lists of defined subnetwork `userinfo` values

###### Cardano

| `userinfo` | Description |
| --- | --- |
| `preprod` | Cardano Pre-Production Network |
| `preview` | Cardano Preview Network |
| 0x<hex_number> | Cardano network identified by this magic number in hex |

### `path`

The [path](https://datatracker.ietf.org/doc/html/rfc3986#section-3.3) defines the actual key within the registration.
Keys are defined relative to the very first Role0 Key registered in any RBAC registration.

The overall `path` specification is: `<initial role0 key>/<role>/<rotation>#encrypt`

* `<initial role 0 key>` - This is the very first role 0 key used to post the registration to the network.
* It is the [Base64 URL] encoded binary data of the role 0 public key.
* This does not change, even if the Initial Role 0 key is revoked.
* This allows for an unambiguous identifier for the RBAC keychain.
* It is not necessarily the key being identified.
* `<role>` - This is the Role number being used.
* It is a positive number, starting at 0, and no greater than 65535.
* `<rotation>` - This is the rotation of the defined role key being identified.
* It starts at 0 for the first published key for the role, and increments by one for each subsequent published rotation.
* This number refers to the published sequence of keys for the role in the RBAC registration keychain,
not the index used in the key derivation.
* It is positive and no greater than 65535.
* `#encrypt` - [Fragment](https://datatracker.ietf.org/doc/html/rfc3986#section-3.5)
disambiguates Encryption Public Keys from signing public keys.
* Roles can have 1 active public signing key, and 1 active public encryption key.
* By default, the URL is referencing the signing public key.
* If a public encryption key is being identified, then the fragment `#encrypt` is appended to the [Universal Resource Identifier].

## Reference Implementation

The first implementation will be Catalyst Voices.

## Test Vectors

* `kid.catalyst-rbac://cardano/<key>/0/0`
* A Signing key registered on the Cardano Main network.
* Role 0 - Rotation 0.
In this example, it is exactly the same as the `<key>`.
* `kid.catalyst-rbac://preprod@cardano/<key>/7/3`
* A Signing key registered on the Cardano pre-production network.
* Role 7 - Rotation 3.
The Key for Role 7, and its third published rotation
(i.e., the fourth key published, the first is the initial key, plus 3 rotations following it).
* `kid.catalyst-rbac://preprod@cardano/<key>/2/0#encrypt`
* A Public Encryption key registered on the Cardano pre-production network.
* Role 2 - Rotation 0.
The initially published Public Encryption Key for Role 2.
* `kid.catalyst-rbac://midnight/<key>/0/1`
* A Signing key registered on the Midnight Blockchain Main network
* Role 0 - Rotation 1.
In this example, it is NOT the same as the `<key>`, as it identifies the first rotation after `<key>`.
* `kid.catalyst-rbac://midnight/<key>/2/1#encrypt`
* A public encryption key registered on the Midnight Blockchain Main network.
* Role 2 - Rotation 1.

## Rationale: how does this CIP achieve its goals?

By creating a [URI] to identify keys,
we allow the unambiguous and flexible identification of any RBAC Key that was used for any purpose.

## Path to Active

### Acceptance Criteria

Working Implementation before Fund 14.

### Implementation Plan

Fund 14 project catalyst will deploy this scheme for Key Identification.

## Copyright

This document is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode).

[URI]: https://datatracker.ietf.org/doc/html/rfc3986
[Universal Resource Identifier]: https://datatracker.ietf.org/doc/html/rfc3986
[RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986
[Base64 URL]: https://datatracker.ietf.org/doc/html/rfc4648#section-5
2 changes: 1 addition & 1 deletion rust/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ build:
--args1="--libs=c509-certificate --libs=cardano-blockchain-types --libs=cardano-chain-follower --libs=hermes-ipfs" \
--args2="--libs=cbork-cddl-parser --libs=cbork-abnf-parser --libs=cbork-utils --libs=catalyst-types" \
--args3="--libs=catalyst-voting --libs=immutable-ledger --libs=vote-tx-v1 --libs=vote-tx-v2" \
--args4="--bins=cbork/cbork --libs=rbac-registration --libs=signed_doc" \
--args4="--bins=cbork/cbork --libs=rbac-registration --libs=catalyst-signed-doc" \
--args5="--cov_report=$HOME/build/coverage-report.info" \
--output="release/[^\./]+" \
--junit="cat-libs.junit-report.xml" \
Expand Down
20 changes: 12 additions & 8 deletions rust/signed_doc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "signed_doc"
version = "0.1.0"
name = "catalyst-signed-doc"
version = "0.0.1"
edition.workspace = true
authors.workspace = true
homepage.workspace = true
Expand All @@ -11,16 +11,20 @@ license.workspace = true
workspace = true

[dependencies]

[dev-dependencies]
clap = { version = "4.5.23", features = ["derive", "env"] }
catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250114-02" }
anyhow = "1.0.95"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.134"
# TODO: Bump this to the latest version and fix the code
jsonschema = "0.18.3"
coset = "0.3.8"
minicbor = "0.25.1"
brotli = "7.0.0"
ed25519-dalek = { version = "2.1.1", features = ["pem"] }
uuid = { version = "1.11.0", features = ["v4", "serde"] }
ulid = { version = "1.1.3", features = ["serde"] }
ed25519-dalek = { version = "2.1.1", features = ["pem", "rand_core"] }
uuid = { version = "1.11.0", features = ["v4", "v7", "serde"] }
hex = "0.4.3"
thiserror = "2.0.9"

[dev-dependencies]
clap = { version = "4.5.23", features = ["derive", "env"] }
rand = "0.8.5"
Loading
Loading