From 5941a9ab4ec3d31b836edd735661cdc00322d8ca Mon Sep 17 00:00:00 2001 From: "Andy Miller (IMS)" <48326098+amiller-ims@users.noreply.github.com> Date: Thu, 15 Sep 2022 13:06:35 -0700 Subject: [PATCH] Update ob30 samples --- .../inspect/vc/probe/EmbeddedProofProbe.java | 18 ++-- .../org/oneedtech/inspect/vc/OB30Tests.java | 16 +++- .../org/oneedtech/inspect/vc/Samples.java | 3 +- .../ob30/simple-err-proof-method.json | 54 ++++++++++++ .../ob30/simple-err-proof-value.json | 54 ++++++++++++ .../test/resources/ob30/simple-err-proof.json | 36 -------- .../src/test/resources/ob30/simple-json.png | Bin 83704 -> 84440 bytes .../src/test/resources/ob30/simple-json.svg | 82 +++++++++++------- .../src/test/resources/ob30/simple-jwt.png | Bin 84446 -> 85229 bytes .../src/test/resources/ob30/simple-jwt.svg | 2 +- .../src/test/resources/ob30/simple.json | 26 +++++- 11 files changed, 210 insertions(+), 81 deletions(-) create mode 100644 inspector-vc/src/test/resources/ob30/simple-err-proof-method.json create mode 100644 inspector-vc/src/test/resources/ob30/simple-err-proof-value.json delete mode 100644 inspector-vc/src/test/resources/ob30/simple-err-proof.json diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/EmbeddedProofProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/EmbeddedProofProbe.java index cafea8a..554a0cf 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/EmbeddedProofProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/EmbeddedProofProbe.java @@ -66,7 +66,7 @@ public class EmbeddedProofProbe extends Probe { if (didScheme.startsWith("key:")) { publicKeyMultibase = didScheme.substring(4); } else { - return fatal("Unknown verification method: " + method.toString(), ctx); + return error("Unknown verification method: " + method.toString(), ctx); } } else { publicKeyMultibase = method.toString(); @@ -74,9 +74,14 @@ public class EmbeddedProofProbe extends Probe { } // Decode the Multibase to Multicodec and check that it is an Ed25519 public key - byte[] publicKeyMulticodec = Multibase.decode(publicKeyMultibase); - if (publicKeyMulticodec[0] != -19 || publicKeyMulticodec[1] != 1) { - return fatal("Verification method does not contain an Ed25519 public key", ctx); + byte[] publicKeyMulticodec; + try { + publicKeyMulticodec = Multibase.decode(publicKeyMultibase); + if (publicKeyMulticodec[0] != -19 || publicKeyMulticodec[1] != 1) { + return error("Verification method does not contain an Ed25519 public key", ctx); + } + } catch (Exception e) { + return error("Verification method is invalid: " + e.getMessage(), ctx); } // Extract the publicKey bytes from the Multicodec @@ -90,7 +95,10 @@ public class EmbeddedProofProbe extends Probe { // if [publicKeyMultibase] -- don't check issuer ID. Maybe we should warn about this syntax. try { - verifier.verify(vc); + boolean verify = verifier.verify(vc); + if (!verify) { + return error("Embedded proof verification failed.", ctx); + } } catch (Exception e) { return fatal("Embedded proof verification failed:" + e.getMessage(), ctx); } diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java index 4417dc2..0be0215 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java @@ -89,10 +89,22 @@ public class OB30Tests { } @Test - void testSimpleJsonInvalidProof() { + void testSimpleJsonInvalidProofMethod() { //add some garbage chars to proofValue assertDoesNotThrow(()->{ - Report report = validator.run(Samples.OB30.JSON.SIMPLE_JSON_PROOF_ERROR.asFileResource()); + Report report = validator.run(Samples.OB30.JSON.SIMPLE_JSON_PROOF_METHOD_ERROR.asFileResource()); + if(verbose) PrintHelper.print(report, true); + assertInvalid(report); + assertErrorCount(report, 1); + assertHasProbeID(report, EmbeddedProofProbe.ID, true); + }); + } + + @Test + void testSimpleJsonInvalidProofValue() { + //add some garbage chars to proofValue + assertDoesNotThrow(()->{ + Report report = validator.run(Samples.OB30.JSON.SIMPLE_JSON_PROOF_VALUE_ERROR.asFileResource()); if(verbose) PrintHelper.print(report, true); assertInvalid(report); assertErrorCount(report, 1); diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java index 5ba1f27..3c10f32 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java @@ -13,7 +13,8 @@ public class Samples { public final static Sample SIMPLE_JSON = new Sample("ob30/simple.json", true); public final static Sample SIMPLE_JSON_NOPROOF = new Sample("ob30/simple-noproof.json", false); public final static Sample SIMPLE_JSON_UNKNOWN_TYPE = new Sample("ob30/simple-err-type.json", false); - public final static Sample SIMPLE_JSON_PROOF_ERROR = new Sample("ob30/simple-err-proof.json", false); + public final static Sample SIMPLE_JSON_PROOF_METHOD_ERROR = new Sample("ob30/simple-err-proof-method.json", false); + public final static Sample SIMPLE_JSON_PROOF_VALUE_ERROR = new Sample("ob30/simple-err-proof-value.json", false); public final static Sample SIMPLE_JSON_EXPIRED = new Sample("ob30/simple-err-expired.json", false); public final static Sample SIMPLE_JSON_ISSUED = new Sample("ob30/simple-err-issued.json", false); public final static Sample SIMPLE_JSON_ISSUER = new Sample("ob30/simple-err-issuer.json", false); diff --git a/inspector-vc/src/test/resources/ob30/simple-err-proof-method.json b/inspector-vc/src/test/resources/ob30/simple-err-proof-method.json new file mode 100644 index 0000000..037a10c --- /dev/null +++ b/inspector-vc/src/test/resources/ob30/simple-err-proof-method.json @@ -0,0 +1,54 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://purl.imsglobal.org/spec/ob/v3p0/context.json", + "https://purl.imsglobal.org/spec/ob/v3p0/extensions.json", + "https://w3id.org/security/suites/ed25519-2020/v1" + ], + "id": "http://example.edu/credentials/3732", + "type": [ + "VerifiableCredential", + "OpenBadgeCredential" + ], + "issuer": { + "id": "https://example.edu/issuers/565049", + "type": [ + "Profile" + ], + "name": "Example University" + }, + "issuanceDate": "2010-01-01T00:00:00Z", + "name": "Example University Degree", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "type": [ + "AchievementSubject" + ], + "achievement": { + "id": "https://example.com/achievements/21st-century-skills/teamwork", + "type": [ + "Achievement" + ], + "criteria": { + "narrative": "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management." + }, + "description": "This badge recognizes the development of the capacity to collaborate within a group environment.", + "name": "Teamwork" + } + }, + "credentialSchema": [ + { + "id": "https://purl.imsglobal.org/spec/ob/v3p0/schema/json/ob_v3p0_achievementcredential_schema.json", + "type": "1EdTechJsonSchemaValidator2019" + } + ], + "proof": [ + { + "type": "Ed25519Signature2020", + "created": "2022-09-15T15:48:32Z", + "verificationMethod": "https://example.edu/issuers/565049#xxMkmY1R6tG2NEdRHzphdRT6JqxeYpHwLAHwbrDfQULpkMAj", + "proofPurpose": "assertionMethod", + "proofValue": "z3yUuWbFsLUp2CUrSZRaRbTk1UnkhpoJgJYu1SdMqd3AEMotpY41sKky7VzavnSfjApggtWJg1tcREvs5H4ZNnBRH" + } + ] +} \ No newline at end of file diff --git a/inspector-vc/src/test/resources/ob30/simple-err-proof-value.json b/inspector-vc/src/test/resources/ob30/simple-err-proof-value.json new file mode 100644 index 0000000..d26f49d --- /dev/null +++ b/inspector-vc/src/test/resources/ob30/simple-err-proof-value.json @@ -0,0 +1,54 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://purl.imsglobal.org/spec/ob/v3p0/context.json", + "https://purl.imsglobal.org/spec/ob/v3p0/extensions.json", + "https://w3id.org/security/suites/ed25519-2020/v1" + ], + "id": "http://example.edu/credentials/3732", + "type": [ + "VerifiableCredential", + "OpenBadgeCredential" + ], + "issuer": { + "id": "https://example.edu/issuers/565049", + "type": [ + "Profile" + ], + "name": "Example University" + }, + "issuanceDate": "2010-01-01T00:00:00Z", + "name": "Example University Degree", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "type": [ + "AchievementSubject" + ], + "achievement": { + "id": "https://example.com/achievements/21st-century-skills/teamwork", + "type": [ + "Achievement" + ], + "criteria": { + "narrative": "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management." + }, + "description": "This badge recognizes the development of the capacity to collaborate within a group environment.", + "name": "Teamwork" + } + }, + "credentialSchema": [ + { + "id": "https://purl.imsglobal.org/spec/ob/v3p0/schema/json/ob_v3p0_achievementcredential_schema.json", + "type": "1EdTechJsonSchemaValidator2019" + } + ], + "proof": [ + { + "type": "Ed25519Signature2020", + "created": "2022-09-15T15:48:32Z", + "verificationMethod": "https://example.edu/issuers/565049#z6MkmY1R6tG2NEdRHzphdRT6JqxeYpHwLAHwbrDfQULpkMAj", + "proofPurpose": "assertionMethod", + "proofValue": "z3fQCWGpz7b1HSH6DTwYiH5vutqtpJb5SHiP1VFK22xeBEW2D61tC9j3SktwPLNxPnTNZnPt4GeAZJPdVYserRqs4" + } + ] +} \ No newline at end of file diff --git a/inspector-vc/src/test/resources/ob30/simple-err-proof.json b/inspector-vc/src/test/resources/ob30/simple-err-proof.json deleted file mode 100644 index f749e52..0000000 --- a/inspector-vc/src/test/resources/ob30/simple-err-proof.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://imsglobal.github.io/openbadges-specification/context.json", - "https://w3id.org/security/suites/ed25519-2020/v1" - ], - "id": "http://example.edu/credentials/3732", - "type": [ - "VerifiableCredential", - "OpenBadgeCredential" - ], - "issuer": { - "id": "https://example.edu/issuers/565049", - "type": [ - "Profile" - ], - "name": "Example University" - }, - "issuanceDate": "2010-01-01T00:00:00Z", - "name": "Example University Degree", - "credentialSubject": { - "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", - "type": [ - "AchievementSubject" - ] - }, - "proof": [ - { - "type": "Ed25519Signature2020", - "created": "2022-06-28T16:28:36Z", - "verificationMethod": "did:key:z6MkkUD3J14nkYzn46QeuaVSnp7dF85QJKwKvJvfsjx79aXj", - "proofPurpose": "assertionMethod", - "proofValue": "XXXz3MUt2ZuU8Byqivxh6GphEM65AFYyNaGYibm97xLTafM7uGufZQLKvJR8itZwxKskvtFM3CUty46v26DZidMNoQnMXXX" - } - ] -} \ No newline at end of file diff --git a/inspector-vc/src/test/resources/ob30/simple-json.png b/inspector-vc/src/test/resources/ob30/simple-json.png index f13d2447a0ec9fcc5314ac7d7bedcec723b3b560..ee80f0abe5cd18f2f1bd5ea03294aac9c481500d 100644 GIT binary patch delta 976 zcmah{O>fgM7$!*LFbTmGA%qDx#G0l1fE5n(BU>r!B+_FoaTcizkd8Y&-?iO`)TRd=cNzdj32e@H~wTlYX-T` zhaxVKLUuDGZ7bN@ihl3c%Ui zCBjl0aw*K(HYP zn5IN9n!haNX=?ph63IM+BIv^0ncfR`rY|tkPY8@Veu$Gi$656GM-~hO<(5OGxU5*# zRZ}7h7VB6}8P)T3l+V}E!WdlY9nGMnW2r-#Cw1}trtP3E_QRIGoEh7PF+or)98_cy@DZ#op-J8iN@e{Z{k2y`!&5@I(v<;wRa!?0mG*`IRF3v delta 282 zcmcaHne|66Yr_`Ct4>TTywk5cF=pyy<`$>tNO=%r_tWRxc9W#;SW7o_GTC8ngO z7V8!lq$X#kWhN( diff --git a/inspector-vc/src/test/resources/ob30/simple-jwt.png b/inspector-vc/src/test/resources/ob30/simple-jwt.png index 84a9ab2fa642d0a39d8779b00ce66e1bfbd1505f..7211f537e503ddc95bb54385ce149393f943284f 100644 GIT binary patch delta 1819 zcmY+DyN>&~6~;5W*d|4a^eOTH8|Y$tMnD?N7Ihh2#*{^hZ2l{ewk4aoj4fLi1aOd7 zNHNJvY_-Am`wl_6yg{nGK%kIEnq%3ip8yvz>r~D_xljqSBO(38y#)3B!ifZ%S=d#JXr9B_c~ zVaR~j1ZrU+V7?&${Y<4j)P%Res9{^~LdUz1YDlOxQ@4qDhq!$UYf#`VETjOJq-L;7 zse=-tW!hlp8tbApjqs_9k`yW&c{hqXk?YjtxESsf6aiNtqP2I8u%KJ3>B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I}hX&6=O}xL zZ0tHibo002?2%&Tt0+Om7(?dvG+w7oP`^*$uwLPad?kDI8`u>znlym+$L-w@Ia_WnS2KZa)+24F&EtZeS}M)%qpXb{6jp#0{x% zrth-tfPQ+=yzMZ*k;~;Nf#$=siIpzMF5A86>MYBxjVqU@yITlQC(cQj=U0x`FAp&( zl`Ulh09@~=u@QSdc(f-E*Q0h=$nSxFYyo%otHu&uvsvk>wmxpJ!kekQY - + diff --git a/inspector-vc/src/test/resources/ob30/simple.json b/inspector-vc/src/test/resources/ob30/simple.json index 33c21a0..6c48673 100644 --- a/inspector-vc/src/test/resources/ob30/simple.json +++ b/inspector-vc/src/test/resources/ob30/simple.json @@ -2,6 +2,7 @@ "@context": [ "https://www.w3.org/2018/credentials/v1", "https://purl.imsglobal.org/spec/ob/v3p0/context.json", + "https://purl.imsglobal.org/spec/ob/v3p0/extensions.json", "https://w3id.org/security/suites/ed25519-2020/v1" ], "id": "http://example.edu/credentials/3732", @@ -22,15 +23,32 @@ "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", "type": [ "AchievementSubject" - ] + ], + "achievement": { + "id": "https://example.com/achievements/21st-century-skills/teamwork", + "type": [ + "Achievement" + ], + "criteria": { + "narrative": "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management." + }, + "description": "This badge recognizes the development of the capacity to collaborate within a group environment.", + "name": "Teamwork" + } }, + "credentialSchema": [ + { + "id": "https://purl.imsglobal.org/spec/ob/v3p0/schema/json/ob_v3p0_achievementcredential_schema.json", + "type": "1EdTechJsonSchemaValidator2019" + } + ], "proof": [ { "type": "Ed25519Signature2020", - "created": "2022-06-28T16:28:36Z", - "verificationMethod": "https://example.edu/issuers/565049#z6MkkUD3J14nkYzn46QeuaVSnp7dF85QJKwKvJvfsjx79aXj", + "created": "2022-09-15T15:48:32Z", + "verificationMethod": "https://example.edu/issuers/565049#z6MkmY1R6tG2NEdRHzphdRT6JqxeYpHwLAHwbrDfQULpkMAj", "proofPurpose": "assertionMethod", - "proofValue": "z3MUt2ZuU8Byqivxh6GphEM65AFYyNaGYibm97xLTafM7uGufZQLKvJR8itZwxKskvtFM3CUty46v26DZidMNoQnM" + "proofValue": "z3yUuWbFsLUp2CUrSZRaRbTk1UnkhpoJgJYu1SdMqd3AEMotpY41sKky7VzavnSfjApggtWJg1tcREvs5H4ZNnBRH" } ] } \ No newline at end of file