From 9c3582bd31e5b2518f4ea16f4bc9208aab4cd5d6 Mon Sep 17 00:00:00 2001 From: Sam Hellawell Date: Mon, 25 Sep 2023 19:39:16 +0100 Subject: [PATCH 1/6] Static BBS+ cred test Signed-off-by: Sam Hellawell --- tests/data/static-bbs-cred-610.json | 42 ++++++++++++++++++++++++++++ tests/data/static-bbs-cred-630.json | 43 +++++++++++++++++++++++++++++ tests/data/static-did-dock.json | 33 ++++++++++++++++++++++ tests/unit/static-bbs.test.js | 26 +++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 tests/data/static-bbs-cred-610.json create mode 100644 tests/data/static-bbs-cred-630.json create mode 100644 tests/data/static-did-dock.json create mode 100644 tests/unit/static-bbs.test.js diff --git a/tests/data/static-bbs-cred-610.json b/tests/data/static-bbs-cred-610.json new file mode 100644 index 000000000..8a9eabb42 --- /dev/null +++ b/tests/data/static-bbs-cred-610.json @@ -0,0 +1,42 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + { + "dk": "https://ld.dock.io/credentials#", + "BasicCredential": "dk:BasicCredential", + "name": "dk:name" + } + ], + "id": "https://creds-staging.dock.io/0985a64f2910e74c48e4066fa683e4cdd9c54d021f6b83a9fd8cb56db9c460e3", + "type": [ + "VerifiableCredential", + "BasicCredential" + ], + "credentialSubject": { + "name": "basic bbs static" + }, + "issuanceDate": "2023-09-22T20:59:25.847Z", + "issuer": { + "name": "newdid", + "id": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd" + }, + "name": "basic bbs static", + "proof": { + "@context": [ + { + "sec": "https://w3id.org/security#", + "proof": { + "@id": "sec:proof", + "@type": "@id", + "@container": "@graph" + } + }, + "https://ld.dock.io/security/bbs/v1" + ], + "type": "Bls12381BBS+SignatureDock2022", + "created": "2023-09-22T20:59:55Z", + "verificationMethod": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-2", + "proofPurpose": "assertionMethod", + "proofValue": "zaEUvk9cmVeVrHueiKMKPwxtV3zab2fRiVkGmah74rFnyXbQtYBtyrGs4zmVTs2jrrWQzeHsgNjf4H1MYMqVjvQmKCfnw4PPjMXS2p8gYQiwm8XaJJwSjT94p1af1ygHrbkpjQmMafPf3gfVqRbyvULW2G" + } +} diff --git a/tests/data/static-bbs-cred-630.json b/tests/data/static-bbs-cred-630.json new file mode 100644 index 000000000..da1267a9b --- /dev/null +++ b/tests/data/static-bbs-cred-630.json @@ -0,0 +1,43 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + { + "dk": "https://ld.dock.io/credentials#", + "BasicCredential": "dk:BasicCredential", + "name": "dk:name" + } + ], + "id": "https://creds-staging.dock.io/be2b56a51e0ec8aa2ee5e92a0267a82bff6cc11a5f2275cfc8b014f3b9422a21", + "type": [ + "VerifiableCredential", + "BasicCredential" + ], + "credentialSubject": { + "id": "mysnjid", + "name": "sbj name" + }, + "issuanceDate": "2023-09-25T18:27:27.053Z", + "issuer": { + "name": "newdid", + "id": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd" + }, + "name": "static bbs plus test", + "proof": { + "@context": [ + { + "sec": "https://w3id.org/security#", + "proof": { + "@id": "sec:proof", + "@type": "@id", + "@container": "@graph" + } + }, + "https://ld.dock.io/security/bbs/v1" + ], + "type": "Bls12381BBS+SignatureDock2022", + "created": "2023-09-25T18:28:13Z", + "verificationMethod": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-2", + "proofPurpose": "assertionMethod", + "proofValue": "zToVRuY4HPCWvXjKCcNFvc3FsxYGMzjSvsfBNS41XHWuAbq9G583kqNhLueELxYCdcL5KSNSr9ABA7JopkyNhoxuB9VaLjXhsn5V7ZxEmAu4W1XpKEXMSoae9MLtRRNDdDpPusihQe7uhM9FhuAEkuBnnp" + } +} diff --git a/tests/data/static-did-dock.json b/tests/data/static-did-dock.json new file mode 100644 index 000000000..443f87978 --- /dev/null +++ b/tests/data/static-did-dock.json @@ -0,0 +1,33 @@ +{ + "@context": [ + "https://www.w3.org/ns/did/v1" + ], + "id": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd", + "controller": [ + "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd" + ], + "publicKey": [ + { + "id": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-1", + "type": "Ed25519VerificationKey2018", + "controller": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd", + "publicKeyBase58": "D74srRGhLCCWK9GEE7m1EXKtUVsAXu4DC6kZ7qPEt7JE" + }, + { + "id": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-2", + "type": "Bls12381G2VerificationKeyDock2022", + "controller": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd", + "publicKeyBase58": "zqgSKjTri2v5dvKsMi2FY1p2FFVcUd4kRGi4QxQgHyr1g9V7JH42bsvLkfZNqWvS5MhisgwToWseGvifV7TvtMZJzWAopTVrWejpviWejBA1JY8xxpqvVPAwvArrj3Dr1Ng" + } + ], + "authentication": [ + "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-1" + ], + "assertionMethod": [ + "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-1", + "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-2" + ], + "capabilityInvocation": [ + "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-1" + ] +} diff --git a/tests/unit/static-bbs.test.js b/tests/unit/static-bbs.test.js new file mode 100644 index 000000000..b8160dac4 --- /dev/null +++ b/tests/unit/static-bbs.test.js @@ -0,0 +1,26 @@ +import { verifyCredential } from '../../src/utils/vc/index'; +import defaultDocumentLoader from '../../src/utils/vc/document-loader'; +import didDocument from '../data/static-did-dock.json'; +import staticCred610 from '../data/static-bbs-cred-610.json'; + +const loadDocumentDefault = defaultDocumentLoader(null); + +describe('Testing isHexWithGivenByteSize', () => { + test('verifies BBS+ credential from SDK 6.1.0', async () => { + const result = await verifyCredential(staticCred610, { + documentLoader: async (doc) => { + if (doc.startsWith(staticCred610.issuer.id)) { + return { + contextUrl: null, + documentUrl: doc, + document: didDocument, + }; + } + + return loadDocumentDefault(doc); + }, + }); + console.error(JSON.stringify(result, null, 2)); + expect(result.verified).toBe(true); + }); +}); From 655fef51e4fa7460a90bd9c17f98790786d1740e Mon Sep 17 00:00:00 2001 From: Sam Hellawell Date: Mon, 25 Sep 2023 19:58:29 +0100 Subject: [PATCH 2/6] swap test files Signed-off-by: Sam Hellawell --- tests/data/static-bbs-cred-610.json | 15 ++++++++------- tests/data/static-bbs-cred-630.json | 15 +++++++-------- tests/unit/static-bbs.test.js | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/data/static-bbs-cred-610.json b/tests/data/static-bbs-cred-610.json index 8a9eabb42..da1267a9b 100644 --- a/tests/data/static-bbs-cred-610.json +++ b/tests/data/static-bbs-cred-610.json @@ -7,20 +7,21 @@ "name": "dk:name" } ], - "id": "https://creds-staging.dock.io/0985a64f2910e74c48e4066fa683e4cdd9c54d021f6b83a9fd8cb56db9c460e3", + "id": "https://creds-staging.dock.io/be2b56a51e0ec8aa2ee5e92a0267a82bff6cc11a5f2275cfc8b014f3b9422a21", "type": [ "VerifiableCredential", "BasicCredential" ], "credentialSubject": { - "name": "basic bbs static" + "id": "mysnjid", + "name": "sbj name" }, - "issuanceDate": "2023-09-22T20:59:25.847Z", + "issuanceDate": "2023-09-25T18:27:27.053Z", "issuer": { "name": "newdid", "id": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd" }, - "name": "basic bbs static", + "name": "static bbs plus test", "proof": { "@context": [ { @@ -34,9 +35,9 @@ "https://ld.dock.io/security/bbs/v1" ], "type": "Bls12381BBS+SignatureDock2022", - "created": "2023-09-22T20:59:55Z", + "created": "2023-09-25T18:28:13Z", "verificationMethod": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-2", "proofPurpose": "assertionMethod", - "proofValue": "zaEUvk9cmVeVrHueiKMKPwxtV3zab2fRiVkGmah74rFnyXbQtYBtyrGs4zmVTs2jrrWQzeHsgNjf4H1MYMqVjvQmKCfnw4PPjMXS2p8gYQiwm8XaJJwSjT94p1af1ygHrbkpjQmMafPf3gfVqRbyvULW2G" + "proofValue": "zToVRuY4HPCWvXjKCcNFvc3FsxYGMzjSvsfBNS41XHWuAbq9G583kqNhLueELxYCdcL5KSNSr9ABA7JopkyNhoxuB9VaLjXhsn5V7ZxEmAu4W1XpKEXMSoae9MLtRRNDdDpPusihQe7uhM9FhuAEkuBnnp" } -} +} diff --git a/tests/data/static-bbs-cred-630.json b/tests/data/static-bbs-cred-630.json index da1267a9b..8a9eabb42 100644 --- a/tests/data/static-bbs-cred-630.json +++ b/tests/data/static-bbs-cred-630.json @@ -7,21 +7,20 @@ "name": "dk:name" } ], - "id": "https://creds-staging.dock.io/be2b56a51e0ec8aa2ee5e92a0267a82bff6cc11a5f2275cfc8b014f3b9422a21", + "id": "https://creds-staging.dock.io/0985a64f2910e74c48e4066fa683e4cdd9c54d021f6b83a9fd8cb56db9c460e3", "type": [ "VerifiableCredential", "BasicCredential" ], "credentialSubject": { - "id": "mysnjid", - "name": "sbj name" + "name": "basic bbs static" }, - "issuanceDate": "2023-09-25T18:27:27.053Z", + "issuanceDate": "2023-09-22T20:59:25.847Z", "issuer": { "name": "newdid", "id": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd" }, - "name": "static bbs plus test", + "name": "basic bbs static", "proof": { "@context": [ { @@ -35,9 +34,9 @@ "https://ld.dock.io/security/bbs/v1" ], "type": "Bls12381BBS+SignatureDock2022", - "created": "2023-09-25T18:28:13Z", + "created": "2023-09-22T20:59:55Z", "verificationMethod": "did:dock:5GZn9zQTggPWijzgnoV8sZ5a74rFqC8qrz2ncp7GggeGCtKd#keys-2", "proofPurpose": "assertionMethod", - "proofValue": "zToVRuY4HPCWvXjKCcNFvc3FsxYGMzjSvsfBNS41XHWuAbq9G583kqNhLueELxYCdcL5KSNSr9ABA7JopkyNhoxuB9VaLjXhsn5V7ZxEmAu4W1XpKEXMSoae9MLtRRNDdDpPusihQe7uhM9FhuAEkuBnnp" + "proofValue": "zaEUvk9cmVeVrHueiKMKPwxtV3zab2fRiVkGmah74rFnyXbQtYBtyrGs4zmVTs2jrrWQzeHsgNjf4H1MYMqVjvQmKCfnw4PPjMXS2p8gYQiwm8XaJJwSjT94p1af1ygHrbkpjQmMafPf3gfVqRbyvULW2G" } -} +} diff --git a/tests/unit/static-bbs.test.js b/tests/unit/static-bbs.test.js index b8160dac4..8feb1abee 100644 --- a/tests/unit/static-bbs.test.js +++ b/tests/unit/static-bbs.test.js @@ -5,7 +5,7 @@ import staticCred610 from '../data/static-bbs-cred-610.json'; const loadDocumentDefault = defaultDocumentLoader(null); -describe('Testing isHexWithGivenByteSize', () => { +describe('Static BBS+ Credential Verification (backwards compatibility)', () => { test('verifies BBS+ credential from SDK 6.1.0', async () => { const result = await verifyCredential(staticCred610, { documentLoader: async (doc) => { From 9637666c4c96ce127469b48156bf695563f7df05 Mon Sep 17 00:00:00 2001 From: lovesh Date: Tue, 26 Sep 2023 20:57:17 +0530 Subject: [PATCH 3/6] Fix test Signed-off-by: lovesh --- package.json | 2 +- .../vc/crypto/common/DockCryptoSignature.js | 9 ++++- yarn.lock | 37 ++++++++++++------- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 5b5732097..1cef57a68 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ }, "dependencies": { "@digitalbazaar/vc-status-list": "^4.0.0", - "@docknetwork/crypto-wasm-ts": "^0.42.0", + "@docknetwork/crypto-wasm-ts": "0.44.0", "@docknetwork/node-types": "^0.16.0", "@juanelas/base64": "^1.0.5", "@polkadot/api": "9.7.1", diff --git a/src/utils/vc/crypto/common/DockCryptoSignature.js b/src/utils/vc/crypto/common/DockCryptoSignature.js index 4f848d252..5159a7bba 100644 --- a/src/utils/vc/crypto/common/DockCryptoSignature.js +++ b/src/utils/vc/crypto/common/DockCryptoSignature.js @@ -133,7 +133,14 @@ export default withExtendedStaticProperties( if (!credSchema) { credSchema = new CredentialSchema( CredentialSchema.essential(), - DEFAULT_PARSING_OPTS, + // Passing old parsing options and version + { + useDefaults: false, + defaultMinimumInteger: -(Math.pow(2, 32) - 1), + defaultDecimalPlaces: 0, + }, + false, + { version: '0.0.1' }, ); } diff --git a/yarn.lock b/yarn.lock index 963431b57..c15206aca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2481,10 +2481,10 @@ jsonld "^5.2.0" jsonld-signatures "^9.3.0" -"@docknetwork/crypto-wasm-ts@^0.42.0": - version "0.42.0" - resolved "https://registry.yarnpkg.com/@docknetwork/crypto-wasm-ts/-/crypto-wasm-ts-0.42.0.tgz#4edd11e315b8ed62b5d470eed9de8d7a6332117c" - integrity sha512-M5dp6WiX5OS9AzUv7TaWAU/dDg7GlWHx3e3BbvquQV1qgklDlkqpgdM2O2rWYdQMCgyAEcGwFMtD2dyF8e8xyQ== +"@docknetwork/crypto-wasm-ts@0.44.0": + version "0.44.0" + resolved "https://registry.yarnpkg.com/@docknetwork/crypto-wasm-ts/-/crypto-wasm-ts-0.44.0.tgz#38bbee2182e613111ce167362bd07bb32ca0ada5" + integrity sha512-xF53RZVWlVbngTnnOqsX6lH4U99A4TdtK/XxOonDSN4EXuGlqRD2vsqhXBne9Bk0B0ingbr9Gkp0PEk3w2DGMw== dependencies: "@docknetwork/crypto-wasm" "0.21.0" "@types/flat" "^5.0.2" @@ -2494,6 +2494,7 @@ json-pointer "^0.6.2" lodash "^4.17.21" lzutf8 "0.6.3" + semver "^7.5.4" "@docknetwork/crypto-wasm@0.21.0", "@docknetwork/crypto-wasm@^0.21.0": version "0.21.0" @@ -3979,9 +3980,9 @@ integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== "@types/flat@^5.0.2": - version "5.0.2" - resolved "https://registry.yarnpkg.com/@types/flat/-/flat-5.0.2.tgz#642a51a037d1f52fda082312b0e4566dc09a9f8f" - integrity sha512-3zsplnP2djeps5P9OyarTxwRpMLoe5Ash8aL9iprw0JxB+FAHjY+ifn4yZUuW4/9hqtnmor6uvjSRzJhiVbrEQ== + version "5.0.3" + resolved "https://registry.yarnpkg.com/@types/flat/-/flat-5.0.3.tgz#1f8045859a7e0955acf2a50e8c2979899e7b1801" + integrity sha512-uG/4x6EXYbq4VDsBJLNDHQAQmtRPg3x4tAXcBspxlnEknz8NiJxnHoxSiJKGNExiS00q4mJNvuEBgVA3jsDIdQ== "@types/fs-extra@^8.0.1": version "8.1.2" @@ -4068,9 +4069,9 @@ integrity sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA== "@types/lodash@^4.14.195": - version "4.14.197" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.197.tgz#e95c5ddcc814ec3e84c891910a01e0c8a378c54b" - integrity sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g== + version "4.14.199" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.199.tgz#c3edb5650149d847a277a8961a7ad360c474e9bf" + integrity sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg== "@types/long@^4.0.1": version "4.0.2" @@ -10643,14 +10644,15 @@ readable-stream@^3.4.0, readable-stream@^3.6.0: util-deprecate "^1.0.1" readable-stream@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-4.2.0.tgz#a7ef523d3b39e4962b0db1a1af22777b10eeca46" - integrity sha512-gJrBHsaI3lgBoGMW/jHZsQ/o/TIWiu5ENCJG1BB7fuCKzpFM8GaS2UoBVt9NO+oI+3FcrBNbUkl3ilDe09aY4A== + version "4.4.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-4.4.2.tgz#e6aced27ad3b9d726d8308515b9a1b98dc1b9d13" + integrity sha512-Lk/fICSyIhodxy1IDK2HazkeGjSmezAWX2egdtJnYhtzKEsBPJowlI6F6LPb5tqIQILrMbx22S5o3GuJavPusA== dependencies: abort-controller "^3.0.0" buffer "^6.0.3" events "^3.3.0" process "^0.11.10" + string_decoder "^1.3.0" readable-web-to-node-stream@^3.0.2: version "3.0.2" @@ -11195,6 +11197,13 @@ semver@^7.3.2, semver@^7.3.5: dependencies: lru-cache "^6.0.0" +semver@^7.5.4: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + send@0.18.0: version "0.18.0" resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" @@ -11704,7 +11713,7 @@ string.prototype.trimstart@^1.0.6: define-properties "^1.1.4" es-abstract "^1.20.4" -string_decoder@^1.1.1: +string_decoder@^1.1.1, string_decoder@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== From b8b5dfb41b6676b2595e10e999cade02f770243b Mon Sep 17 00:00:00 2001 From: Sam Hellawell Date: Tue, 26 Sep 2023 20:09:34 +0100 Subject: [PATCH 4/6] rework test Signed-off-by: Sam Hellawell --- tests/integration/anoncreds/issuing.test.js | 1 + tests/unit/static-bbs.test.js | 33 ++++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/integration/anoncreds/issuing.test.js b/tests/integration/anoncreds/issuing.test.js index ccd00fa04..afd0c8f22 100644 --- a/tests/integration/anoncreds/issuing.test.js +++ b/tests/integration/anoncreds/issuing.test.js @@ -85,6 +85,7 @@ for (const { lprNumber: 1234, }, }; + describe(`${Name} Module`, () => { const dock = new DockAPI(); const resolver = new DockResolver(dock); diff --git a/tests/unit/static-bbs.test.js b/tests/unit/static-bbs.test.js index 8feb1abee..e4fb8b30c 100644 --- a/tests/unit/static-bbs.test.js +++ b/tests/unit/static-bbs.test.js @@ -2,25 +2,36 @@ import { verifyCredential } from '../../src/utils/vc/index'; import defaultDocumentLoader from '../../src/utils/vc/document-loader'; import didDocument from '../data/static-did-dock.json'; import staticCred610 from '../data/static-bbs-cred-610.json'; +// import staticCred630 from '../data/static-bbs-cred-630.json'; // TODO: add a credential from 6.3.0 const loadDocumentDefault = defaultDocumentLoader(null); +async function documentLoader(doc) { + if (doc.startsWith(staticCred610.issuer.id)) { + return { + contextUrl: null, + documentUrl: doc, + document: didDocument, + }; + } + + return loadDocumentDefault(doc); +} + describe('Static BBS+ Credential Verification (backwards compatibility)', () => { test('verifies BBS+ credential from SDK 6.1.0', async () => { const result = await verifyCredential(staticCred610, { - documentLoader: async (doc) => { - if (doc.startsWith(staticCred610.issuer.id)) { - return { - contextUrl: null, - documentUrl: doc, - document: didDocument, - }; - } - - return loadDocumentDefault(doc); - }, + documentLoader, }); console.error(JSON.stringify(result, null, 2)); expect(result.verified).toBe(true); }); + + // test('verifies BBS+ credential from SDK 6.3.0', async () => { + // const result = await verifyCredential(staticCred630, { + // documentLoader, + // }); + // console.error(JSON.stringify(result, null, 2)); + // expect(result.verified).toBe(true); + // }); }); From 15e108779bb776ca262b4665a7577821c6f39923 Mon Sep 17 00:00:00 2001 From: Sam Hellawell Date: Tue, 26 Sep 2023 20:15:01 +0100 Subject: [PATCH 5/6] fix lint --- .eslintrc.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.json b/.eslintrc.json index d32dc7460..8d4d7dd1c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -31,6 +31,7 @@ "no-return-await": "off", "no-bitwise": ["error", { "allow": ["~"] }], "no-plusplus": "off", + "no-restricted-properties": "off", "max-len": "off", "no-console": "off", "no-else-return": "off", From bb79dc4080fef9d3a9666b0396983580a1d419cb Mon Sep 17 00:00:00 2001 From: lovesh Date: Wed, 27 Sep 2023 03:11:04 +0530 Subject: [PATCH 6/6] fix parsing options Signed-off-by: lovesh --- src/modules/did/did.js | 2 -- src/utils/vc/crypto/common/DockCryptoSignature.js | 11 ++++++++--- tests/integration/anoncreds/issuing.test.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/did/did.js b/src/modules/did/did.js index 5121b2ab5..71f17a6ae 100644 --- a/src/modules/did/did.js +++ b/src/modules/did/did.js @@ -853,7 +853,6 @@ class DIDModule { } if (this.api.query.offchainSignatures != null) { const resp = await this.api.query.offchainSignatures.publicKeys.multi(queryKeys); - let currentIter = 0; for (let r of resp) { // The gaps in `keyId` might correspond to removed keys @@ -885,7 +884,6 @@ class DIDModule { } } else { const resp = await this.api.query.bbsPlus.bbsPlusKeys.multi(queryKeys); - let currentIter = 0; for (const r of resp) { // The gaps in `keyId` might correspond to removed keys diff --git a/src/utils/vc/crypto/common/DockCryptoSignature.js b/src/utils/vc/crypto/common/DockCryptoSignature.js index 5159a7bba..45296b5fa 100644 --- a/src/utils/vc/crypto/common/DockCryptoSignature.js +++ b/src/utils/vc/crypto/common/DockCryptoSignature.js @@ -115,10 +115,15 @@ export default withExtendedStaticProperties( let credSchema; if (document.credentialSchema) { credSchema = CredentialSchema.fromJSON({ - parsingOptions: DEFAULT_PARSING_OPTS, + // Passing all the default parsing options. Ideally `document.credentialSchema` should contain these + parsingOptions: { + useDefaults: false, + defaultMinimumInteger: -((2 ** 32) - 1), + defaultMinimumDate: -((2 ** 44) - 1), + defaultDecimalPlaces: 0, + }, ...document.credentialSchema, }); - // TODO: support documentloader for schemas here so we can use dock chain schemas // requires that the presentation wrapper passes a documentloader to this method // const loadedSchema = (await documentLoader(document.credentialSchema.id)).document; @@ -136,7 +141,7 @@ export default withExtendedStaticProperties( // Passing old parsing options and version { useDefaults: false, - defaultMinimumInteger: -(Math.pow(2, 32) - 1), + defaultMinimumInteger: -((2 ** 32) - 1), defaultDecimalPlaces: 0, }, false, diff --git a/tests/integration/anoncreds/issuing.test.js b/tests/integration/anoncreds/issuing.test.js index afd0c8f22..a2e39a8ae 100644 --- a/tests/integration/anoncreds/issuing.test.js +++ b/tests/integration/anoncreds/issuing.test.js @@ -161,7 +161,7 @@ for (const { expect(resultWithSchema).toMatchObject( expect.objectContaining(getProofMatcherDoc()), ); - }, 30000); + }, 30000); test(`Can issue+verify a ${Name} credential with default schema`, async () => { const issuerKey = getKeyDoc(did1, keypair, keypair.type, keypair.id);