Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

feat: add prefixes for chainid #2

Merged
merged 2 commits into from
Aug 5, 2021
Merged

Conversation

carsonfarmer
Copy link
Member

@carsonfarmer carsonfarmer commented Aug 4, 2021

As per our prior discussion. This now means that JWTs look something like this:

Header

{
  "alg": "ETH",
  "typ": "JWT",
  "kid": "eth:rinkeby:0x0000000..."
};

Payload

{
  "nbf": 12345,
  "iat": 12345,
  "exp": 56789,
  "iss": "eth:rinkeby:0x0000000...",
  "sub": "eth:rinkeby:0x0000000...",
  "aud": "0x111111111..."
}

I've used : as delimiters because these cannot show up in the address itself, so it is a safe delimiter to use. Additionally, it is similar to the did spec, though I've moved away from using "proper" key dids here because that adds complexity that we just don't need.

Note that aud is the address of the provider, and kid is the key id for the address. This is a non-standard JWT, with borrows ideas from ethereum/EIPs#1341. This can be validated for polygon and ethereum by extracting the address from the header, and using https://goethereumbook.org/signature-verify/ to verify that the signed payload was signed by the correct private key/address.

Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
@carsonfarmer carsonfarmer added the enhancement New feature or request label Aug 4, 2021
@carsonfarmer carsonfarmer self-assigned this Aug 4, 2021
Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
@carsonfarmer
Copy link
Member Author

Tests should be passing now @asutula

@carsonfarmer carsonfarmer merged commit b0a9155 into main Aug 5, 2021
@carsonfarmer carsonfarmer deleted the carson/chain-prefixes branch August 5, 2021 16:35
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants