Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

proofValue is not in MULTIBASE format. #233

Open
ellellie opened this issue Jan 8, 2024 · 0 comments
Open

proofValue is not in MULTIBASE format. #233

ellellie opened this issue Jan 8, 2024 · 0 comments

Comments

@ellellie
Copy link

ellellie commented Jan 8, 2024

As per Verifiable Credential Data Integrity 1.0, the proofValue MUST be expressed as in the Multibase encoding format.

This is not done in the code, see https://github.com/mattrglobal/jsonld-signatures-bbs/blob/master/src/BbsBlsSignature2020.ts#L379

Basic reproduction:

import { BbsBlsSignature2020, Bls12381G2KeyPair } from '@mattrglobal/jsonld-signatures-bbs'
import { sign, purposes } from "jsonld-signatures";

const keyPair = new Bls12381G2KeyPair({
    "id": "did:example:489398593#test",
    "controller": "did:example:489398593",
    "privateKeyBase58": "5D6Pa8dSwApdnfg7EZR8WnGfvLDCZPZGsZ5Y1ELL9VDj",
    "publicKeyBase58": "oqpWYKaZD9M1Kbe94BVXpr8WTdFBNZyKv48cziTiQUeuhm7sBhCABMyYG4kcMrseC68YTFFgyhiNeBKjzdKk9MiRWuLv5H4FFujQsQK2KTAtzU8qTBiZqBHMmnLF4PL7Ytu"
});

const documentLoader = async (url: string): Promise<any> => {
    // HACK: Just a quick hack to get the context.
    if (url.startsWith('http')) {
        const res = await fetch(url);
        const linkHeader = res.headers.get('Link')
        if(linkHeader) {
            const parts = linkHeader.split(';')
            const contextUrl = parts[0].replace('<', '').replace('>', '')

            return documentLoader(url + contextUrl)
        }

        return {
            contextUrl: null,
            document: await res.json(),
            documentUrl: url
        }
    }
}

const inputDocument = {
    '@context': [
        'https://schema.org',
        'https://w3id.org/security/bbs/v1'
    ],
    '@type': 'Person',
    'name': 'John Doe'
}

const signedDocument = await sign(inputDocument, {
    suite: new BbsBlsSignature2020({ key: keyPair }),
    purpose: new purposes.AssertionProofPurpose(),
    documentLoader
})

console.log(signedDocument)

Results in:

{
  "@context": [
    "https://schema.org",
    "https://w3id.org/security/bbs/v1"
  ],
  "@type": "Person",
  "name": "John Doe",
  "https://w3id.org/security#proof": {
    "@graph": {
      "type": "BbsBlsSignature2020",
      "created": "2024-01-08T02:17:50Z",
      "proofPurpose": "assertionMethod",
      "proofValue": "rCZ65PkLqdlYHqOJoLtPW/KdfoacLIWZ/EA79DfgygAGRQx5Uiihtno+apCmpMfjWbwMfQxOYveLVux+muOsBGn/CuxGchB3cPozh2rRtO4nvDvkL4XqCp9662Yo9GgwqcuQBY55Y6mTfz3ifaZbKg==",
      "verificationMethod": "did:example:489398593#test"
    }
  }
}

Instead, the proofValue should be expressed as RFC4648 (base64url), with no padding, and prefixed with u to denote the format.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant