Skip to content

Commit

Permalink
Merge pull request #44 from filip26/release/v0.1.0
Browse files Browse the repository at this point in the history
Release/v0.1.0
  • Loading branch information
filip26 authored Nov 26, 2023
2 parents d8319a7 + 8744ed1 commit f627b55
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ An implementation of the [Decentralized Identifiers (DIDs) v1.0](https://www.w3.
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>carbon-did</artifactId>
<version>0.0.7</version>
<version>0.1.0</version>
</dependency>

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

```gradle
implementation("com.apicatalog:carbon-did:0.0.7")
implementation("com.apicatalog:carbon-did:0.1.0")
```


Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.apicatalog</groupId>
<artifactId>carbon-did</artifactId>

<version>0.0.7</version>
<version>0.1.0</version>
<packaging>jar</packaging>

<url>https://github.com/filip26/carbon-decentralized-identifiers</url>
Expand Down Expand Up @@ -58,8 +58,8 @@

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

<copper.multicodec.version>0.0.6</copper.multicodec.version>
<copper.multibase.version>0.0.1</copper.multibase.version>
<copper.multicodec.version>0.1.1</copper.multicodec.version>
<copper.multibase.version>0.0.2</copper.multibase.version>

<!-- test resources -->
<junit.version>5.10.1</junit.version>
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/apicatalog/did/key/DidKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
*/
public class DidKey extends Did {

private static final long serialVersionUID = 582726516478574544L;
private static final long serialVersionUID = 3710900614215756688L;

public static final String METHOD_KEY = "key";

protected static final MulticodecDecoder MULTICODEC = MulticodecDecoder.getInstance(Tag.Key);
protected static final MultibaseDecoder MULTIBASE = MultibaseDecoder.getInstance(Multibase.BASE_58_BTC);
protected static final MultibaseDecoder MULTIBASE = MultibaseDecoder.getInstance();

private final Multicodec codec;

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

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

final byte[] decoded = base.decode(did.getMethodSpecificId());

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

Expand Down
7 changes: 0 additions & 7 deletions src/main/java/com/apicatalog/did/key/DidKeyResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ public DidDocument resolve(final Did did) {
* @return The new verification key
*/
public static DidVerificationMethod createSignatureMethod(DidKey didKey) {

// if (!Multicodec.Codec.Ed25519PublicKey.equals(didKey.getCodec())) {
// throw new IllegalArgumentException();
// }
// 5.
// String encodingType = ED25519_VERIFICATION_KEY_2020_TYPE;

return new DidVerificationMethod(
DidUrl.from(didKey, null, null, didKey.getMethodSpecificId()),
DidUrl.from(didKey, null, null, didKey.getMethodSpecificId()),
Expand Down
36 changes: 18 additions & 18 deletions src/test/java/com/apicatalog/did/DidKeyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.junit.jupiter.params.provider.MethodSource;

import com.apicatalog.did.key.DidKey;
import com.apicatalog.multicodec.MulticodecRegistry;
import com.apicatalog.multicodec.codec.KeyCodec;

@DisplayName("DID Key")
@TestMethodOrder(OrderAnnotation.class)
Expand Down Expand Up @@ -54,77 +54,77 @@ static Stream<DidKeyTestCase> testVectors() {
static final DidKeyTestCase testCases[] = new DidKeyTestCase[] {
DidKeyTestCase.create(
"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH",
MulticodecRegistry.ED25519_PUBLIC_KEY,
KeyCodec.ED25519_PUBLIC_KEY,
32
),
DidKeyTestCase.create(
"did:key:z6MkiTBz1ymuepAQ4HEHYSF1H8quG5GLVVQR3djdX3mDooWp",
MulticodecRegistry.ED25519_PUBLIC_KEY,
KeyCodec.ED25519_PUBLIC_KEY,
32
),
DidKeyTestCase.create(
"did:key:z6MkjchhfUsD6mmvni8mCdXHw216Xrm9bQe2mBH1P5RDjVJG",
MulticodecRegistry.ED25519_PUBLIC_KEY,
KeyCodec.ED25519_PUBLIC_KEY,
32
),
DidKeyTestCase.create(
"did:key:z6MknGc3ocHs3zdPiJbnaaqDi58NGb4pk1Sp9WxWufuXSdxf",
MulticodecRegistry.ED25519_PUBLIC_KEY,
KeyCodec.ED25519_PUBLIC_KEY,
32
),
DidKeyTestCase.create(
"did:key:z6MkicdicToW5HbxPP7zZV1H7RHvXgRMhoujWAF2n5WQkdd2",
MulticodecRegistry.ED25519_PUBLIC_KEY,
KeyCodec.ED25519_PUBLIC_KEY,
32
),
DidKeyTestCase.create(
"did:key:z6MkiVQTYk3L2XKY6yg6MyeN2QLE5QkKcXByUeY1dkdiLx4j",
MulticodecRegistry.ED25519_PUBLIC_KEY,
KeyCodec.ED25519_PUBLIC_KEY,
32
),
DidKeyTestCase.create(
"did:key:zQ3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme",
MulticodecRegistry.SECP256K1_PUBLIC_KEY,
KeyCodec.SECP256K1_PUBLIC_KEY,
33
),
DidKeyTestCase.create(
"did:key:zQ3shtxV1FrJfhqE1dvxYRcCknWNjHc3c5X1y3ZSoPDi2aur2",
MulticodecRegistry.SECP256K1_PUBLIC_KEY,
KeyCodec.SECP256K1_PUBLIC_KEY,
33
),
DidKeyTestCase.create(
"did:key:zQ3shZc2QzApp2oymGvQbzP8eKheVshBHbU4ZYjeXqwSKEn6N",
MulticodecRegistry.SECP256K1_PUBLIC_KEY,
KeyCodec.SECP256K1_PUBLIC_KEY,
33
),
DidKeyTestCase.create(
"did:key:zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169",
MulticodecRegistry.P256_PUBLIC_KEY,
KeyCodec.P256_PUBLIC_KEY,
33
),
DidKeyTestCase.create(
"did:key:zDnaerx9CtbPJ1q36T5Ln5wYt3MQYeGRG5ehnPAmxcf5mDZpv",
MulticodecRegistry.P256_PUBLIC_KEY,
KeyCodec.P256_PUBLIC_KEY,
33
),
DidKeyTestCase.create(
"did:key:z82Lm1MpAkeJcix9K8TMiLd5NMAhnwkjjCBeWHXyu3U4oT2MVJJKXkcVBgjGhnLBn2Kaau9",
MulticodecRegistry.P384_PUBLIC_KEY,
KeyCodec.P384_PUBLIC_KEY,
49
),
DidKeyTestCase.create(
"did:key:z82LkvCwHNreneWpsgPEbV3gu1C6NFJEBg4srfJ5gdxEsMGRJUz2sG9FE42shbn2xkZJh54",
MulticodecRegistry.P384_PUBLIC_KEY,
KeyCodec.P384_PUBLIC_KEY,
49
),
DidKeyTestCase.create(
"did:key:z2J9gaYxrKVpdoG9A4gRnmpnRCcxU6agDtFVVBVdn1JedouoZN7SzcyREXXzWgt3gGiwpoHq7K68X4m32D8HgzG8wv3sY5j7",
MulticodecRegistry.P521_PUBLIC_KEY,
KeyCodec.P521_PUBLIC_KEY,
67
),
DidKeyTestCase.create(
"did:key:z2J9gcGdb2nEyMDmzQYv2QZQcM1vXktvy1Pw4MduSWxGabLZ9XESSWLQgbuPhwnXN7zP7HpTzWqrMTzaY5zWe6hpzJ2jnw4f",
MulticodecRegistry.P521_PUBLIC_KEY,
KeyCodec.P521_PUBLIC_KEY,
67
),

Expand All @@ -136,13 +136,13 @@ static Stream<DidKeyTestCase> testVectors() {
// versioned keys
DidKeyTestCase.create(
"did:key:1.1:z6MkicdicToW5HbxPP7zZV1H7RHvXgRMhoujWAF2n5WQkdd2",
MulticodecRegistry.ED25519_PUBLIC_KEY,
KeyCodec.ED25519_PUBLIC_KEY,
32,
"1.1"
),
DidKeyTestCase.create(
"did:key:0.7:z6MkicdicToW5HbxPP7zZV1H7RHvXgRMhoujWAF2n5WQkdd2",
MulticodecRegistry.ED25519_PUBLIC_KEY,
KeyCodec.ED25519_PUBLIC_KEY,
32,
"0.7"
),
Expand Down

0 comments on commit f627b55

Please sign in to comment.