# Implementations

The following official reference implementations are available:

* C#/.NET
  * [Source code (GitHub)](https://github.com/shifteverywhere/dime-dotnet-ref)
  * [Nuget package](https://www.nuget.org/packages/DiME/)
* JAVA
  * [Source code (GitHub)](https://github.com/shifteverywhere/dime-java-ref)
  * [Maven artifact](https://search.maven.org/artifact/io.dimeformat/dime-java-ref/1.2.1/jar)

Apart from reference implementation of the DiME data format, there is also an early implementation of a command-line tool to help in generating DiME items. This tool may be used to generate keys and identities for trust trees, or just to assist working with DiME items in general.

* [DiME Command-line tool](https://github.com/shifteverywhere/dime-tool)

### Code examples

The following code examples are provided in C#.

#### Creating an Identity Issuing Request

In order to include an entity in a trust chain, the entity must first create a public-key pair and an Identity Issuing Request (IIR):

```csharp
var key = Key.Generate(KeyCapability.Sign);
var caps = new List<IdentityCapability> { IdentityCapability.Generic, IdentityCapability.Identify };
var iir = IdentityIssuingRequest.Generate(key, caps);
```

Here a public-key pair and a list of capabilities to be requested are created. These are then used to create the IIR. The IIR then needs to be sent to the issuing entity for the creation of a new Identity item. Note that the secret (private) key inside **key** should never leave the entity where it was generated.

#### Issuing a new Identity item from an IIR

Once an IIR is received from an entity a new Identity item should be generated and issued. This Identity item should be sent back to the requesting entity and later used for authentication purposes, much like a X.509 certificate.

```csharp
var subjectId = Guid.NewGuid();
var allowedCaps = new List<IdentityCapability> { IdentityCapability.Generic, IdentityCapability.Identify };
var identity = iir.Issue(subjectId, Dime.ValidFor1Year, rootKey, rootIdentity, true, caps);
```

The **iir** in the above example would be the Identity Issuing Request received from a requesting entity. The variables **rootKey** and **rootIdentity** are the public keypair and Identity item of the issuing entity. The resulting **identity** contains no sensitive information and may be communicated publicly to be used as part of the authentication of the owning entity.

... more code examples to follow ...


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dimeformat.io/implementations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
