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

fix(rust/rbac-registration): Fix deleted tag cbor decoding #249

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

bkioshn
Copy link
Contributor

@bkioshn bkioshn commented Mar 22, 2025

Description

Fix deleted tag cbor decoding for X509, C509, Simple Public Key
As defined
deleted-key = #6.31(undefined) ; delete the key (if any) at this position of the array
deleted-key is of tag 31 follow by undefined.

Ref: https://github.com/input-output-hk/catalyst-CIPs/blob/x509-role-registration-metadata/CIP-XXXX/x509-roles.cddl

Test

Test with slot = 86965717, tx_index = 0 Deleted for x509 certificate index 0

Original Error got Unknown tag for X509DerCert

CIP509 invalid: Ok(Some(Cip509 { purpose: Some(UuidV4(ca7a1457-ef9f-4c7f-9c74-7f8c4a4cfa6c)), txn_inputs_hash: Some(TxInputHash(Hash<16>("56aa72567aad49ab277ae9430faf3162"))), prv_tx_id: None, metadata: Some(Cip509RbacMetadata { x509_certs: [], c509_certs: [], certificate_uris: Cip0134UriSet(Cip0134UriSetInner { x_uris: {}, c_uris: {} }), pub_keys: [], revocation_list: [], role_data: {}, purpose_key_data: {} }), validation_signature: Some(ValidationSignature([222, 57, 65, 176, 211, 141, 109, 164, 84, 250, 212, 222, 85, 179, 133, 220, 107, 80, 123, 5, 163, 111, 170, 53, 154, 170, 67, 160, 254, 31, 240, 218, 43, 112, 165, 131, 150, 223, 14, 49, 85, 14, 125, 74, 17, 41, 85, 198, 242, 205, 206, 210, 101, 58, 250, 107, 85, 91, 196, 228, 6, 172, 225, 13])), payment_history: {}, txn_hash: TransactionId(Hash<32>("cc51554b706767abb1ede232c225156af60e402d68f2c925284aa95869c8fb63")), origin: PointTxnIdx { point: Point((86965717, 455a2eec62e722f5e8fc320cafc3d6d1c1df6cea9fc5a6a97c1c305f86329c83)), txn_index: TxnIndex(0) }, catalyst_id: None, report: ProblemReport(State { context: "Decoding and validating Cip509", report: Report([Entry { kind: Other { description: "Unable to decode array value: Error { err: Message, pos: None, msg: \"Unknown tag for X509DerCert\" }" }, context: "Cip509RbacMetadata x509 certificates" }]) }) })), network: "preprod"

After fixing

CIP509 invalid: Ok(Some(Cip509 { purpose: Some(UuidV4(ca7a1457-ef9f-4c7f-9c74-7f8c4a4cfa6c)), txn_inputs_hash: Some(TxInputHash(Hash<16>("56aa72567aad49ab277ae9430faf3162"))), prv_tx_id: None, metadata: Some(Cip509RbacMetadata { x509_certs: [Deleted, X509Cert(CertificateInner { tbs_certificate: TbsCertificateInner { version: V3, serial_number: SerialNumber { inner: Int { inner: BytesOwned { length: Length(5), inner: [0, 226, 247, 196, 46] } }, _profile: PhantomData<x509_cert::certificate::Rfc5280> }, signature: AlgorithmIdentifier { oid: ObjectIdentifier(1.3.101.112), parameters: None }, issuer: RdnSequence([RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.6), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.8), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.7), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.10), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.11), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.3), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] })]), validity: Validity { not_before: UtcTime(UtcTime(DateTime { year: 2025, month: 3, day: 22, hour: 13, minutes: 6, seconds: 9, unix_duration: 1742648769s })), not_after: UtcTime(UtcTime(DateTime { year: 1999, month: 12, day: 31, hour: 23, minutes: 59, seconds: 59, unix_duration: 946684799s })) }, subject: RdnSequence([RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.6), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.8), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.7), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.10), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.11), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] }), RelativeDistinguishedName(SetOfVec { inner: [AttributeTypeAndValue { oid: ObjectIdentifier(2.5.4.3), value: Any { tag: Tag(0x13: PrintableString), value: BytesOwned { length: Length(0), inner: [] } } }] })]), subject_public_key_info: SubjectPublicKeyInfo { algorithm: AlgorithmIdentifier { oid: ObjectIdentifier(1.3.101.112), parameters: None }, subject_public_key: BitString { unused_bits: 0, bit_length: 512, inner: [110, 66, 248, 229, 137, 167, 110, 187, 19, 239, 39, 157, 247, 132, 30, 252, 233, 120, 241, 6, 190, 225, 150, 240, 227, 207, 211, 71, 187, 49, 162, 232, 142, 54, 112, 201, 252, 143, 142, 50, 98, 247, 199, 211, 150, 49, 98, 217, 178, 123, 251, 145, 167, 185, 217, 177, 183, 203, 156, 196, 50, 107, 36, 208] } }, issuer_unique_id: None, subject_unique_id: None, extensions: Some([Extension { extn_id: ObjectIdentifier(2.5.29.17), critical: false, extn_value: OctetString { inner: [48, 129, 147, 130, 12, 109, 121, 100, 111, 109, 97, 105, 110, 46, 99, 111, 109, 130, 16, 119, 119, 119, 46, 109, 121, 100, 111, 109, 97, 105, 110, 46, 99, 111, 109, 130, 11, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 130, 15, 119, 119, 119, 46, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 134, 83, 119, 101, 98, 43, 99, 97, 114, 100, 97, 110, 111, 58, 47, 47, 97, 100, 100, 114, 47, 115, 116, 97, 107, 101, 95, 116, 101, 115, 116, 49, 117, 112, 104, 101, 50, 106, 113, 112, 50, 117, 118, 100, 119, 100, 55, 110, 54, 117, 55, 50, 99, 101, 109, 57, 50, 119, 57, 50, 119, 51, 48, 106, 101, 50, 122, 117, 52, 48, 112, 101, 50, 112, 102, 101, 120, 52, 115, 108, 101, 101, 99, 106, 113] } }]) }, signature_algorithm: AlgorithmIdentifier { oid: ObjectIdentifier(1.3.101.112), parameters: None }, signature: BitString { unused_bits: 0, bit_length: 512, inner: [51, 27, 229, 7, 190, 228, 30, 160, 92, 223, 63, 128, 180, 160, 26, 234, 195, 226, 132, 223, 162, 31, 234, 97, 180, 105, 229, 79, 111, 157, 47, 108, 177, 82, 125, 64, 0, 126, 143, 38, 120, 106, 244, 33, 213, 231, 41, 64, 119, 206, 249, 46, 84, 20, 202, 78, 10, 44, 35, 165, 226, 124, 60, 0] } })], c509_certs: [], certificate_uris: Cip0134UriSet(Cip0134UriSetInner { x_uris: {1: [Cip0134Uri { uri: "web+cardano://addr/stake_test1uphe2jqp2uvdwd7n6u72cem92w92w30je2zu40pe2pfex4sleecjq", address: Stake(StakeAddress(Testnet, Stake(Hash<28>("6f9548015718d737d3d73cac6765538aa745f2ca85cabc3950539356")))) }]}, c_uris: {} }), pub_keys: [], revocation_list: [], role_data: {RoleNumber(0): RoleData { signing_key: Some(KeyLocalRef { local_ref: X509Certs, key_offset: 1 }), encryption_key: None, payment_key: Some(ShelleyAddress(Testnet, Key(Hash<28>("2bfcb2088e089b6064d432f006e9ffc35cc0dd9fe244b983f849fd3e")), Key(Hash<28>("6f9548015718d737d3d73cac6765538aa745f2ca85cabc3950539356")))), extended_data: {10: [100, 84, 101, 115, 116]} }}, purpose_key_data: {} }), validation_signature: Some(ValidationSignature([222, 57, 65, 176, 211, 141, 109, 164, 84, 250, 212, 222, 85, 179, 133, 220, 107, 80, 123, 5, 163, 111, 170, 53, 154, 170, 67, 160, 254, 31, 240, 218, 43, 112, 165, 131, 150, 223, 14, 49, 85, 14, 125, 74, 17, 41, 85, 198, 242, 205, 206, 210, 101, 58, 250, 107, 85, 91, 196, 228, 6, 172, 225, 13])), payment_history: {}, txn_hash: TransactionId(Hash<32>("cc51554b706767abb1ede232c225156af60e402d68f2c925284aa95869c8fb63")), origin: PointTxnIdx { point: Point((86965717, 455a2eec62e722f5e8fc320cafc3d6d1c1df6cea9fc5a6a97c1c305f86329c83)), txn_index: TxnIndex(0) }, catalyst_id: None, report: ProblemReport(State { context: "Decoding and validating Cip509", report: Report([Entry { kind: Other { description: "The role 0 certificate must be present" }, context: "Role data validation" }, Entry { kind: Other { description: "The role 0 must reference a certificate with 0 index (RoleData { signing_key: Some(KeyLocalRef { local_ref: X509Certs, key_offset: 1 }), encryption_key: None, payment_key: Some(ShelleyAddress(Testnet, Key(Hash<28>(\"2bfcb2088e089b6064d432f006e9ffc35cc0dd9fe244b983f849fd3e\")), Key(Hash<28>(\"6f9548015718d737d3d73cac6765538aa745f2ca85cabc3950539356\")))), extended_data: {10: [100, 84, 101, 115, 116]} })" }, context: "Role data validation" }]) }) })), network: "preprod"

@bkioshn bkioshn self-assigned this Mar 22, 2025
Copy link
Contributor

github-actions bot commented Mar 22, 2025

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

@bkioshn bkioshn added the review me PR is ready for review label Mar 22, 2025
Copy link
Contributor

@Mr-Leshiy Mr-Leshiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Mr-Leshiy Mr-Leshiy merged commit 3f71447 into main Mar 24, 2025
10 checks passed
@Mr-Leshiy Mr-Leshiy deleted the fix/delete-tag branch March 24, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review me PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants