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

Signature verification #23

Merged
merged 21 commits into from
Mar 30, 2022
Merged

Signature verification #23

merged 21 commits into from
Mar 30, 2022

Conversation

mistermoe
Copy link
Member

@mistermoe mistermoe commented Mar 28, 2022

Overview

  • Adds function verifyMessageSignature to verify a signed message
  • scaffolds Permissions interface stuff
  • Adds PermissionsRequest message validation
  • Updates CONTRIBUTING.md

Review instructions

  • Review code, run tests to ensure there are no failing ones
git clone https://github.com/TBD54566975/hub-sdk-js
cd hub-sdk-js
git checkout signature-verification
npm install
npm run test

output should look like this:

> hub-sdk@0.1.0 test
> ts-mocha --type-check tests/**/*.ts



  Permission Tests
    constructor
      - throws an exception if expiration is in the past
      - throws an exception if expiration is before nbf
    toUnixEpochSeconds
      ✔ adds duration to the current time and returns that as a unix epoch timestamp
      - converts a date to a unix epoch timestamp

  Message Tests
    validateMessage
      - throws exception if interface method isnt supported
      - throws exception if message is invalid relative to interface method
    verifyMessageSignature
      - throws an exception if attestation property is missing
      ✔ throws an exception if attestation payload is not a valid CID
      ✔ throws an exception if CID of descriptor !== attestation payload
      ✔ throws an exception if provided CID doesnt utilize cbor codec
      ✔ throws an exception if provided CID uses unsupported hashing algo
      ✔ throws an exception if DID could not be resolved
      ✔ throws an exception if appropriate key isnt present in DID Doc
      ✔ throws an exception if signature does not match
      ✔ resolves if signature is successfully verified


  9 passing (30ms)
  6 pending

src/message.ts Show resolved Hide resolved
src/message.ts Show resolved Hide resolved
@mistermoe mistermoe removed the request for review from decentralgabe March 30, 2022 05:33
@mistermoe mistermoe merged commit e04084d into main Mar 30, 2022
@mistermoe mistermoe deleted the signature-verification branch March 30, 2022 05:35
@mistermoe mistermoe linked an issue Mar 30, 2022 that may be closed by this pull request
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.

Fill out CONTRIBUTING.md
2 participants