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

Add 0.10.0 fixtures #13

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add 0.10.0 fixtures #13

wants to merge 2 commits into from

Conversation

bgins
Copy link
Contributor

@bgins bgins commented Aug 16, 2023

Description

This PR implements the following features:

  • Add 0.10.0 fixtures

Link to issue

Closes #12

Type of change

  • New feature (non-breaking change that adds functionality)

Test plan (required)

The fixtures will need to be verified manually. Taking a look through the code may be helpful for understanding how the fixtures were generated, but isn't required.

The fixtures are in fixtures/0.10.0:

.
├── all.json
├── build.json
├── cid.json
├── refute.json
└── verify.json

The verify fixtures request that an implementation check a token and associated proof map. For example:

{
    "name": "UCAN has a delegated capability",
    "task": "verify",
    "inputs": {
      "token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkaWQ6a2V5Ono2TWt0YWZaVFJFakprdlY1bWZKeGNMcE5Cb1ZQd0RMaFR1TWc5bmc3ZFk0ek1BTCIsImNhcCI6eyJtYWlsdG86YWxpY2VAZW1haWwuY29tIjp7ImVtYWlsL3NlbmQiOlt7fV19fSwiZXhwIjpudWxsLCJpc3MiOiJkaWQ6a2V5Ono2TWtmZkRaQ2tDVFdyZWc4ODY4ZkcxRkdGb2djSmo1WDZQWTkzcFBjV0RuOWJvYiIsInByZiI6WyJiYWZrcmVpYnZtaTc2NGNtdGFvNGsybWUybGtzYmY3NGRqcXBscWp3cWFsYWhkNHhmbnR5MzNycnBnbSJdLCJ1Y3YiOiIwLjEwLjAifQ.fwWnOgRSYryzvkvLyqYQZozrzKLIBfW4uGHKG6hR8Dygj1OOrDrcVXY88N7UQmj6O4ETXsrF99om5NK3QBB7Cw",
      "proofs": {
        "bafkreibvmi764cmtao4k2me2lksbf74djqplqjwqalahd4xfnty33rrpgm": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkaWQ6a2V5Ono2TWtmZkRaQ2tDVFdyZWc4ODY4ZkcxRkdGb2djSmo1WDZQWTkzcFBjV0RuOWJvYiIsImNhcCI6eyJtYWlsdG86YWxpY2VAZW1haWwuY29tIjp7ImVtYWlsL3NlbmQiOlt7fV19fSwiZXhwIjpudWxsLCJpc3MiOiJkaWQ6a2V5Ono2TWtrODliQzNKclZxS2llNzFZRWNjNU0xU01WeHVDZ054NnpMWjhTWUpzeEFMaSIsInVjdiI6IjAuMTAuMCJ9.mWmgl4OyAl_OKCB0tYBaxbw_0MkR2jM0W_G6eH8OW39IuB9y9ArbBcCSnG7r0WdeZaJBh6Qf4MxLiuSKM3ZFCA"
      }
    },
    "assertions": {
      "header": {
        "alg": "EdDSA",
        "typ": "JWT"
      },
      "payload": {
        "ucv": "0.10.0",
        "iss": "did:key:z6MkffDZCkCTWreg8868fG1FGFogcJj5X6PY93pPcWDn9bob",
        "aud": "did:key:z6MktafZTREjJkvV5mfJxcLpNBoVPwDLhTuMg9ng7dY4zMAL",
        "exp": null,
        "cap": {
          "mailto:[email protected]": {
            "email/send": [
              {}
            ]
          }
        },
        "prf": [
          "bafkreibvmi764cmtao4k2me2lksbf74djqplqjwqalahd4xfnty33rrpgm"
        ]
      },
      "signature": "fwWnOgRSYryzvkvLyqYQZozrzKLIBfW4uGHKG6hR8Dygj1OOrDrcVXY88N7UQmj6O4ETXsrF99om5NK3QBB7Cw"
    }
  }

An implementation should confirm the token encodes a valid and well-formed UCAN with a delegated capability. The assertions provide extra information that can be validated by the implementation.

The refute fixtures are similar but should refute the validity of the token. For example:

  {
    "name": "UCAN header is missing typ field",
    "task": "refute",
    "inputs": {
      "token": "eyJhbGciOiJFZERTQSJ9.eyJhdWQiOiJkaWQ6a2V5Ono2TWtmZkRaQ2tDVFdyZWc4ODY4ZkcxRkdGb2djSmo1WDZQWTkzcFBjV0RuOWJvYiIsImNhcCI6e30sImV4cCI6bnVsbCwiaXNzIjoiZGlkOmtleTp6Nk1razg5YkMzSnJWcUtpZTcxWUVjYzVNMVNNVnh1Q2dOeDZ6TFo4U1lKc3hBTGkiLCJ1Y3YiOiIwLjEwLjAifQ.mFFFVP-hfpI16xLV657cFPbmHHCy-LRuXaLaCr0c07o5gi9DLMs0RS54ZOWwNcCVLPwp1howg_aa4tUk9_DuBw",
      "proofs": {}
    },
    "assertions": {
      "header": {
        "alg": "EdDSA"
      },
      "payload": {
        "ucv": "0.10.0",
        "iss": "did:key:z6Mkk89bC3JrVqKie71YEcc5M1SMVxuCgNx6zLZ8SYJsxALi",
        "aud": "did:key:z6MkffDZCkCTWreg8868fG1FGFogcJj5X6PY93pPcWDn9bob",
        "exp": null,
        "cap": {}
      },
      "signature": "MkBYb77b19pn8fCODCMYpqNTs5_neWBsNHKL73U68S1w3sj0RCllCoHq-Ih-rrFsNvNWSSyOQN3ZC_nN966BAA"
    },
    "errors": [
      "missingField"
    ]
  }

Note that the refute fixtures also have an errors field that lists an expected error. Assertions are still included in the fixtures, but they omit any field that is malformed or missing.

The build fixtures request an implementation build a token when given a set of inputs. For example:

  {
    "name": "UCAN has an expiration",
    "task": "build",
    "inputs": {
      "version": "0.10.0",
      "issuer_base64_key": "U+bzp2GaFQHso587iSFWPSeCzbSfn/CbNHEz7ilKRZ1UQMmMS7qq4UhTzKn3X9Nj/4xgrwa+UqhMOeo4Ki8JUw==",
      "signature_scheme": "Ed25519",
      "audience": "did:key:z6MkffDZCkCTWreg8868fG1FGFogcJj5X6PY93pPcWDn9bob",
      "expiration": 9246211200,
      "capabilities": {}
    },
    "outputs": {
      "token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkaWQ6a2V5Ono2TWtmZkRaQ2tDVFdyZWc4ODY4ZkcxRkdGb2djSmo1WDZQWTkzcFBjV0RuOWJvYiIsImNhcCI6e30sImV4cCI6OTI0NjIxMTIwMCwiaXNzIjoiZGlkOmtleTp6Nk1razg5YkMzSnJWcUtpZTcxWUVjYzVNMVNNVnh1Q2dOeDZ6TFo4U1lKc3hBTGkiLCJ1Y3YiOiIwLjEwLjAifQ.pkJxQke-FDVB1Eg_7Jh2socNBKgo6_0OF1XXRfRMazmpXBG37tScYGAzJKB2Z4RFvSBpbBu29Sozrv4GQLFrDg"
    }
  }

Lastly, the toCID fixtures request an implementation compute the CID for a token with a specific hasher. For example:

  {
    "name": "Compute CID for token using SHA2-256 hasher",
    "task": "toCID",
    "inputs": {
      "token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkaWQ6a2V5Ono2TWtmZkRaQ2tDVFdyZWc4ODY4ZkcxRkdGb2djSmo1WDZQWTkzcFBjV0RuOWJvYiIsImNhcCI6e30sImV4cCI6bnVsbCwiaXNzIjoiZGlkOmtleTp6Nk1razg5YkMzSnJWcUtpZTcxWUVjYzVNMVNNVnh1Q2dOeDZ6TFo4U1lKc3hBTGkiLCJ1Y3YiOiIwLjEwLjAifQ.MkBYb77b19pn8fCODCMYpqNTs5_neWBsNHKL73U68S1w3sj0RCllCoHq-Ih-rrFsNvNWSSyOQN3ZC_nN966BAA",
      "hasher": "SHA2-256"
    },
    "outputs": {
      "cid": "bafkreibvv43zt5dfzwr5ejms3oeb5rkazufzkvqs6v3izwwlj64jmrchci"
    }
  }

all.json collects all of the above into a single JSON object.

@bgins bgins marked this pull request as ready for review August 16, 2023 21:09
@bgins bgins added the enhancement New feature or request label Aug 16, 2023
@bgins bgins marked this pull request as draft August 21, 2023 18:47
@bgins bgins mentioned this pull request Sep 5, 2023
QuinnWilton added a commit to fission-codes/rs-ucan that referenced this pull request Sep 28, 2023
Note that not all of them pass yet, and that the build tests are
impossible to support, as currently defined, due to JSON
canonicalization issues.

Fixtures from: ucan-wg/conformance-tests#13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add 0.10.0 fixtures
1 participant