Hashverse Messaging Protocol (HMP)
We have implemented and defined a protocol based on Protobuf serialization for a secure communication and interaction mechanism for Hedera accounts. In order to send and receive data on Hashgraph network we are using HCS.
We define topics subscriptions as channels where users can send and receive HashverseMessage payloads. See protobufs definitions for more details. All submitted
messages are encrypted and can only be decrypted for the audience the message is intended for.
You will be using Mirror Node REST APIs for querying information about accounts, transactions or other entities. For all account related operations such as token transfer, channel subscription, etc. you will be using gRPC calls to Hedera.
========
Version 0.0.1 - 2022-02-28
Account Creation
Hedera Mainnet accounts can only be created by an existing Mainnet accounts, since you dont have this in the beginning Hashverse provides you an app that communicates using HMP and passes you credentials of a temporary Mainnet account, then using that you can go ahead and create your own mainnet account. All of this happens automatically in the app for you so you don't have to do anything!
Steps needed in account creation
- Test account is created for the user using a default account we ship with our wallet.
- We subscribe to the
Hashverse Mainnet Account CreatorhApp. - After an
ACKmessage is sent to theHashverse Mainnet Account Creatoraccount ID, user will receive the account id and seed phrase for Mainnet created account. - We will ask user if they want to import this account to Hashverse wallet and switch to it.
- (Optionally) If user wants more security they can go ahead and create a new Mainnet account with this existing one.
Sending Request for subscription
All messages need to be carried on HCS topics. But before that accounts need to agree on which topic they want to communicate on. To do this an account can send a subscription request message and let the other account know which topic they are going to send information.
This request needs to be done by a HBAR transfer to the designated account. See here.
The memo for this transfer will be a payload of type SubscriptionRequestMessage defined in HMP. See here.
A channel can be used for different purposes.
- Only among two accounts
- Group chat
- Broadcasting
All of the messages submitted on topics are encrypted based on the audience they are targeted for. Topic message submission restriction is imposed by submitKey assigned to the topic while creating it. This can be a shared key among the accounts that are allowed to submit messages on this topic.
Flow of the subscription
- Hbar Transaction with
SubscriptionRequestMessagein memo as payload. - (Optionally) Send a
ChannelMessagewith type ofCHANNEL_SECRETwith accounts that can submit messages. Each of these messages are encrypted with public key of the receiver account. This is the only message that is encrypted with Public Key of the receiver, all other messages must be encrypted and signed with the submit key. - If the receiver accepts the request, subscribes to the topic and sends back an
ACKmessage.
Receiving Request for Subscription
All the latest transactions are fetched using mirror node API. By polling data regularly from this API, wallet can make sure we fetch latest transcations and process SubscriptionRequestMessage in the memo if there exists any.
If any parsable message exists then we should show the user request and ask if they want to subscribe to the requested channel.
Note that a user can subscribe to a channel without a request. This can be done using a QR code or entering the account ID of the hApp in Hashverse Wallet.
HashverseMessage
A HashverseMessage is sent over a private or public topic over HCS. This message contains public and encrypted fields. See here for more details about the message format.
MessageType can be of the following types:
AUTHORIZETEXTFILECHANNEL_SECRETACKAUTHORIZATION_REQUESTINFORMATION_REQUESTDOCUMENT_REQUESTPAYMENT_REQUEST
Authorizing apps (AUTHORIZATION_REQUEST)
This message type can have 2 purposes:
- When user wants to login to an application, for instamce on Hashverse Marketplace
- User filled in a form on an application wants submit it securely.
User will respond with a message of type AUTHORIZE if they agree with action. This usually comes with extra piece of information to match with the credible source.