Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Proposal for Ricardian Contracts in Open Bazaar

0

Ricardian Contracts in OpenBazaar

What is a Ricardian Contract

A Ricardian Contract can be defined as a single document that is a) a contract offered by an issuer to holders, b) for a valuable right held by holders, and managed by the issuer, c) easily readable by people (like a contract on paper), d) readable by programs (parsable like a database), e) digitally signed, f) carries the keys and server information, and g) allied with a unique and secure identifier.
- Ian Grigg

The Ricardian contract is a means of tracking the liability of one party to another when selling goods to each other in OpenBazaar. Fundamentally, a contract represents a single unit of a good or service. Ricardian contracts should be used in OpenBazaar as they are means of effectively tracking legitimately signed agreements between two parties, which cannot be forged after the contract has been signed.

Ricardian contracts make use of a chain of digitally signed and checksum hashed contracts to create an unalterable record of agreement for an exchange on a peer-to-peer network.

Digital signatures = Proof of agreement (when you sign, you agree to the terms)
Hashes = Proof of authenticity (the smallest possible change in the contract alters the hash, indicating the contract has been altered)

Issuing a Contract: Structure

The contract is saved as an XML file, with the SHA1 hash of the file as part of the file name. Within the XML file, the contract contains the following structure:

1. Contract terms
	- Seller's nym
	- Contract nonce (unique identifier)
	- Seller's bitcoin pubkey (for multisig transactions)
	- Merchant Data
		- What is to be sold
		- Price per unit
		- Additional conditional detail unforseen in this proposal
	- Contract expiration date
	- Seller's PGP public key
2. All of the above is digitally signed with the seller's private PGP key

Example:

Alice wants to sell a 16 pound watermelon. She creates the contract below, signs it with her nym key (her private PGP key) and distributes/seeds it on the OpenBazaar network.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

<?xml version="1.0"?>

<!-- Seller's NYM -->
        <nym_id> ALICE-NYM-ID-HASH </nym_id>

<!-- Contract Nonce -->
	<contract_nonce> XXXX-YYYY-123456 </contract_nonce>

<!-- Bitcoin Pubkey -->
	<btc_addr> 03d728ad6757d4784effea04d47baafa216cf474866c2d4dc99b1e8e3eb936e730 </btc_addr>

<!-- Merchant Data -->
	<asset_name> 16 Pound Watermelon </asset_name>
	<asset_price> 0.01 BTC </asset_price>

<!-- Contract Expiration Date -->
	<contract_exp> YYYY-MM-DD TIME UTC </contract_exp>
	
<!-- Seller's PGP Key -->
<PGP_Public_Key>
- -----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG v1.47

mQINBFMZcEIBEADJlq0oVgLfFDdW9WOBguskPdSSeAfHe4s9w8QlmRuO/Zj548gK
fofbM84rtP3rHSOSkeOTsu5GwDt48V/md6gyJ69BTZJkJ6qmxFtGaWVRLP/UD4ma
vW4EAn3PvWY6X7Z8x36U3j2I6vknH1Ufu5Dh5qvQC3WsMliul9ZxlJQZ1/TkQE+q
I/gBPRmsMFZ/xV2VOEjMtM3qOPoemhYFzU39/ra0isk81sXrotySkvWw6zsrx8Nr
kBaw9mxhs0kumF06AfKSrBjyt/FIdbJaWtNrCdxJ+NMfzQUHmq9bzpBI2VpNJzFQ
I4WlO8eRYDS1Z88VxXOjMZchd70JfNNWcXwCUeOA/HUgHO4tWczvb/5/C5pfZRKu
DqfOLntcMEzpPxbhAbXvU+K5TK394SGgu9ioXl3rdrFj1B1EBPH2BfnOdwCiOOr5
ccWVPUHdG34i4D98ARgeqEDxq9/WZwq8FG9rgSszqkmnGQtSZxz8aoW1kU1h1SQu
mqs2ZUrEoLGACkNg16kRq2z7RBLc4MAm3/GW3ygeEFQxK0PMief0X2+l0oVo7a0A
RMLLLx4ckuoX3DIJvBegFPvlp0rO3JihdzNmCqIBTDok7D0k2NiQsm3WDJHAYB+8
G4ruHVPAOzPNxz5krF+u71jcWmZKO4FRAcXCrWTQCku7wLyzOF80sVEDlwARAQAB
tGNEciBXYXNoaW5ndG9uIFlhbWFuZHUgU2FuY2hleiAoMjAxNCBLZXlwYWlyIGZv
ciBuZXcgZW1haWwgYWRkcmVzcykgPHdhc2hpbmd0b24uc2FuY2hlekBvdXRsb29r
LmNvbT6JAjkEEwECACMFAlMZcEICGw8HCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIX
gAAKCRDgeMiuv/IyzzaGEACiYWINH5utgquhNPIGl8oPXQwi3cdHbLROXk9s8K5j
umxO3qyzrZuag+M39eKrDOgMTteLcCuJV+9sgdmSJHsLuH9o9/PPwaKHsY995C0Y
5ZRsvABRQbHoOJPsdq136gH2Z0kW/RJ2fqQfNrDiqyPJpWTkrnnRZF2XU8OlIAq+
BsyeVqxOiht1vMIz2TX/LanbP6leas7Wah1GRuzhd68+NCyCUQJ4bnBDv6cbGwXR
Vi7kOOvXYoTilCENdbSuYfGWrq7z54DrefjTP3+0Y/YTWwUQr/yvXi915UCDVU+T
6jaqCwtqmezr1VjkMrFQOOrOY7jWmYo4AwQfr4hW9iLdiggr6bPmz0YRfT83a9r9
Z+SmU4zuLWmmJXARiUGBwhXUmyqFQa1yjCVI+50uW8Wx3iDot9qiO7gSB878Zq1s
Ktt3EXolTDGgpVIxZ78do42X02wD8gwGGOdDU3Dzywjy3qcIbVWreuT8tEvCU+Wx
w0TGzeoBLcHezhLEbaAOmE5jAmKPL9EbRQBGS1nV3uwzW24vu9ftNqmseYXC2afW
DCulmUHHAQEfleJA/mKii2mYV7Yxclib81+EzkzJBPijgUJBN9A1PxqliF8ZDXF/
h/jQomASoDBAL8VWo7qwTQlc5CZKZ6xnUZGdUU9lFBmnclw0A6PrMBaZjm1zeKJr
1Q==
=7M1T
- -----END PGP PUBLIC KEY BLOCK-----
</PGP_Public_Key>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

<?xml version="1.0"?>

<!-- Seller's NYM -->
        <nym_id> ALICE-NYM-ID-HASH </nym_id>

<!-- Contract Nonce -->
	<contract_nonce> XXXX-YYYY-123456 </contract_nonce>

<!-- Bitcoin Pubkey -->
	<btc_addr> 03d728ad6757d4784effea04d47baafa216cf474866c2d4dc99b1e8e3eb936e730 </btc_addr>

<!-- Merchant Data -->
	<asset_name> 16 Pound Watermelon </asset_name>
	<asset_price> 0.01 BTC </asset_price>

<!-- Contract Expiration Date -->
	<contract_exp> YYYY-MM-DD TIME UTC </contract_exp>
	
<!-- Seller's PGP Key -->
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Z8
w65Xftwfn/gVvjBNlHetYRSJuynSKNwHG7u26tkihXbcvEnN24wOoPozQhWT2WbS
3zbjE+WjXjOGHjuAd/u5fdezTzG26BwSb0jahgvLwr+DvaOH5HX3jDtpQH5Vi8p1
ULW9dVeAX7ZHC//as0IY+6uuhLBy7+HlIzmn2ka63ML7Kqk+p9Uf1mImJ3PXmjvb
EyGYDpDtkfIKWJvM+UB6eiZKOG1VCAZjKHj9O8IgCTfT4fViu0GmjHYeOGdj+U6e
3dQzGqOYc/Ow4kXKQMM2FGpRp+85Arj9HEoUyPWNf6FDKKclbeBAKMJX99SNdwsi
ZX9YNFFPguwsoztYyWQGfhQItzUxfnsBFn4JvU6LyHI/orbzmtUSR4qFHKPpTRmI
BYDcVMMAv/u1eXOL8zd43kLcD0qp551FRjHVPhuOcu1R7tPkhdKirlZ4anbaEBMA
fdUl5j/whtLQ7afe3zsQ+9R4rpA=
=zW6Y
-----END PGP SIGNATURE-----

The SHA1 hash of this contract is 4cb658abd0ed7cd1a0531a5f1e839638a8d22d93 and can be used as the filename and/or tracking number of the contract.

Buying a Contract on OpenBazaar

The process for buying a contract is summarised by the following steps (note: signing is done on the client side, following the assumption that the buyer/seller's keys are stored locally or recoverable from a seed similar to DarkWallet):

1. The buyer digitally signs the seller's contract and sends it back to the seller
	- The buyer appends the following data to contract before signing:
		1. Buyer's nym
		2. Contract nonce
		3. Buyer's bitcoin pubkey (for multisig transactions)
		4. Delivery address of the buyer
		4. Buyer's PGP public key
	- Filename is the hash of the contract
2. The seller agrees to the transaction by digitally signing the buyer's version of the contract and sending the contract to 1) a potential arbiter, and 2) the buyer
	- Filename is the hash of the contract
3. The arbiter agrees to mediate the transaction by digitally signing the contract AND creaties a 2-of-3 multisig address
	- The arbiter's appends the following data to the contract before signing:
		1. Arbiter nym
		2. Contract nonce
		3. Arbiter's bitcoin pubkey (for multisig transactions)
		4. Arbiter's PGP public key
		5. Generated multisig address from the buyer, seller and arbiter's pubkeys
		6. Redemption script of the multisig address
	- Filename is the hash of the contract
4. The arbiter sends the final version of the triple-signed contract, with a multisig address, to the buyer and seller
	- The triple-signed contract represents the final version of the contract that all parties have agreed to
5. The buyer sends the contractually required amount of bitcoin to the multisig address.
6. The seller packages and ships the good to the buyer's address indicated in the triple-signed contract
7. Upon successful arrival of the goods, the buyer sends a digitally signed 'closed' contract to the seller and arbiter:
	- The buyer appends the following data to the triple-signed contract before signing:
		1. Message indicating that the goods have arrived
		2. Multisignature transaction script
		3. Buyer's signed multisignature transaction script
8. The seller verifies the multisignature transaction script in the 'closed' contract, signs the script and broadcasts the transaction to the bitcoin network for release of funds to the seller's bitcoin address

Using this process, the terms and conditions of the contract cannot be disputed and are impossible to forge. This leaves any disputes regarding the contract concerning to:

  1. Whether the goods have arrived or not
  2. Whether the multisignature transaction has been signed by the buyer (if not, the arbiter can be called upon to do this)

Reducing Contract Size

To reduce the overall size of the contract at each stage of the process, the next individual in the contract's iteration can sign the hash of the previous version of the contract.

For example, the buyer in step (1) can format the contract the following way:

<?xml version="1.0"?>

<!-- Seller's Contract Hash -->
	<contract_hash> 4cb658abd0ed7cd1a0531a5f1e839638a8d22d93 </contract_hash>

<!-- Buyer's NYM -->
	<nym_id> BOB-NYM-ID-HASH </nym_id>

<!-- Contract Nonce -->
	<contract_nonce> XXXX-YYYY-123456 </contract_nonce>

<!-- Bitcoin Pubkey -->
	<btc_addr> 03d728ad6757d4784effea04d47baafa216cf474866c2d4dc99b1e8e3eb936e730 </btc_addr>

<!-- Buyer's Delivery Addres -->
	<delivery_addr> 1060 W Addison St, Chicago, IL 60613, United States </delivery_addr>

<!-- Buyer's PGP Key -->
<PGP_Public_Key>
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: Mailvelope v0.8.2
Comment: Email security by Mailvelope - http://www.mailvelope.com

xsFNBFODLW8BD/9rmoBRBASaZuNpPBG+Gj7/aJcE7aQ4Sti7lKaERFD7/rHd
WHm+o+FnyQvxpkOuuU6G4q739tP5ZqHx/bn9rhpAKKa+o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Qa/Z
SXlkGuCJ7s0CjJ6qRmc9HPRcd5qA/2AHsAVF5HywgYXYqze8QFscUGhn/kO3//1Z
1I0u1v8FHuHSY/r/wHDZymJ5dYgndEPgzUrzvZStbswN3NtLVNdv6DRhGi+/xFRC
tZ87ys3OD+1cFjCd/wSTamAlTj99PHJLYuxX6gMYfTnj41JJADnfUeMa2Fw/qQg9
B3wWDXKIvs/xb4TzIJHKykBIZ5jjKGMweysD4iMbHkpSN/xEaWhM8hDAQ1nU1TjO
ecERcMLNM/oTa+RleynGXONaVG+24XwkC7gyl8fWdfFI9cfaICLHpcksRFWjkTkD
Z85QRlyzCUp1xK54hn3YNUKwibeOYHBdSqj3DYtCFdFD9A6QWYS+CGqlPLKbkjQQ
fgV7t+6hJjVztSeZiUzZDLDDGn978j8yTGi/5fQJsgbxO6cdPCAf7qKMX/4vK2g3
excS0w19X3r6nX+N6/+x
=YNf7
-----END PGP SIGNATURE-----

For even later iterations of the contract, a running tally of the previous hashes can be made in the contract field. For example:

<!-- Seller's Contract Hash -->
	<contract_hash> 4cb658abd0ed7cd1a0531a5f1e839638a8d22d93 </contract_hash>
	<contract_hash> 3f295f95f4a9abb0dba2cdb026ea551f0fa91507 </contract_hash>

There is also some flexibility in the naming of this field for clarity and simplicity:

<!-- Contract Chain -->
	<seller_signed_contract_hash> 4cb658abd0ed7cd1a0531a5f1e839638a8d22d93 </seller_signed_contract_hash>
	<buyer_signed_contract_hash> 3f295f95f4a9abb0dba2cdb026ea551f0fa91507 </buyer_signed_contract_hash>
	<double_signed_contract_hash> ... </double_signed_contract_hash>
	<arbiter_signed_contract_hash> ... </arbiter_contract_hash>
	<closed_contract_signed_hash> ... </closed_contract_signed_hash>

Summary

In conclusion, using Ricardian Contracts for buying and sellings goods on OpenBazaar is an effective means of managing risk and minimising disputes on a pseudonymous peer-to-peer market, thought its use of iterative key signing and checksum hashes at each stage of the contract's execution.

buyer digitally signs the seller's contract and sends it back to the seller

How is this done? Depending on how this information is sent, it has significant security implications for OpenBazaar. Could someone elaborate or point me to docs that do (in detail)?

2nd Question: shouldn't the buyer's home address be encrypted so that the arbiter doesn't know what it is?

question: has it been discussed to implement contracts in alternate formats, like a JSON?
(openbazaar could parse both XML and JSON, I suggest JSON as it's more interoperable in the web development world, and it's a lot leaner, less memory and cpu to parse when you add all the contracts traveling across the network, think 10million users a day a year from now, all the energy that could be saved., also more DHT friendly [love the idea of hashing the contract and just signing the hashes btw])

I find it so much more readable like this, and efficient
I also introduce here proposed data structures to let people set prices in the currency of their preference and have OpenBazaar automatically convert prices to Bitcoin based on the current exchange rate.

I guess the one issue remaining would be making sure the exchange rate used is valid, and maybe that can be part of the contract processing, if the buyer didn't use a conversion rate the buyer is willing to accept everything just gets rolled back, and that could be something the notary and arbiter could help with in the event of conflict.

the notary would sign off on the correctness of the exchange rate used.

also, the price information of bitcoin in time should be public, and it could programatically be checked by openbazaar around the time the transaction was made. Loving this facet of OpenBazaar, what an awesome project this is.

{
  'contract_hash':'6ad248665190044ff1ae3ad7c43c2835cb3cf28a',
  'nym_id': 'BOB-NUM-ID-HAH',
  'contract_nonce':'XXXX-YYYY-123456',
  'asset': {
     'name': '16 Pound Watermelon',
     'price': 8.00, //protect yourself against volatility, more user friendly when browsing for prices.
     'baseline_currency_code': 'USD',
     'accepted_payment_currencies': ['BTC'], //could open here for more than one currency,
     'exchange_rates_urls': ['https://bitpay.com/api/rates'], //could add more than one source in case one is down
    },
  'contract_exp': 'YYYY-MM-DD TIME UTC',
  'btc_addr':'03d728ad6757d4784effea04d47baafa216cf474866c2d4dc99b1e8e3eb936e730',
}
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: Mailvelope v0.8.2
Comment: Email security by Mailvelope - http://www.mailvelope.com

xsFNBFODLW8BD/9rmoBRBASaZuNpPBG+Gj7/aJcE7aQ4Sti7lKaERFD7/rHd
WHm+o+FnyQvxpkOuuU6G4q739tP5ZqHx/bn9rhpAKKa+o7es70jlpenHyge4
0QyIU1/9jXzwlMsXkq9Xfb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ywgYXYqze8QFscUGhn/kO3//1Z
1I0u1v8FHuHSY/r/wHDZymJ5dYgndEPgzUrzvZStbswN3NtLVNdv6DRhGi+/xFRC
tZ87ys3OD+1cFjCd/wSTamAlTj99PHJLYuxX6gMYfTnj41JJADnfUeMa2Fw/qQg9
B3wWDXKIvs/xb4TzIJHKykBIZ5jjKGMweysD4iMbHkpSN/xEaWhM8hDAQ1nU1TjO
ecERcMLNM/oTa+RleynGXONaVG+24XwkC7gyl8fWdfFI9cfaICLHpcksRFWjkTkD
Z85QRlyzCUp1xK54hn3YNUKwibeOYHBdSqj3DYtCFdFD9A6QWYS+CGqlPLKbkjQQ
fgV7t+6hJjVztSeZiUzZDLDDGn978j8yTGi/5fQJsgbxO6cdPCAf7qKMX/4vK2g3
excS0w19X3r6nX+N6/+x
=YNf7
-----END PGP SIGNATURE-----

A JSON format would be awesome!

Also would this be possible to conduct a sports wagering contract where 2 people enter money into a contract and the arbiter is a program that checks sports scores and releases funds to one of the addresses of the wagerers?

Owner

drwasho commented Oct 4, 2014

This is the first article I wrote for OpenBazaar making the case for Ricardian contracts. Since this time, JSON is being used as the standard formatting.

I proposed a way to make Ricardian Contract with Open Asset.
I talk about it on Bitcointalk
The spec is currently under PR on my fork.

Don't know if it can help, but might give you idea.

A key missing component seems to be a protocol to agree on acceptable arbiters. The protocol as written would allow the seller to create their own arbiter account, and create an "accepted" contract. This could be easily avoided by:

  • Having a list of acceptable arbiters listed in the initial contract offer.
  • Having the buyer specify the subset of arbiters that are also acceptable to them.
  • The seller then proceeds as normal, but the arbiter must be selected from that mutually acceptable subset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment