# 3.3 Create a Ddo

# Use cases

Perform a transaction to set the specified DidDocument as being associated with the address present inside the specified wallet.

# Tools

The Commercio SDK, our own open source tool to format transactions to Commercio.network

# Functions and APIs

  • DidDocumentHelper fromWallet;
  • IdHelper setDidDocument;
  • KeysHelper generateRsaKeyPair;

# Background

From Wikipedia:

RSA (Rivest–Shamir–Adleman) is one of the first public-key cryptosystems and is widely used for secure data transmission. Elliptic-curve cryptography (ECC) is an approach to public-key cryptography based on the algebraic structure of elliptic curves over finite fields. ECC requires smaller keys compared to non-EC cryptography (based on plain Galois fields) to provide equivalent security.

# Step by step sequence

  1. Generate the Verification RSA key;
  2. Generate the Signature RSA key;
  3. Call the DidDocumentHelper fromWallet function to create the Did Document;
  4. Finally, execute IdHelper setDidDocument function to set the Did Document.

# Code Examples

Here's an example of the implemetation in all the available languages.

# Dart

final rsaVerificationKeyPair = await KeysHelper.generateRsaKeyPair();
final rsaVerificationPubKey = rsaVerificationKeyPair.publicKey;
final rsaSignatureKeyPair =
    await KeysHelper.generateRsaKeyPair(type: 'RsaSignatureKey2018');
final rsaSignaturePubKey = rsaSignatureKeyPair.publicKey;
final didDocument =  DidDocumentHelper.fromWallet(
  wallet,
  [rsaVerificationPubKey, rsaSignaturePubKey],
);
await IdHelper.setDidDocument(didDocument, wallet);
1
2
3
4
5
6
7
8
9
10

# Kotlin

val rsaKeyPair = KeysHelper.generateRsaKeyPair()
val ecKeyPair = KeysHelper.generateEcKeyPair()
val didDocument = DidDocumentHelper.fromWallet(
  wallet,
  listOf(rsaKeyPair.public, ecKeyPair.public)
)
val fee = StdFee(gas = "200000", amount = listOf(StdCoin(denom = "ucommercio", amount = "10000")))
val response = IdHelper.setDidDocument(didDocument, wallet, fee)
1
2
3
4
5
6
7
8

# C#

var rsaKeyPair = commercio.sdk.KeysHelper.generateRsaKeyPair();
var ecKeyPair = commercio.sdk.KeysHelper.generateEcKeyPair();

var pubKeys = new List<commercio.sdk.PublicKey>();
pubKeys.Add(rsaKeyPair.publicKey);
pubKeys.Add(ecKeyPair.publicKey);

var didDocument = commercio.sdk.DidDocumentHelper.fromWallet(wallet, pubKeys);
var res = commercio.sdk.IdHelper.setDidDocument(didDocument, wallet);
1
2
3
4
5
6
7
8
9