-
Notifications
You must be signed in to change notification settings - Fork 0
feat(rust/signed-doc): Catalyst signed document encoding using minicbor #353
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
Conversation
coset::ContentType::Assigned(CoapContentFormat::Cbor) => ContentType::Cbor, | ||
_ => { | ||
match value { | ||
coset::ContentType::Assigned(CoapContentFormat::Json) => Ok(ContentType::Json), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aim is to remove coset, is it not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside this PR, I've just removing coset for encoding functionality. Decoding would be done under the different PR
@@ -12,10 +12,11 @@ pub(crate) mod utils; | |||
use catalyst_types::{problem_report::ProblemReport, uuid::UuidV7}; | |||
pub use content_encoding::ContentEncoding; | |||
pub use content_type::ContentType; | |||
use coset::{cbor::Value, iana::CoapContentFormat, CborSerializable}; | |||
use coset::CborSerializable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use coset
at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be eliminated under the next PR
fn encode<W: minicbor::encode::Write>( | ||
&self, e: &mut minicbor::Encoder<W>, _ctx: &mut (), | ||
) -> Result<(), minicbor::encode::Error<W::Error>> { | ||
e.str(self.to_string().as_str())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we figure out what's up with the mismatch between Section
spec and its impl?
Catalyst spec – RFC6901 Standard JSON Pointer.
Impl in this file – RFC9535 JSONPath.
I've brought up this issue before, but it hasn't been resolved. Either the spec or the impl should change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create pls a separate ticket under this feature ticket, #330.
Under this PR, not going to change it, just keep the original behaviour that we have
| SupportedField::Parameters(document_ref) => document_ref.encode(e, ctx), | ||
SupportedField::Type(doc_type) => doc_type.encode(e, ctx), | ||
SupportedField::Collabs(collabs) => { | ||
if !collabs.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the cddl spec be changed from
collaborators = [ * catalyst_id_kid ]
to
collaborators = [ + catalyst_id_kid ]
Because it's not deterministic encoding if this field is both optional and can be an empty array. This impl follows the optional +
rule.
<minicbor::bytes::ByteVec>::from(minicbor::to_vec(metadata)?), | ||
<minicbor::bytes::ByteVec>::from(protected_header_bytes(kid)?), | ||
minicbor::bytes::ByteArray::from([]), | ||
<minicbor::bytes::ByteVec>::from(content.encoded_bytes(metadata.content_encoding())?), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither Catalyst spec nor RFC 8152 Section 2 explicitly says whether an empty payload should nil
or empty bstr
. RFC says – nil
if the signature is for a detached content.
From what I understand, it wouldn't make sense for Catalyst Singed Document to have a detached content signature.
So could the spec be changed to forbid nil
? This impl follows that rule.
Co-authored-by: Artur Helmanau <[email protected]>
This reverts commit 5b209bb.
✅ Test Report | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Partially migrating
signed-doc
components encoding fromcoset
tominicbor
.As the next step, COSE helpers from #351 are intended to be salvaged too.
Related Issue(s)
Closes #332
Description of Changes
ContentType
,ContentEncoding
,DocumentRef
,Section
and othersigned-doc
components tominicbor
.coset
traits now wrap around theminicibor
implementation as opposed to the other way around it's been before.serde
implementations, whichcoset
depends on throughciborium
, now also made to wrap theminicbor
implementation where possible.Breaking Changes
None.
Related Pull Requests
Please confirm the following checks