Skip to content

Commit

Permalink
Merge pull request #72 from blockchain-certificates/feat/align-data-i…
Browse files Browse the repository at this point in the history
…ntegrity-proof

feat(DataIntegrityProof): enable verification of data integrity proof
  • Loading branch information
lemoustachiste authored Feb 27, 2024
2 parents bea7dfa + e5e5773 commit 1f4e9e7
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 26 deletions.
39 changes: 15 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
"typings": "lib/index.d.ts",
"dependencies": {
"@blockcerts/explorer-lookup": "^1.5.1",
"@blockcerts/schemas": "^3.6.2",
"@trust/keyto": "^1.0.1",
"@vaultie/lds-merkle-proof-2019": "^0.0.12",
"bitcoinjs-lib": "^6.0.2",
"bs58": "^4.0.1",
"elliptic": "^6.5.4",
"hash-base": "github:blockchain-certificates/hash-base",
"js-sha3": "^0.8.0",
"jsonld": "^8.2.0",
"jsonld": "^8.3.2",
"jsonld-signatures": "^11.2.1",
"lodash.clonedeep": "^4.5.0",
"secp256k1": "^5.0.0",
"sha256": "^0.2.0",
"xmlhttprequest": "^1.8.0"
},
"devDependencies": {
"@blockcerts/schemas": "^3.2.1",
"@decentralized-identity/did-common-typescript": "^0.1.19",
"@digitalbazaar/vc": "^6.2.0",
"@rollup/plugin-commonjs": "^25.0.7",
Expand Down
39 changes: 39 additions & 0 deletions tests/fixtures/mocknet-vc-v2-data-integrity-proof.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://w3id.org/security/data-integrity/v2",
"https://w3id.org/blockcerts/v3.1"
],
"id": "urn:uuid:bbba8553-8ec1-445f-82c9-a57251dd731c",
"type": [
"VerifiableCredential",
"BlockcertsCredential"
],
"issuer": "https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json",
"validFrom": "2022-07-13T20:21:40.088Z",
"validUntil": "2039-07-13T00:00:00.000Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"name": "Julien Fraichot",
"email": "[email protected]",
"publicKey": "ecdsa-koblitz-pubkey:1BPQXndcz5Uf3qZQkgnvJC87LUD5n7a2mC",
"claim": {
"name": "Master of Puppets",
"description": "Awarded to those who rock"
}
},
"metadata": "{\"classOf\":\"2021\"}",
"display": {
"contentMediaType": "text/html",
"content": "<div style=\"background-color:transparent;padding:6px;display:inline-flex;align-items:center;flex-direction:column\">Yo</div>"
},
"proof": {
"id": "urn:uuid:a68a8c11-556b-42dc-b840-55677639db7d",
"type": "DataIntegrityProof",
"cryptosuite": "merkle-proof-2019",
"proofPurpose": "assertionMethod",
"created": "2024-02-15T15:22:35.361231",
"proofValue": "zEuZQLZTYrdsDv2FbpkZtthsgpG54RGrfTSvyUNDGi1ecmJdY9KMtFSxbbs6pEspqa38GgXJD9ReRosEBrXsXKu4Nk7xMGnm6wfzuCUiwwBCXKrfs8e8r6a1gbyXbzifiJprkeVD9UtaVtdb5QXKHPRikuQR8F9epBejTF7MfQukr1T5U7mZ8nSuKXDJ5epzg6mCANdCFt8ZrYZiLUZGrWpd33BfeuyaJxSGYcfMgjzJGvLnoZpAXHi1MWpNFhxxuTn6BtUbivTJqQhgzUDoXaErWeMEe1z8wRR5TgzNaoULxGp",
"verificationMethod": "https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json#key-1"
}
}
19 changes: 19 additions & 0 deletions tests/verification/data-integrity-proof-support.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import fixture from '../fixtures/mocknet-vc-v2-data-integrity-proof.json';
import { LDMerkleProof2019 } from '../../src';

describe('given the documnet is signed following the DataIntegrityProof spec', function () {
describe('and is a valid MerkleProof2019 signature', function () {
it('should verify successfully', async function () {
const instance = new LDMerkleProof2019({
document: fixture,
proof: fixture.proof // merkle proof
});
const result = await instance.verifyProof();
expect(result).toEqual({
verified: true,
verificationMethod: null,
error: ''
});
});
});
});

0 comments on commit 1f4e9e7

Please sign in to comment.