AIP 4: Basic Encrypted Messages Source

Author Dmitriy Soloduhin, Aleksei Lebedev
Discussions-To https://github.com/Adamant-im/AIPs/issues/7
Status Accepted
Type Standards
Category ARC
Created 2018-06-09
Requires 10

Structure of basic encrypted messages in ADAMANT.

Simple Summary

Describing current structure of basic encrypted ADAMANT messages, so that extensions or alternative clients can rely on it.

Abstract

To standartize message exchange between different ADAMANT clients we need to describe how messages are stored and encrypted/decrypted.

Specification

Secure Message exchange is the base of ADAMANT messaging system.

Messages are encrypted using curve25519xsalsa20poly1305 (NaCl box) algorithm. Box is created using sender’s private key and recipient’s public key. Recipient’s public key is retrieved from network.

Private and public keys of account are instances of Ed25519 signing keys, so they should be converted into Curve25519 Diffie-Hellman keys first.

Syntax

Transaction syntax is based on AIP-10: General transaction structure. Messaging blockchain transaction type is 8.

Here is transaction asset contents syntax:

chat: {
  message: HEXIFIED_ENCRYPTED_MESSAGE
  own_message: HEXIFIED_NONCE
  type: 1
}

Value of chat type is 1 for basic encrypted message. For other types of messages should be described in future APIs.

Examples

{
  "transaction": {
    "type": 8,
    "amount": 0,
    "senderId": "U15677078342684640219",
    "senderPublicKey": "e16e624fd0a5123294b448c21f30a07...",
    "asset": {
      "chat": {
        "message": "4bf88eb80f4710e5aec4...",
        "own_message": "9dded63b476e75a146e3f...",
        "type": 1
      }
    },
    "recipientId": "U7972131227889954319",
    "timestamp": 46115307,
    "signature": "aa468db9b70b731931308f7c7d0d1..."
  }
}

Sends message to U7972131227889954319.

{
  "transaction": {
    "type": 8,
    "amount": 49000000,
    "senderId": "U15677078342684640219",
    "senderPublicKey": "e16e624fd0a5123294b448c21f30a07...",
    "asset": {
      "chat": {
        "message": "4bf88eb80f4710e5aec4...",
        "own_message": "9dded63b476e75a146e3f...",
        "type": 1
      }
    },
    "recipientId": "U7972131227889954319",
    "timestamp": 46115307,
    "signature": "aa468db9b70b731931308f7c7d0d1..."
  }
}

Transfer of 0.49 ADM to U7972131227889954319 with comment.

Rationale

Currently used mechanisms should also be documented, to make process of extending and updating clearer.

Copyright and related rights waived via CC0.