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

Fixes pretty-receipt command for COSE envelopes with embedded receipts #219

Merged
merged 14 commits into from
Sep 4, 2024

Conversation

ivarprudnikov
Copy link
Member

@ivarprudnikov ivarprudnikov commented Sep 2, 2024

pretty-receipt CLI command fails when presented with the receipt embedded in the cose envelope. Fixing it here to make the command more resilient when parsing arbitrary CBOR. I am fairly sure there is an edge case that is not handled properly at the moment though as JSON encoder does not like pycose objects.

After the change COSE_Sign1 with the embedded receipt output will look like:

{
  "protected": {
    "Algorithm": "Ps256",
    "ContentType": "application/json+cose-hash-v",
    "CWTClaims": {
      "iss": "did:x509:0:sha256:HnwZ4lezuxq_GVcl_Sk7YWW170qAD0DZBLXilXet0jg::eku:1.3.6.1.4.1.311.10.3.13",
      "sub": "Test",
      "iat": "2024-08-20T20:38:00+00:00",
      "svn": "0"
    },
    "X5chain": [
     "MIIERDCCAiygAwIBAgI....3TTV6s0qg==",
      "MIIFLDCCAxSgAwIBA....M1SHsro5I=",
      "MIIFDjCCA...PWC4+72M="
    ],
    "X5t": {
      "alg": -16,
      "hash": "26d40d8e012c3358c01b494dc188e9bf1b77ee9a29987ed9f6a06fb0bf9188f4"
    }
  },
  "unprotected": {
    "SCITTReceipts": [
      {
        "protected": {
          "tree_alg": "CCF",
          "SCITTIssuer": "did:web:....",
          "KID": "#113c86fc073e81cda6d031909123e03eae846c39a9ad51aad1904461de5d4774",
          "service_id": "113c86fc073e81cda6d031909123e03eae846c39a9ad51aad1904461de5d4774",
          "enclave_measurement": "96c40e2532ba329849e7fede3f3d888a0423a1dc0f3d0511b138617cc3aa9e94",
          "registration_time": "1723582574"
        },
        "contents": {
          "signature": "cfBLt5uVN8qJxbYgn4vX691KEPEkE/TNVpoRRnNlgOT/e48ewk0fYt8rHmH5efkqVZONTRYBdZ2E8nQNE69VTZ6SYTFyfSfqsHIYhT0V7zu7N/ArADnRLR2hmLJHqYZ5",
          "node_certificate": "MIIB+TCCAX6gAwIBAgIRAM...cNWJwWIEe5+E=",
          "inclusion_proof": [
            {
              "left": "cb99e3e579a8e9b15f114698ce5ca5b9bb66cc65fbdf72bc0f05ac6ddc6d3a79"
            },
            {
              "left": "68e649b295fb445f7e3555674ae7737397ade859d0cbbee8c4a2cd82bd6ca6c6"
            },
            {
              "left": "39e813d29a6e91a2abae8d50c63a572c6b28f104b05807caffc4da86bf005b42"
            },
            {
              "left": "caeb4b0fc559339e96f3d56cec3bae91ec91e3e41007c39cfc122b9a9ee56c05"
            },
            {
              "left": "eab83a86fff687e59b795b6665d3e026f942575fb54dcf89eca98d5f5833059b"
            },
            {
              "left": "e37cb3d0460332dbd959ba585914a6ef823d223ed9f8436070d574196fd6858e"
            },
            {
              "left": "1258d09965c7253ec0864665ee54756d188a0dbcf88e6859cdd3301cdb2fb8aa"
            },
            {
              "left": "8daac9fb88effe244fe2f1adf68acd96264f81b2edcbc2d2adff1c405332c711"
            }
          ],
          "leaf_info": {
            "internal_hash": "399ac6d8379ac1b95de59ae0a555068f453b14981bdb15b4f1ec70a4b978778f",
            "internal_data": "ce:214.3533:c02f3e7cf7472ea5ed399280cbc657da24d0a1a8aba73d2cb4d4518696474425"
          }
        }
      }
    ]
  },
  "payload": "gy9YIAFavX9cxXot2Ut1kPBK2AhCc5Be4z7Fzr6uYidql/hidmh0dHBzOi8vdXJsLXRvLWNvbnRlbnQ="
}

@ivarprudnikov ivarprudnikov marked this pull request as ready for review September 3, 2024 12:46
@ivarprudnikov ivarprudnikov changed the title WIP fix pretty-receipt command for cose envelopes with embedded receipts Fixes pretty-receipt command for COSE envelopes with embedded receipts Sep 3, 2024
pyscitt/pyscitt/receipt.py Outdated Show resolved Hide resolved
pyscitt/pyscitt/receipt.py Outdated Show resolved Hide resolved
pyscitt/pyscitt/receipt.py Show resolved Hide resolved
@ivarprudnikov ivarprudnikov merged commit 35f72ea into main Sep 4, 2024
16 checks passed
@ivarprudnikov ivarprudnikov deleted the fix/pretty-receipt-for-cose branch September 4, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants