Skip to content

Commit f627b55

Browse files
authored
Merge pull request #44 from filip26/release/v0.1.0
Release/v0.1.0
2 parents d8319a7 + 8744ed1 commit f627b55

File tree

5 files changed

+28
-33
lines changed

5 files changed

+28
-33
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ An implementation of the [Decentralized Identifiers (DIDs) v1.0](https://www.w3.
2121
<dependency>
2222
<groupId>com.apicatalog</groupId>
2323
<artifactId>carbon-did</artifactId>
24-
<version>0.0.7</version>
24+
<version>0.1.0</version>
2525
</dependency>
2626

2727
```
@@ -30,7 +30,7 @@ An implementation of the [Decentralized Identifiers (DIDs) v1.0](https://www.w3.
3030
Android API Level >=24
3131

3232
```gradle
33-
implementation("com.apicatalog:carbon-did:0.0.7")
33+
implementation("com.apicatalog:carbon-did:0.1.0")
3434
```
3535

3636

pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.apicatalog</groupId>
88
<artifactId>carbon-did</artifactId>
99

10-
<version>0.0.7</version>
10+
<version>0.1.0</version>
1111
<packaging>jar</packaging>
1212

1313
<url>https://github.com/filip26/carbon-decentralized-identifiers</url>
@@ -58,8 +58,8 @@
5858

5959
<jakarta.json.version>2.0.1</jakarta.json.version>
6060

61-
<copper.multicodec.version>0.0.6</copper.multicodec.version>
62-
<copper.multibase.version>0.0.1</copper.multibase.version>
61+
<copper.multicodec.version>0.1.1</copper.multicodec.version>
62+
<copper.multibase.version>0.0.2</copper.multibase.version>
6363

6464
<!-- test resources -->
6565
<junit.version>5.10.1</junit.version>

src/main/java/com/apicatalog/did/key/DidKey.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
*/
2424
public class DidKey extends Did {
2525

26-
private static final long serialVersionUID = 582726516478574544L;
26+
private static final long serialVersionUID = 3710900614215756688L;
2727

2828
public static final String METHOD_KEY = "key";
2929

3030
protected static final MulticodecDecoder MULTICODEC = MulticodecDecoder.getInstance(Tag.Key);
31-
protected static final MultibaseDecoder MULTIBASE = MultibaseDecoder.getInstance(Multibase.BASE_58_BTC);
31+
protected static final MultibaseDecoder MULTIBASE = MultibaseDecoder.getInstance();
3232

3333
private final Multicodec codec;
3434

@@ -68,7 +68,9 @@ public static final DidKey from(final Did did) {
6868
throw new IllegalArgumentException("The given DID method [" + did.getMethod() + "] is not 'key'. DID [" + did.toString() + "].");
6969
}
7070

71-
final byte[] decoded = MULTIBASE.decode(did.getMethodSpecificId());
71+
final Multibase base = MULTIBASE.getBase(did.getMethodSpecificId()).orElseThrow(() -> new IllegalArgumentException("Cannot detect did:key base encoding."));
72+
73+
final byte[] decoded = base.decode(did.getMethodSpecificId());
7274

7375
final Multicodec codec = MULTICODEC.getCodec(decoded).orElseThrow(() -> new IllegalArgumentException("Cannot detect did:key codec."));
7476

src/main/java/com/apicatalog/did/key/DidKeyResolver.java

-7
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ public DidDocument resolve(final Did did) {
4848
* @return The new verification key
4949
*/
5050
public static DidVerificationMethod createSignatureMethod(DidKey didKey) {
51-
52-
// if (!Multicodec.Codec.Ed25519PublicKey.equals(didKey.getCodec())) {
53-
// throw new IllegalArgumentException();
54-
// }
55-
// 5.
56-
// String encodingType = ED25519_VERIFICATION_KEY_2020_TYPE;
57-
5851
return new DidVerificationMethod(
5952
DidUrl.from(didKey, null, null, didKey.getMethodSpecificId()),
6053
DidUrl.from(didKey, null, null, didKey.getMethodSpecificId()),

src/test/java/com/apicatalog/did/DidKeyTest.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.junit.jupiter.params.provider.MethodSource;
1515

1616
import com.apicatalog.did.key.DidKey;
17-
import com.apicatalog.multicodec.MulticodecRegistry;
17+
import com.apicatalog.multicodec.codec.KeyCodec;
1818

1919
@DisplayName("DID Key")
2020
@TestMethodOrder(OrderAnnotation.class)
@@ -54,77 +54,77 @@ static Stream<DidKeyTestCase> testVectors() {
5454
static final DidKeyTestCase testCases[] = new DidKeyTestCase[] {
5555
DidKeyTestCase.create(
5656
"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH",
57-
MulticodecRegistry.ED25519_PUBLIC_KEY,
57+
KeyCodec.ED25519_PUBLIC_KEY,
5858
32
5959
),
6060
DidKeyTestCase.create(
6161
"did:key:z6MkiTBz1ymuepAQ4HEHYSF1H8quG5GLVVQR3djdX3mDooWp",
62-
MulticodecRegistry.ED25519_PUBLIC_KEY,
62+
KeyCodec.ED25519_PUBLIC_KEY,
6363
32
6464
),
6565
DidKeyTestCase.create(
6666
"did:key:z6MkjchhfUsD6mmvni8mCdXHw216Xrm9bQe2mBH1P5RDjVJG",
67-
MulticodecRegistry.ED25519_PUBLIC_KEY,
67+
KeyCodec.ED25519_PUBLIC_KEY,
6868
32
6969
),
7070
DidKeyTestCase.create(
7171
"did:key:z6MknGc3ocHs3zdPiJbnaaqDi58NGb4pk1Sp9WxWufuXSdxf",
72-
MulticodecRegistry.ED25519_PUBLIC_KEY,
72+
KeyCodec.ED25519_PUBLIC_KEY,
7373
32
7474
),
7575
DidKeyTestCase.create(
7676
"did:key:z6MkicdicToW5HbxPP7zZV1H7RHvXgRMhoujWAF2n5WQkdd2",
77-
MulticodecRegistry.ED25519_PUBLIC_KEY,
77+
KeyCodec.ED25519_PUBLIC_KEY,
7878
32
7979
),
8080
DidKeyTestCase.create(
8181
"did:key:z6MkiVQTYk3L2XKY6yg6MyeN2QLE5QkKcXByUeY1dkdiLx4j",
82-
MulticodecRegistry.ED25519_PUBLIC_KEY,
82+
KeyCodec.ED25519_PUBLIC_KEY,
8383
32
8484
),
8585
DidKeyTestCase.create(
8686
"did:key:zQ3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme",
87-
MulticodecRegistry.SECP256K1_PUBLIC_KEY,
87+
KeyCodec.SECP256K1_PUBLIC_KEY,
8888
33
8989
),
9090
DidKeyTestCase.create(
9191
"did:key:zQ3shtxV1FrJfhqE1dvxYRcCknWNjHc3c5X1y3ZSoPDi2aur2",
92-
MulticodecRegistry.SECP256K1_PUBLIC_KEY,
92+
KeyCodec.SECP256K1_PUBLIC_KEY,
9393
33
9494
),
9595
DidKeyTestCase.create(
9696
"did:key:zQ3shZc2QzApp2oymGvQbzP8eKheVshBHbU4ZYjeXqwSKEn6N",
97-
MulticodecRegistry.SECP256K1_PUBLIC_KEY,
97+
KeyCodec.SECP256K1_PUBLIC_KEY,
9898
33
9999
),
100100
DidKeyTestCase.create(
101101
"did:key:zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169",
102-
MulticodecRegistry.P256_PUBLIC_KEY,
102+
KeyCodec.P256_PUBLIC_KEY,
103103
33
104104
),
105105
DidKeyTestCase.create(
106106
"did:key:zDnaerx9CtbPJ1q36T5Ln5wYt3MQYeGRG5ehnPAmxcf5mDZpv",
107-
MulticodecRegistry.P256_PUBLIC_KEY,
107+
KeyCodec.P256_PUBLIC_KEY,
108108
33
109109
),
110110
DidKeyTestCase.create(
111111
"did:key:z82Lm1MpAkeJcix9K8TMiLd5NMAhnwkjjCBeWHXyu3U4oT2MVJJKXkcVBgjGhnLBn2Kaau9",
112-
MulticodecRegistry.P384_PUBLIC_KEY,
112+
KeyCodec.P384_PUBLIC_KEY,
113113
49
114114
),
115115
DidKeyTestCase.create(
116116
"did:key:z82LkvCwHNreneWpsgPEbV3gu1C6NFJEBg4srfJ5gdxEsMGRJUz2sG9FE42shbn2xkZJh54",
117-
MulticodecRegistry.P384_PUBLIC_KEY,
117+
KeyCodec.P384_PUBLIC_KEY,
118118
49
119119
),
120120
DidKeyTestCase.create(
121121
"did:key:z2J9gaYxrKVpdoG9A4gRnmpnRCcxU6agDtFVVBVdn1JedouoZN7SzcyREXXzWgt3gGiwpoHq7K68X4m32D8HgzG8wv3sY5j7",
122-
MulticodecRegistry.P521_PUBLIC_KEY,
122+
KeyCodec.P521_PUBLIC_KEY,
123123
67
124124
),
125125
DidKeyTestCase.create(
126126
"did:key:z2J9gcGdb2nEyMDmzQYv2QZQcM1vXktvy1Pw4MduSWxGabLZ9XESSWLQgbuPhwnXN7zP7HpTzWqrMTzaY5zWe6hpzJ2jnw4f",
127-
MulticodecRegistry.P521_PUBLIC_KEY,
127+
KeyCodec.P521_PUBLIC_KEY,
128128
67
129129
),
130130

@@ -136,13 +136,13 @@ static Stream<DidKeyTestCase> testVectors() {
136136
// versioned keys
137137
DidKeyTestCase.create(
138138
"did:key:1.1:z6MkicdicToW5HbxPP7zZV1H7RHvXgRMhoujWAF2n5WQkdd2",
139-
MulticodecRegistry.ED25519_PUBLIC_KEY,
139+
KeyCodec.ED25519_PUBLIC_KEY,
140140
32,
141141
"1.1"
142142
),
143143
DidKeyTestCase.create(
144144
"did:key:0.7:z6MkicdicToW5HbxPP7zZV1H7RHvXgRMhoujWAF2n5WQkdd2",
145-
MulticodecRegistry.ED25519_PUBLIC_KEY,
145+
KeyCodec.ED25519_PUBLIC_KEY,
146146
32,
147147
"0.7"
148148
),

0 commit comments

Comments
 (0)