Home

Awesome

DIDComm JVM

License Unit Tests

Basic DIDComm v2 support in Java/Kotlin and Android.

Installation

Available from Maven Central.

Gradle:

dependencies {
  implementation 'org.didcommx:didcomm:0.3.0'
}

Maven:

<dependency>
  <groupId>org.didcommx</groupId>
  <artifactId>didcomm</artifactId>
  <version>0.3.0</version>
</dependency>

DIDComm + peerdid Demo

See https://github.com/sicpa-dlab/didcomm-demo.

Assumptions and Limitations

Examples

See demo scripts for details:

A general usage of the API is the following:

1. Build an Encrypted DIDComm message for the given recipient

This is the most common DIDComm message to be used in most of the applications.

A DIDComm encrypted message is an encrypted JWM (JSON Web Messages) that

It is important in privacy-preserving routing. It is what normally moves over network transports in DIDComm applications, and is the safest format for storing DIDComm data at rest.

See packEncrypted documentation for more details.

Authentication encryption example (most common case):

val didComm = DIDComm(DIDDocResolverMock(), SecretResolverMock())

// ALICE
val message = Message.builder(
    id = "1234567890",
    body = mapOf("messagespecificattribute" to "and its value"),
    type = "http://example.com/protocols/lets_do_lunch/1.0/proposal"
)
    .from(ALICE_DID)
    .to(listOf(BOB_DID))
    .createdTime(1516269022)
    .expiresTime(1516385931)
    .build()
val packResult = didComm.packEncrypted(
    PackEncryptedParams.builder(message, BOB_DID)
        .from(JWM.ALICE_DID)
        .build()
)
println("Sending ${packResult.packedMessage} to ${packResult.serviceMetadata?.serviceEndpoint ?: ""}")

// BOB
val unpackResult = didComm.unpack(
    UnpackParams.Builder(packResult.packedMessage).build()
)
println("Got ${unpackResult.message} message")

Anonymous encryption example:

val didComm = DIDComm(DIDDocResolverMock(), SecretResolverMock())
val message = Message.builder(
    id = "1234567890",
    body = mapOf("messagespecificattribute" to "and its value"),
    type = "http://example.com/protocols/lets_do_lunch/1.0/proposal"
)
    .to(listOf(BOB_DID))
    .createdTime(1516269022)
    .expiresTime(1516385931)
    .build()
val packResult = didComm.packEncrypted(
    PackEncryptedParams.builder(message, BOB_DID).build()
)
)

Encryption with non-repudiation example:

val didComm = DIDComm(DIDDocResolverMock(), SecretResolverMock())
val message = Message.builder(
    id = "1234567890",
    body = mapOf("messagespecificattribute" to "and its value"),
    type = "http://example.com/protocols/lets_do_lunch/1.0/proposal"
)
    .from(ALICE_DID)
    .to(listOf(BOB_DID))
    .createdTime(1516269022)
    .expiresTime(1516385931)
    .build()
val packResult = didComm.packEncrypted(
    PackEncryptedParams.builder(message, BOB_DID)
        .signFrom(ALICE_DID)
        .from(ALICE_DID)
        .build()
)

2. Build an unencrypted but Signed DIDComm message

Signed messages are only necessary when

Adding a signature when one is not needed can degrade rather than enhance security because it relinquishes the sender’s ability to speak off the record.

See packSigned documentation for more details.

val didComm = DIDComm(DIDDocResolverMock(), SecretResolverMock())

// ALICE
val message = Message.builder(
    id = "1234567890",
    body = mapOf("messagespecificattribute" to "and its value"),
    type = "http://example.com/protocols/lets_do_lunch/1.0/proposal"
)
    .from(ALICE_DID)
    .to(listOf(BOB_DID))
    .createdTime(1516269022)
    .expiresTime(1516385931)
    .build()
val packResult = didComm.packSigned(
    PackSignedParams.builder(message, ALICE_DID).build()
)
println("Publishing ${packResult.packedMessage}")

// BOB
val unpackResult = didComm.unpack(
    UnpackParams.Builder(packResult.packedMessage).build()
)
println("Got ${unpackResult.message} message")

3. Build a Plaintext DIDComm message

A DIDComm message in its plaintext form that

They are therefore not normally transported across security boundaries.

val didComm = DIDComm(DIDDocResolverMock(), SecretResolverMock())

// ALICE
val message = Message.builder(
    id = "1234567890",
    body = mapOf("messagespecificattribute" to "and its value"),
    type = "http://example.com/protocols/lets_do_lunch/1.0/proposal"
)
    .from(ALICE_DID)
    .to(listOf(BOB_DID))
    .createdTime(1516269022)
    .expiresTime(1516385931)
    .build()
val packResult = didComm.packPlaintext(
    PackPlaintextParams.builder(message)
        .build()
)
println("Publishing ${packResult.packedMessage}")

// BOB
val unpackResult = didComm.unpack(
    UnpackParams.Builder(packResult.packedMessage).build()
)
println("Got ${unpackResult.message} message")

Contribution

PRs are welcome!

The following CI checks are run against every PR: