Messaging

From Open Transactions
Jump to navigation Jump to search

Open Transactions is agnostic to transport. Meaning that libOTLib.a, the actual library (containing the bulk of the code), includes no transport code at all.

The OTMessage class, which OT uses for all of its messaging, simply serializes itself into string form, and then you can transport that string using whatever form of transport you wish. (OT operates on Request / Response model.) See this article on the OTX protocol.

The OT Server, Test Client, and API were written using the OT Library. These pieces do implement transport, via a callback function. The current callback is implemented using the ZeroMQ Library

Each OTMessage is encrypted in an OTEnvelope, to the public key located in the server contract, after which only the server can open it.

When messaging the transaction server, a new user includes his public key in the message so that the server can verify his signature and also so it can encrypt its response to him.

If you look at the below “Check Server ID” message, you can see that the user has included his public key:

-----BEGIN SIGNED MESSAGE-----
Hash: SAMY

<?xml version="1.0"?>

<OTmessage
 version="1.0">

<checkServerID
 nymID="Bg2QrSTomOEU5ICfvhfYfBYxQZPktDSnaVPpMLYxUnz"
 serverID="44FmyPAgrmGu671RywGnhrt8aR6tzmNFn9WKQ92BXn">

<nymPublicKey>
- -----BEGIN PUBLIC KEY-----
LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlHZk1BMEdDU3FHU0liM0RRRUJB
UVVBQTRHTkFEQ0JpUUtCZ1FEZThQMTg3aWkvanpuZ3Z6QmV1QisvYTJXMApQUFNK
NVd0TTFJdTdMWEc1REp2Ly80ekJuUVJqQzd5TXd4Q3VwdFJwZ2JyTHpNbTdmYklF
cXNFMDgvQW41OGtUCjYxK0JXRHpyUjBaVnZBeDNncUdtUXEybWtsZVpsb2FvdXE4
UXRwZHJoVEQwM2VxRDk5cVBRMHdRTWdHRy8rMFAKOEhsVHJtOGY1VFFtVkVuVHVR
SURBUUFCCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
- -----END PUBLIC KEY-----
</nymPublicKey>

</checkServerID>

</OTmessage>
-----BEGIN MESSAGE SIGNATURE-----
Version: Open Transactions 0.40
Comment: http://github.com/FellowTraveler/Open-Transactions/wiki

y0c9qAp9xS7f9/r9HokY70ajoAO92/LhNXvDOqg1Td0TtsvndNX4+rfahat+w2Y5
fbFn9ZAZkFUOqjNE4zPwazRSm93W0SIj1rCyOjWkCYfSFLsGm+YS5oMwRColAqu1
FmdO3SSTMVzLnUGpt4BKGPSct0xr48Rh0l5o6Za0XDI=
-----END MESSAGE SIGNATURE-----

The user registers his public key so that it can be stored on the server side. He might register with many different keys, depending on his level of paranoia. He might also go “cash only” and therefore not register at all, but this isn’t necessary for untraceability (only for anonymity), since even the pseudonymous accounts are unlinkable when you use cash.

Your public key is a pseudonym. You will see the words “User ID” and “Nym ID” and “Nym” and “pseudonym” used interchangeably in OT. They all mean the same thing: a public key, or an ID used to look it up.

Below is an example of an OTMessage where the user is requesting a copy of his inbox. Notice this message does not include a public key; once you have registered a public key with the server, it does not have to be passed back and forth anymore. Below, the message only includes the Nym ID this time, instead of the entire public key. The server will use the ID to look up the key, and then verify the signature on the message. Only messages signed by the appropriate key will be processed.

-----BEGIN SIGNED MESSAGE-----
Hash: SAMY

<?xml version="1.0"?>

<OTmessage
 version="1.0">

<getInbox
 nymID="Bg2QrSTomOEU5ICfvhfYfBYxQZPktDSnaVPpMLYxUnz"
 serverID="44FmyPAgrmGu671RywGnhrt8aR6tzmNFn9WKQ92BXn"
 accountID="PhmhKernutijMa2XXxH1dZnTluIDQUVn1tifSOq9H4x"
 requestNum="269" >

</getInbox>

</OTmessage>
-----BEGIN MESSAGE SIGNATURE-----
Version: Open Transactions 0.40
Comment: http://github.com/FellowTraveler/Open-Transactions/wiki

mu6uLNV/OVL42bZbuD5lfUQLKfUcsLqyfy5dGfjPiQ3hzuhge4RXqzs1t0wnuS2F
AarWXdxO5+wlu5ZUW/7uJj0IP5dMJcxjWYh/ZBRDInBTH8zXbg6ZvPp+0Ia4nJOx
dsvwNyizqbSnidI5knjaJmusknFWA4r3Cp00fvZQWHg=
-----END MESSAGE SIGNATURE-----

Notice a few things:

  1. The above message includes the ServerID. Why? To prevent the message being intercepted and sent to a different server, since the signature itself will verify.
  2. Notice also that the message above includes a “Request Number”. This number must increment with each message. Why? To prevent the message being intercepted and sent multiple times. Once a message has been used once, it can never work again, since the request number is now invalid.

If you send a "getInbox" request, the server replies with "@getInbox". Here is that reply:

-----BEGIN SIGNED MESSAGE-----
Hash: SAMY

<?xml version="1.0"?>

<OTmessage
 version="1.0">

<@getInbox
 success="true"
 nymID="Bg2QrSTomOEU5ICfvhfYfBYxQZPktDSnaVPpMLYxUnz"
 serverID="44FmyPAgrmGu671RywGnhrt8aR6tzmNFn9WKQ92BXn"
 accountID="PhmhKernutijMa2XXxH1dZnTluIDQUVn1tifSOq9H4x" >

<inboxLedger>
eJx1UslyGjEQzXm+YoorhUf7QsWuAoMJXnDYTOAmqSUYswyBAUy+PiKkKskhukjd
6uW97lerxdNsd7q9dNjt9Nqt9Lnd6rQHF3ct+WL2i3o6bLxMk+Szca44bMpnD3O/
S49+t8+LzW0F36BKkpbnrb+t5BtbfETrd2i3Fb8lM8Ig67k0ygRnVbyo9cggcIpj
hR0OgghhGShMERc+cMuDVoRbAdpTTj3CjHkHilrDNHUekWAlaMcw4cZZ4M54J50N
QhuGnQSwkgaprQ0RzWHvdxcoErALQXAjg7fGmYjKmksgCI4o8UIQ5OMTB4a1wJZY
Tw1wLkBpDCzELpaTyE1JhyQYjYMFpxkCowQnTDsrPLLUiOAlCBGEpUF5qxnX2HKo
JBHI8YqFOccAOIop5sJEAooVkEcaTIiNgwOsNKUYIiUkQ6SEsQcltJDgMXE6BGCe
OgISAQJpEIkoPVEoEAg4QECcM8qVUCy6bJCWSmBEawMCfCW9iyvN/tnpXVL7o4ar
DH6JojEaD9pXQbxdt15PX7d+k452ZrM3royefYpuGErui/Xab8p6uijLbT3L5nm5
ONgbV6yzB79aFaeYcvQrv8suBWp/F8hO+TJPEvSl2s37s/OoaBSzZqe7P+Xs+zZn
s37HnXqPclGEsDyf9dtq3pnMqos+bayXIrQWM9IcHc7LZMwnjU6+YtkLmQn5bT2Y
PVQnyxV1Wf+o1U4Mz0/3LcdaTdT+Kp+Mqr7mfvremzbmp+Fb88d9QnjT4edpedjY
5UbNRsV8MP7QzU6m9h9sPXl/OBzL7PHVynx8e51Yu9f6z7ySTz8BFP0Cpw==
</inboxLedger>

</@getInbox>

</OTmessage>
-----BEGIN MESSAGE SIGNATURE-----
Version: Open Transactions 0.40
Comment: http://github.com/FellowTraveler/Open-Transactions/wiki

3Ly510ofsMjiaWZiid/5ekmfVHWbWmHZpY9u4T5QVViqCusw8NhGAZFDshrWtUWc
CFJ+H1uFiS91kreHeqb9Qp7difWL4lBgxNn4I8pP0dKJmkUiS5R9dLAFonJMBZfg
ybwAEUX6WxVYLEZpDxLFqojXgVP+nPrUcf9LVu89rHg=
-----END MESSAGE SIGNATURE-----

As you can see, my inbox is attached to the above server reply. (In base64-encoded form.) Decoding it reveals it to be empty:

-----BEGIN SIGNED LEDGER-----
Hash: SAMY

<accountLedger version="1.0"
 type="inbox"
 accountID="PhmhKernutijMa2XXxH1dZnTluIDQUVn1tifSOq9H4x"
 userID="Bg2QrSTomOEU5ICfvhfYfBYxQZPktDSnaVPpMLYxUnz"
serverID="44FmyPAgrmGu671RywGnhrt8aR6tzmNFn9WKQ92BXn" >

</accountLedger>
-----BEGIN LEDGER SIGNATURE-----
Version: Open Transactions 0.40
Comment: http://github.com/FellowTraveler/Open-Transactions/wiki

0H+IiQZyToAoZBGIswi4qpi4ZQGcwNJ7hoffkyy9VlgGWZ+hQ3Amk6fDhZ2BTuyk
U5WAGil4/M2Z67XmRZF+Wkl3c/Qv98r6SyKCDc4DB0EP7Ka8+OieYjNYAgwSVBzC
25Bc1LYtunbkn8ZTogRUx9BG/8sx4mWjFuvt/JOb7iU=
-----END LEDGER SIGNATURE-----

What about messages that involve transactions? Click here to read about transaction-specific messages on OT.