Skip to content

Commit

Permalink
Merge pull request #118 from filip26/patch/10-improvements
Browse files Browse the repository at this point in the history
0.10.0
  • Loading branch information
filip26 authored Feb 12, 2024
2 parents 80df529 + 95c10a4 commit bbaddd3
Show file tree
Hide file tree
Showing 23 changed files with 192 additions and 373 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ An implementation of the [Verifiable Credentials](https://www.w3.org/TR/vc-data-
* Signature Suites
* [Data Integrity 1.0 Proofs](https://w3c-ccg.github.io/data-integrity-spec/)
* [ECDSA-2019](https://github.com/filip26/iron-ecdsa-cryptosuite-2019)
* [EdDSA-2022](https://github.com/filip26/iron-eddsa-cryptosuite-2022)
* [EdDSA-RDFC-2022](https://github.com/filip26/iron-eddsa-rdfc-cryptosuite-2022)
* [ECDSA-SD-2023](https://github.com/filip26/iron-ecdsa-sd-cryptosuite-2023) (planned)
* [BBS-2023](https://github.com/filip26/iron-bbs-cryptosuite-2023) (planned)
* [Ed25519Signature2020](https://github.com/filip26/iron-ed25519-cryptosuite-2020)
Expand All @@ -39,7 +39,7 @@ Java 17+
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>iron-verifiable-credentials</artifactId>
<version>0.8.1</version>
<version>0.10.0</version>
</dependency>

```
Expand All @@ -48,7 +48,7 @@ Java 17+
Android 12+ (API Level >=31)

```gradle
compile group: 'com.apicatalog', name: 'iron-verifiable-credentials-jre8', version: '0.8.1'
compile group: 'com.apicatalog', name: 'iron-verifiable-credentials-jre8', version: '0.10.0'
```

## Documentation
Expand Down
90 changes: 47 additions & 43 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.apicatalog</groupId>
<artifactId>iron</artifactId>
<version>0.10.0-SNAPSHOT</version>
<relativePath>pom_parent.xml</relativePath>
</parent>

<artifactId>iron-verifiable-credentials</artifactId>
<packaging>jar</packaging>

<name>Iron Verifiable Credentials (JRE17)</name>

<url>https://github.com/filip26/iron-verifiable-credentials</url>

<scm>
<connection>scm:git:git://github.com/filip26/iron-verifiable-credentials.git</connection>
<developerConnection>scm:git:git://github.com/filip26/iron-verifiable-credentials.git</developerConnection>
<url>https://github.com/filip26/iron-verifiable-credentials/tree/main</url>
</scm>

<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<envSources>src/main/java17</envSources>
<rdf-urdna.version>1.1</rdf-urdna.version>
</properties>

<dependencies>
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>titanium-json-ld</artifactId>
<version>${titanium.version}</version>
</dependency>
<dependency>
<groupId>io.setl</groupId>
<artifactId>rdf-urdna</artifactId>
<version>${rdf-urdna.version}</version>
</dependency>
</dependencies>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.apicatalog</groupId>
<artifactId>iron</artifactId>
<version>0.10.0</version>
<relativePath>pom_parent.xml</relativePath>
</parent>

<artifactId>iron-verifiable-credentials</artifactId>
<packaging>jar</packaging>

<name>Iron Verifiable Credentials (JRE17)</name>

<url>https://github.com/filip26/iron-verifiable-credentials</url>

<scm>
<connection>
scm:git:git://github.com/filip26/iron-verifiable-credentials.git</connection>
<developerConnection>
scm:git:git://github.com/filip26/iron-verifiable-credentials.git</developerConnection>
<url>https://github.com/filip26/iron-verifiable-credentials/tree/main</url>
</scm>

<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<envSources>src/main/java17</envSources>
<rdf-urdna.version>1.1</rdf-urdna.version>
</properties>

<dependencies>
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>titanium-json-ld</artifactId>
<version>${titanium.version}</version>
</dependency>
<dependency>
<groupId>io.setl</groupId>
<artifactId>rdf-urdna</artifactId>
<version>${rdf-urdna.version}</version>
</dependency>
</dependencies>
</project>
88 changes: 45 additions & 43 deletions pom_jre8.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.apicatalog</groupId>
<artifactId>iron</artifactId>
<version>0.10.0-SNAPSHOT</version>
<relativePath>pom_parent.xml</relativePath>
</parent>

<artifactId>iron-verifiable-credentials-jre8</artifactId>
<packaging>jar</packaging>

<name>Iron Verifiable Credentials (JRE8)</name>

<url>https://github.com/filip26/iron-verifiable-credentials</url>

<scm>
<connection>scm:git:git://github.com/filip26/iron-verifiable-credentials.git</connection>
<developerConnection>scm:git:git://github.com/filip26/iron-verifiable-credentials.git</developerConnection>
<url>https://github.com/filip26/iron-verifiable-credentials/tree/main</url>
</scm>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<envSources>src/main/java8</envSources>
<rdf-urdna.version>1.2</rdf-urdna.version>
</properties>

<dependencies>
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>titanium-json-ld-jre8</artifactId>
<version>${titanium.version}</version>
</dependency>
<dependency>
<groupId>io.setl</groupId>
<artifactId>rdf-urdna</artifactId>
<version>${rdf-urdna.version}</version>
</dependency>
</dependencies>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.apicatalog</groupId>
<artifactId>iron</artifactId>
<version>0.10.0</version>
<relativePath>pom_parent.xml</relativePath>
</parent>

<artifactId>iron-verifiable-credentials-jre8</artifactId>
<packaging>jar</packaging>

<name>Iron Verifiable Credentials (JRE8)</name>

<url>https://github.com/filip26/iron-verifiable-credentials</url>

<scm>
<connection>scm:git:git://github.com/filip26/iron-verifiable-credentials.git</connection>
<developerConnection>scm:git:git://github.com/filip26/iron-verifiable-credentials.git</developerConnection>
<url>https://github.com/filip26/iron-verifiable-credentials/tree/main</url>
</scm>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<envSources>src/main/java8</envSources>
<rdf-urdna.version>1.2</rdf-urdna.version>
</properties>

<dependencies>
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>titanium-json-ld-jre8</artifactId>
<version>${titanium.version}</version>
</dependency>
<dependency>
<groupId>io.setl</groupId>
<artifactId>rdf-urdna</artifactId>
<version>${rdf-urdna.version}</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion pom_parent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.apicatalog</groupId>
<artifactId>iron</artifactId>
<version>0.10.0-SNAPSHOT</version>
<version>0.10.0</version>
<packaging>pom</packaging>

<name>Iron Verifiable Credentials</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/apicatalog/ld/node/LdNodeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public JsonObject build() {
}

public void id(URI id) {
builder.add(Keywords.ID, id.toASCIIString());
builder.add(Keywords.ID, id.toString());
}
}
27 changes: 17 additions & 10 deletions src/main/java/com/apicatalog/ld/node/LdSetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.apicatalog.jsonld.lang.Keywords;
import com.apicatalog.ld.Term;
import com.apicatalog.ld.adapter.LdAdapter;
import com.apicatalog.multibase.Multibase;
import com.apicatalog.vc.VcVocab;

import jakarta.json.Json;
Expand Down Expand Up @@ -53,20 +54,26 @@ public <T> void map(LdAdapter<T> adapter, T value) {
}
}

JsonArray setOrAdd(JsonValue value) {
if (content != null) {
return Json.createArrayBuilder(content).add(value).build();
}
return Json.createArrayBuilder().add(value).build();
}

public void xsdDateTime(Instant created) {
scalar(VcVocab.XSD_DATETIME.uri(), created.toString());
}

public void multibase(Multibase base, byte[] value) {
scalar(VcVocab.MULTIBASE_TYPE.uri(), base.encode(value));
}

public void id(URI id) {
JsonObjectBuilder node = Json.createObjectBuilder();
node.add(Keywords.ID, id != null ? Json.createValue(id.toASCIIString()) : JsonValue.NULL);
value(node.build());
if (id != null) {
JsonObjectBuilder node = Json.createObjectBuilder();
node.add(Keywords.ID, Json.createValue(id.toString()));
value(node.build());
}
}

JsonArray setOrAdd(JsonValue value) {
if (content != null) {
return Json.createArrayBuilder(content).add(value).build();
}
return Json.createArrayBuilder().add(value).build();
}
}
15 changes: 14 additions & 1 deletion src/main/java/com/apicatalog/ld/signature/CryptoSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
public class CryptoSuite implements CanonicalizationAlgorithm, DigestAlgorithm, SignatureAlgorithm {

protected final String id;
protected final CanonicalizationAlgorithm canonicalization;
protected final DigestAlgorithm digester;
protected final SignatureAlgorithm signer;
Expand All @@ -26,11 +27,19 @@ public CryptoSuite(
final CanonicalizationAlgorithm canonicalization,
final DigestAlgorithm digester,
final SignatureAlgorithm signer) {
this(null, canonicalization, digester, signer);
}

public CryptoSuite(
final String id,
final CanonicalizationAlgorithm canonicalization,
final DigestAlgorithm digester,
final SignatureAlgorithm signer) {
this.id = id;
this.canonicalization = canonicalization;
this.digester = digester;
this.signer = signer;
}

@Override
public void verify(byte[] publicKey, byte[] signature, byte[] data) throws VerificationError {
signer.verify(publicKey, signature, data);
Expand All @@ -55,4 +64,8 @@ public byte[] canonicalize(JsonStructure document) throws LinkedDataSuiteError {
public KeyPair keygen() throws KeyGenError {
return signer.keygen();
}

public String id() {
return id;
}
}
40 changes: 0 additions & 40 deletions src/main/java/com/apicatalog/ld/signature/key/MulticodecKey.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public MessageDigest(final String type) {
}

@Override
public byte[] digest(byte[] data) throws LinkedDataSuiteError {
public byte[] digest(final byte[] data) throws LinkedDataSuiteError {

try {
java.security.MessageDigest digest = java.security.MessageDigest.getInstance(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@
public class Urdna2015 implements CanonicalizationAlgorithm {

@Override
public byte[] canonicalize(JsonStructure document) throws LinkedDataSuiteError {
public byte[] canonicalize(final JsonStructure document) throws LinkedDataSuiteError {
try {
RdfDataset dataset = JsonLd.toRdf(JsonDocument.of(document)).get();
final RdfDataset dataset = JsonLd.toRdf(JsonDocument.of(document)).get();

RdfDataset canonical = RdfNormalize.normalize(dataset);
final RdfDataset canonical = RdfNormalize.normalize(dataset);

StringWriter writer = new StringWriter();
final StringWriter writer = new StringWriter();

RdfWriter rdfWriter = Rdf.createWriter(MediaType.N_QUADS, writer);
final RdfWriter rdfWriter = Rdf.createWriter(MediaType.N_QUADS, writer);

rdfWriter.write(canonical);

return writer.toString()
.getBytes(StandardCharsets.UTF_8);
return writer.toString().getBytes(StandardCharsets.UTF_8);

} catch (JsonLdError | UnsupportedContentException | IOException | RdfWriterException e) {
throw new LinkedDataSuiteError(Code.Canonicalization, e);
Expand Down
Loading

0 comments on commit bbaddd3

Please sign in to comment.