Skip to content

feat(rust/signed-doc): Implement new Catalyst Signed Doc #338

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

bkioshn
Copy link
Contributor

@bkioshn bkioshn commented May 19, 2025

Description

Feature base branch for new Catalyst Signed Doc

Related Issue(s)

Closes #330

Related Pull Requests

bkioshn added 2 commits May 19, 2025 20:26
@bkioshn bkioshn marked this pull request as draft May 19, 2025 13:32
@bkioshn bkioshn added the do not merge yet PR is not ready to merge yet label May 20, 2025
bkioshn and others added 3 commits May 22, 2025 14:44
* feat(signed-doc): add new type DocType

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): add conversion policy

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): doc type

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): doc type error

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): seperate test

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): format

Signed-off-by: bkioshn <[email protected]>

---------

Signed-off-by: bkioshn <[email protected]>
…gned Documents (#349)

* wip

* wip

* fix fmt

* fix spelling

* fix clippy
bkioshn and others added 3 commits May 29, 2025 13:37
* feat(signed-doc): add new type DocType

Signed-off-by: bkioshn <[email protected]>

* wip: apply doctype

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): add more function to DocType

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): map old doctype to new doctype

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): add eq to uuidv4

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): fix validator

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): minor fixes

Signed-off-by: bkioshn <[email protected]>

* fix(catalyst-types): add hash to uuidv4

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): decoding test

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): doctype

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): minor fixes

Signed-off-by: bkioshn <[email protected]>

* chore(sign-doc): fix comment

Signed-off-by: bkioshn <[email protected]>

* fix(catalyst-types): add fromstr to uuidv4 and 7

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): restructure doctypes

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): test

Signed-off-by: bkioshn <[email protected]>

* Update rust/signed_doc/tests/proposal.rs

* Update rust/signed_doc/tests/comment.rs

* Update rust/signed_doc/tests/submission.rs

---------

Signed-off-by: bkioshn <[email protected]>
Co-authored-by: Alex Pozhylenkov <[email protected]>
…350)

* feat: initial

* test: minor check

* test: more test

* fix: minor

* Update rust/signed_doc/src/validator/rules/content_type.rs

Co-authored-by: Alex Pozhylenkov <[email protected]>

* chore: remove proptest

* chore: cleanup

* chore: split json and cbor

* chore: minor adjustment

* Update rust/signed_doc/src/validator/rules/content_type.rs

Co-authored-by: Artur Helmanau <[email protected]>

* fix: import json raw value

---------

Co-authored-by: Alex Pozhylenkov <[email protected]>
Co-authored-by: Artur Helmanau <[email protected]>
@Mr-Leshiy Mr-Leshiy marked this pull request as ready for review May 30, 2025 03:12
Copy link
Contributor

github-actions bot commented May 30, 2025

Test Report | ${\color{lightgreen}Pass: 351/351}$ | ${\color{red}Fail: 0/351}$ |

no30bit and others added 4 commits June 12, 2025 17:18
* feat: metadata enum map representation

* add encode/decode impl for Metadata

* fix integer label, upd its doc

* upd integer label doc.

* use ProblemReport, remove map ord decode validation

* Update rust/signed_doc/src/metadata/mod.rs
…or (#353)

* wip

* wip

* wip

* wip

* wip

* fix

* fix clippy

* wip

* cleanup

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* update test

* fix spelling

* wip

* wip

* Update rust/signed_doc/src/lib.rs

Co-authored-by: Artur Helmanau <[email protected]>

* Revert "wip"

This reverts commit 5b209bb.

* fix clippy

---------

Co-authored-by: Artur Helmanau <[email protected]>
* feat(deterministic decoder): rfc template

WIP

* fix: implement minimal length validation for string types

Adds validation for minimal length encoding of string types (Str and Bytes) in the
DeterministicDecoder according to RFC 8949 Section 4.2. This ensures that string
lengths are encoded using the minimal number of bytes required. For example, strings
of length 0-23 must use direct encoding, length 24-255 must use one byte, etc.

The changes:
- Add length validation for Type::Str and Type::Bytes
- Check for indefinite length strings
- Validate minimal length encoding using check_minimal_length function

* test: expand deterministic CBOR decoding tests

Adds comprehensive test coverage for RFC 8949 Section 4.2 deterministic encoding
requirements. The new tests verify:

- Minimal length integer encoding rules for values 0-23, 24-255, etc.
- Floating point value requirements including shortest form and non-finite prohibition
- String/array/map length encoding rules and indefinite length checks
- Map key ordering rules with length-first canonical ordering

Each test includes detailed comments explaining:
- The specific RFC requirement being tested
- Byte-level breakdown of CBOR encodings
- Why each test case is valid or invalid
- References to relevant RFC sections

This ensures proper validation of all deterministic encoding rules and helps
maintainers understand the requirements.

* cbor: Add comprehensive tests for deterministic encoding

Add detailed test cases for deterministic CBOR encoding rules as specified in
RFC 8949 section 4.2. The new tests cover:

- Integer boundary conditions and minimal encoding requirements
- Negative integer encoding across different ranges
- Map key ordering (length-first, then lexicographic)
- Floating point encoding with different precision requirements
- String comparison ordering including UTF-8 handling
- Nested structure validation
- Array length encoding rules
- Duplicate map key detection

The tests are extensively documented with RFC requirements and include TODOs
for future validation improvements, particularly for floating point handling
where additional checks for non-finite values and minimal encoding could be
added.

Includes commented-out test cases that can be enabled once support for
validating non-finite floating point values is implemented.

RFC: https://datatracker.ietf.org/doc/html/rfc8949#section-4.2

* cbor: Fix clippy warnings in deterministic tests

Refactor test cases to fix clippy warnings:
- Use simpler iterator chaining in array length test
- Remove redundant  calls
- Replace explicit type annotations with inferred types
- Fix collect() with redundant map operations

Also simplify floating point test cases to match current implementation
and improve RFC 8949 compliance documentation. The floating point tests
now focus on valid encodings while keeping commented-out future test
cases for non-finite values validation.

Tests still verify the same RFC requirements but with more idiomatic
Rust code.

* fmt

* docs

* docs: enhance CBOR deterministic validation documentation

Improve documentation and refactor validate_next() to align with RFC 8949 § 4.2
specification for deterministically encoded CBOR. Split validation logic into
smaller, focused functions for better maintainability.

- Split validate_next into specialized validation functions:
  * validate_integer() - Handles minimal integer encoding
  * validate_array() - Validates definite-length arrays
  * validate_string() - Checks string/bytes encoding
  * validate_map() - Ensures proper key ordering

- Add comprehensive documentation referencing RFC 8949:
  * Detail core deterministic encoding requirements
  * Document rules for integer minimality
  * Explain length field constraints
  * Specify map key ordering rules
  * Include examples of valid/invalid encodings

This refactoring improves code organization while maintaining full compliance
with the CBOR deterministic encoding specification. The enhanced documentation
helps developers understand both implementation details and RFC requirements.

* docs: enhance CBOR deterministic validation documentation

Improve documentation and refactor validate_next() to align with RFC 8949 § 4.2
specification for deterministically encoded CBOR. Split validation logic into
smaller, focused functions for better maintainability.

- Split validate_next into specialized validation functions:
  * validate_integer() - Handles minimal integer encoding
  * validate_array() - Validates definite-length arrays
  * validate_string() - Checks string/bytes encoding
  * validate_map() - Ensures proper key ordering

- Add comprehensive documentation referencing RFC 8949:
  * Detail core deterministic encoding requirements
  * Document rules for integer minimality
  * Explain length field constraints
  * Specify map key ordering rules
  * Include examples of valid/invalid encodings

This refactoring improves code organization while maintaining full compliance
with the CBOR deterministic encoding specification. The enhanced documentation
helps developers understand both implementation details and RFC requirements.

* docs: Add comprehensive documentation for CBOR deterministic validation

* Add violation test cases for string comparison ordering

* Add violation test cases for string comparison ordering

* feat(deterministic cbor): toggle validation

* feat(deterministic cbor): toggle validation

* feat(deterministic cbor): toggle validation

* refactor(generic decoder): helper functions

* refactor(generic decoder): helper functions

* refactor(generic decoder): helper functions

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(deterministic maps): rfc validation

* refactor(minimal length check): maps only

* refactor(minimal length check): maps only

* refactor(minimal length check): maps only

* refactor(minimal length check): maps only

* docs: enhance CBOR deterministic validation documentation

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* feat(deterministic map decoder only): rfc 8949

* refactor(pr changes): houskeeping

* fmt

* refactor(pr changes): houskeeping

* refactor(pr changes): houskeeping

* refactor(pr changes): houskeeping

* refactor(pr changes): houskeeping

* refactor(cleanup): actual vs declared length helper

* refactor(cleanup): actual vs declared length helper

* refactor(cleanup): actual vs declared length helper

* Add comprehensive MapEntry ordering tests

- Test length-first and lexicographic key ordering per RFC 8949
- Verify equality vs ordering distinction for CBOR deterministic encoding
- Cover edge cases: empty keys, identical entries, duplicate key scenarios

* Add comprehensive MapEntry ordering tests

- Test length-first and lexicographic key ordering per RFC 8949
- Verify equality vs ordering distinction for CBOR deterministic encoding
- Cover edge cases: empty keys, identical entries, duplicate key scenarios

* refactor(err): rm deterministic error type

* Update rust/cbork-utils/src/deterministic_helper.rs

Co-authored-by: Artur Helmanau <[email protected]>

* Fix MapEntry ordering to prioritize length over lexicographic comparison

The Ord implementation now compares key_bytes by length first, then
lexicographically if lengths are equal. This fixes the failing test
case where shorter keys should be ordered before longer keys regardless
of byte content.

* Update rust/cbork-utils/src/deterministic_helper.rs

Co-authored-by: Alex Pozhylenkov <[email protected]>

* Update rust/cbork-utils/src/deterministic_helper.rs

Co-authored-by: Alex Pozhylenkov <[email protected]>

* Update rust/cbork-utils/src/deterministic_helper.rs

Co-authored-by: Alex Pozhylenkov <[email protected]>

* fmt

* fmt

* fmt

* refactor(rm fn): get bytes

* refactor(indefinite length items): laconic

* refactor(indefinite length items): laconic

---------

Co-authored-by: Artur Helmanau <[email protected]>
Co-authored-by: Alex Pozhylenkov <[email protected]>
@no30bit no30bit closed this Jun 18, 2025
@no30bit no30bit reopened this Jun 18, 2025
bkioshn and others added 2 commits June 20, 2025 09:28
* fix(signed-doc): log and to value

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): add from doctype to vec uuid

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): add more doc type

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): from doctype for vec string

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): revert

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): revert

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): backward compatible rule

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): remove unused doc type

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): improve static doc types

Signed-off-by: bkioshn <[email protected]>

* fix(signed-doc): add more doc-types

Signed-off-by: bkioshn <[email protected]>

---------

Signed-off-by: bkioshn <[email protected]>
Co-authored-by: Alex Pozhylenkov <[email protected]>
* impl deserialize

* refactor from_metadata_fields & remove InnerMetadata

* rename visitor

* handle aliasing

* kebab-case only deserialization for SupportedLabel

* cleanup

* fmt

---------

Co-authored-by: Alex Pozhylenkov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge yet PR is not ready to merge yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Catalyst Signed Document updates
5 participants