|
24 | 24 | public class DidBtc1PatchTest { |
25 | 25 |
|
26 | 26 | @Test |
27 | | - public void testPatch() throws JsonLDException, GeneralSecurityException, IOException { |
| 27 | + public void testPatch1() throws JsonLDException, GeneralSecurityException, IOException { |
28 | 28 |
|
29 | | - JsonLDObject jsonLdObject = JsonLDObject.fromJson(new InputStreamReader(Objects.requireNonNull(DidBtc1PatchTest.class.getResourceAsStream("did-btc1-patch.jsonld")))); |
| 29 | + JsonLDObject jsonLdObject = JsonLDObject.fromJson(new InputStreamReader(Objects.requireNonNull(DidBtc1PatchTest.class.getResourceAsStream("did-btc1-patch.1.jsonld")))); |
30 | 30 | jsonLdObject.setDocumentLoader(DataIntegrityContexts.DOCUMENT_LOADER); |
31 | 31 |
|
32 | | - JsonLDObject verificationMethod = JsonLDObject.fromJson(new InputStreamReader(Objects.requireNonNull(DidBtc1PatchTest.class.getResourceAsStream("did-btc1-patch.verification-method.jsonld")))); |
| 32 | + JsonLDObject verificationMethod = JsonLDObject.fromJson(new InputStreamReader(Objects.requireNonNull(DidBtc1PatchTest.class.getResourceAsStream("did-btc1-patch.verification-method.1.jsonld")))); |
| 33 | + String publicKeyMultibase = (String) verificationMethod.getJsonObject().get("publicKeyMultibase"); |
| 34 | + byte[] publicKeyBytes = Arrays.copyOfRange(Multibase.decode(publicKeyMultibase), 2, 35); |
| 35 | + ECKey publicKey = PublicKeyBytes.bytes_to_secp256k1PublicKey(publicKeyBytes); |
| 36 | + |
| 37 | + PublicKeyVerifier<?> publicKeyVerifier = PublicKeyVerifierFactory.publicKeyVerifierForKey(KeyTypeName.secp256k1, JWSAlgorithm.ES256KS, publicKey); |
| 38 | + DataIntegrityProofLdVerifier verifier = new DataIntegrityProofLdVerifier(publicKeyVerifier); |
| 39 | + boolean verify = verifier.verify(jsonLdObject); |
| 40 | + |
| 41 | + assertTrue(verify); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void testPatch2() throws JsonLDException, GeneralSecurityException, IOException { |
| 46 | + |
| 47 | + JsonLDObject jsonLdObject = JsonLDObject.fromJson(new InputStreamReader(Objects.requireNonNull(DidBtc1PatchTest.class.getResourceAsStream("did-btc1-patch.2.jsonld")))); |
| 48 | + jsonLdObject.setDocumentLoader(DataIntegrityContexts.DOCUMENT_LOADER); |
| 49 | + |
| 50 | + JsonLDObject verificationMethod = JsonLDObject.fromJson(new InputStreamReader(Objects.requireNonNull(DidBtc1PatchTest.class.getResourceAsStream("did-btc1-patch.verification-method.2.jsonld")))); |
| 51 | + String publicKeyMultibase = (String) verificationMethod.getJsonObject().get("publicKeyMultibase"); |
| 52 | + byte[] publicKeyBytes = Arrays.copyOfRange(Multibase.decode(publicKeyMultibase), 2, 35); |
| 53 | + ECKey publicKey = PublicKeyBytes.bytes_to_secp256k1PublicKey(publicKeyBytes); |
| 54 | + |
| 55 | + PublicKeyVerifier<?> publicKeyVerifier = PublicKeyVerifierFactory.publicKeyVerifierForKey(KeyTypeName.secp256k1, JWSAlgorithm.ES256KS, publicKey); |
| 56 | + DataIntegrityProofLdVerifier verifier = new DataIntegrityProofLdVerifier(publicKeyVerifier); |
| 57 | + boolean verify = verifier.verify(jsonLdObject); |
| 58 | + |
| 59 | + assertTrue(verify); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + public void testPatch3() throws JsonLDException, GeneralSecurityException, IOException { |
| 64 | + |
| 65 | + JsonLDObject jsonLdObject = JsonLDObject.fromJson(new InputStreamReader(Objects.requireNonNull(DidBtc1PatchTest.class.getResourceAsStream("did-btc1-patch.3.jsonld")))); |
| 66 | + jsonLdObject.setDocumentLoader(DataIntegrityContexts.DOCUMENT_LOADER); |
| 67 | + |
| 68 | + JsonLDObject verificationMethod = JsonLDObject.fromJson(new InputStreamReader(Objects.requireNonNull(DidBtc1PatchTest.class.getResourceAsStream("did-btc1-patch.verification-method.3.jsonld")))); |
33 | 69 | String publicKeyMultibase = (String) verificationMethod.getJsonObject().get("publicKeyMultibase"); |
34 | 70 | byte[] publicKeyBytes = Arrays.copyOfRange(Multibase.decode(publicKeyMultibase), 2, 35); |
35 | 71 | ECKey publicKey = PublicKeyBytes.bytes_to_secp256k1PublicKey(publicKeyBytes); |
|
0 commit comments