From 5fd92b401d9b650a240b3c997d16e2506a77b687 Mon Sep 17 00:00:00 2001 From: Filip Date: Wed, 7 Feb 2024 01:43:05 +0100 Subject: [PATCH 1/2] Bump version to 0.3.0 - DidKey.create --- README.md | 4 ++-- pom.xml | 2 +- .../java/com/apicatalog/did/key/DidKey.java | 22 ++++++++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 68fe166..3b54221 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ An implementation of the [Decentralized Identifiers (DIDs) v1.0](https://www.w3. com.apicatalog carbon-did - 0.2.0 + 0.3.0 ``` @@ -32,7 +32,7 @@ An implementation of the [Decentralized Identifiers (DIDs) v1.0](https://www.w3. Android API Level >=24 ```gradle -implementation("com.apicatalog:carbon-did:0.2.0") +implementation("com.apicatalog:carbon-did:0.3.0") ``` diff --git a/pom.xml b/pom.xml index 6f00230..fe0b2bf 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.apicatalog carbon-did - 0.2.0 + 0.3.0 jar https://github.com/filip26/carbon-decentralized-identifiers diff --git a/src/main/java/com/apicatalog/did/key/DidKey.java b/src/main/java/com/apicatalog/did/key/DidKey.java index 98dcb8c..add30ac 100644 --- a/src/main/java/com/apicatalog/did/key/DidKey.java +++ b/src/main/java/com/apicatalog/did/key/DidKey.java @@ -26,12 +26,14 @@ public class DidKey extends Did { public static final String METHOD_KEY = "key"; - private final Multicodec codec; + protected final Multibase base; + protected final Multicodec codec; - private final byte[] rawKey; + protected final byte[] rawKey; - protected DidKey(Did did, Multicodec codec, byte[] rawValue) { - super(did.getMethod(), did.getVersion(), did.getMethodSpecificId()); + protected DidKey(String version, String encoded, Multibase base, Multicodec codec, byte[] rawValue) { + super(METHOD_KEY, version, encoded); + this.base = base; this.codec = codec; this.rawKey = rawValue; } @@ -65,14 +67,18 @@ public static final DidKey from(final Did did, final MultibaseDecoder bases, fin } final Multibase base = bases.getBase(did.getMethodSpecificId()).orElseThrow(() -> new IllegalArgumentException("Unsupported did:key base encoding. DID [" + did.toString() + "].")); - + final byte[] decoded = base.decode(did.getMethodSpecificId()); final Multicodec codec = codecs.getCodec(decoded).orElseThrow(() -> new IllegalArgumentException("Unsupported did:key codec. DID [" + did.toString() + "].")); final byte[] rawKey = codec.decode(decoded); - return new DidKey(did, codec, rawKey); + return new DidKey(did.getVersion(), did.getMethodSpecificId(), base, codec, rawKey); + } + + public static final DidKey create(Multibase base, Multicodec codec, byte[] rawKey) { + return new DidKey(null, base.encode(codec.encode(rawKey)), base, codec, rawKey); } public static boolean isDidKey(final Did did) { @@ -93,6 +99,10 @@ public Multicodec getCodec() { return codec; } + public Multibase getBase() { + return base; + } + public byte[] getRawKey() { return rawKey; } From e484289677fbe91d7f5ccf5bdb8801566940db9e Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 15 Feb 2024 19:52:55 +0100 Subject: [PATCH 2/2] Bump multibase to 0.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fe0b2bf..7ee9dd2 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 2.0.1 0.1.1 - 0.4.0 + 0.5.0 5.10.2