vault-tree 0.3.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/CHANGE_LOG.md +27 -0
- data/README.md +15 -73
- data/features/contracts/asymmetric_vault.feature +69 -2
- data/features/contracts/block_chain_key_transfer.feature +59 -0
- data/features/contracts/one_two_three.feature +109 -1
- data/features/contracts/readme.md +5 -6
- data/features/contracts_and_vaults.md +19 -24
- data/features/decision_tree.md +1 -1
- data/features/exceptions.feature +54 -43
- data/features/install_and_usage.md +38 -33
- data/features/keywords/assembled_shamir_key.feature +17 -17
- data/features/keywords/dh_key.feature +5 -5
- data/features/keywords/external_input.feature +35 -0
- data/features/keywords/external_key.feature +24 -0
- data/features/keywords/key.feature +3 -3
- data/features/keywords/random_number.feature +3 -3
- data/features/keywords/shamir_key_shares.feature +29 -0
- data/features/keywords/shamir_share.feature +40 -0
- data/features/keywords/split_key.feature +10 -9
- data/features/keywords/unlocked.feature +3 -3
- data/features/readme.md +1 -1
- data/features/steps/asymmetric_vault.steps.rb +14 -21
- data/features/steps/block_chain_key_transfer.steps.rb +17 -22
- data/features/steps/core.steps.rb +60 -71
- data/features/steps/exceptions.steps.rb +27 -64
- data/features/steps/external_input.steps.rb +17 -0
- data/features/steps/one_two_three.steps.rb +21 -27
- data/features/steps/secret_sharing.steps.rb +36 -19
- data/lib/vault-tree.rb +1 -1
- data/lib/vault-tree/contract/content_ciphertext.rb +33 -0
- data/lib/vault-tree/contract/content_plaintext.rb +33 -0
- data/lib/vault-tree/contract/contract.rb +15 -72
- data/lib/vault-tree/contract/contract_header.rb +11 -0
- data/lib/vault-tree/contract/vault.rb +24 -74
- data/lib/vault-tree/contract/vault_key.rb +21 -0
- data/lib/vault-tree/contract/vault_list.rb +56 -0
- data/lib/vault-tree/exceptions/empty_vault.rb +18 -3
- data/lib/vault-tree/exceptions/failed_lock_attempt.rb +18 -0
- data/lib/vault-tree/exceptions/failed_unlock_attempt.rb +23 -1
- data/lib/vault-tree/exceptions/invalid_external_input.rb +16 -0
- data/lib/vault-tree/exceptions/{missing_passphrase.rb → invalid_shamir_split.rb} +2 -1
- data/lib/vault-tree/exceptions/library_exception.rb +64 -0
- data/lib/vault-tree/exceptions/missing_partner_decryption_key.rb +11 -1
- data/lib/vault-tree/exceptions/unsupported_keyword.rb +17 -1
- data/lib/vault-tree/exceptions/vault_does_not_exist.rb +8 -1
- data/lib/vault-tree/keywords/assembled_shamir_key.rb +1 -1
- data/lib/vault-tree/keywords/contents.rb +1 -1
- data/lib/vault-tree/keywords/dh_key.rb +2 -2
- data/lib/vault-tree/keywords/external_input.rb +58 -0
- data/lib/vault-tree/keywords/external_key.rb +20 -0
- data/lib/vault-tree/keywords/key.rb +7 -1
- data/lib/vault-tree/keywords/keyword_interpreter.rb +5 -3
- data/lib/vault-tree/keywords/public_encryption_key.rb +1 -5
- data/lib/vault-tree/keywords/shamir_key_shares.rb +18 -0
- data/lib/vault-tree/keywords/shamir_share.rb +18 -0
- data/lib/vault-tree/keywords/split_key.rb +1 -1
- data/lib/vault-tree/lock_smith.rb +7 -8
- data/lib/vault-tree/lock_smith/{generated_shamir_key.rb → shamir_key_shares.rb} +22 -21
- data/lib/vault-tree/lock_smith/{split_key.rb → split_key_crypto.rb} +0 -0
- data/lib/vault-tree/version.rb +1 -1
- data/spec/assembled_shamir_key_spec.rb +0 -1
- data/spec/custom_exception_spec.rb +81 -0
- data/spec/lock_smith_spec.rb +0 -48
- data/spec/secret_sharing_spec.rb +0 -1
- data/spec/shamir_key_shares_spec.rb +27 -0
- data/vault-tree.gemspec +1 -1
- metadata +33 -139
- data/Gemfile.lock +0 -53
- data/VagrantFile +0 -30
- data/features/keywords/external_data.feature +0 -11
- data/features/keywords/generated_shamir_key.feature +0 -55
- data/features/keywords/master_passphrase.feature +0 -68
- data/features/manipulating_contracts.md +0 -84
- data/features/support/contract_fixtures/asymmetric_vault.0.1.0.json +0 -69
- data/features/support/contract_fixtures/blank_simple_test_contract.json +0 -14
- data/features/support/contract_fixtures/block_chain_key_transfer.0.1.0.json +0 -59
- data/features/support/contract_fixtures/broken_contract.json +0 -55
- data/features/support/contract_fixtures/one_two_three.0.7.0.json +0 -108
- data/features/support/contract_fixtures/simple_test_contract.json +0 -14
- data/features/support/contract_fixtures/template.json +0 -33
- data/lib/vault-tree/contract/close_validator.rb +0 -28
- data/lib/vault-tree/contract/doorman.rb +0 -113
- data/lib/vault-tree/contract/open_validator.rb +0 -20
- data/lib/vault-tree/exceptions/exception_template.erb +0 -0
- data/lib/vault-tree/exceptions/fill_attempt_master_password.rb +0 -6
- data/lib/vault-tree/exceptions/missing_external_data.rb +0 -6
- data/lib/vault-tree/exceptions/vault_tree_exception.rb +0 -25
- data/lib/vault-tree/keywords/external_data.rb +0 -32
- data/lib/vault-tree/keywords/generated_shamir_key.rb +0 -57
- data/lib/vault-tree/keywords/master_passphrase.rb +0 -9
- data/spec/generated_shamir_key_spec.rb +0 -52
- data/support/cookbooks/ark/.gitignore +0 -12
- data/support/cookbooks/ark/.kitchen.yml +0 -34
- data/support/cookbooks/ark/.travis.yml +0 -6
- data/support/cookbooks/ark/Berksfile +0 -9
- data/support/cookbooks/ark/CHANGELOG.md +0 -87
- data/support/cookbooks/ark/CONTRIBUTING.md +0 -257
- data/support/cookbooks/ark/README.md +0 -301
- data/support/cookbooks/ark/Rakefile +0 -36
- data/support/cookbooks/ark/TESTING.md +0 -25
- data/support/cookbooks/ark/Toftfile +0 -15
- data/support/cookbooks/ark/attributes/default.rb +0 -6
- data/support/cookbooks/ark/chefignore +0 -96
- data/support/cookbooks/ark/files/default/foo.tar.gz +0 -0
- data/support/cookbooks/ark/files/default/foo.tbz +0 -0
- data/support/cookbooks/ark/files/default/foo.tgz +0 -0
- data/support/cookbooks/ark/files/default/foo.zip +0 -0
- data/support/cookbooks/ark/files/default/tests/minitest/default_test.rb +0 -0
- data/support/cookbooks/ark/files/default/tests/minitest/support/helpers.rb +0 -0
- data/support/cookbooks/ark/files/default/tests/minitest/test_test.rb +0 -94
- data/support/cookbooks/ark/libraries/default.rb +0 -167
- data/support/cookbooks/ark/metadata.rb +0 -13
- data/support/cookbooks/ark/providers/default.rb +0 -370
- data/support/cookbooks/ark/recipes/default.rb +0 -31
- data/support/cookbooks/ark/recipes/test.rb +0 -138
- data/support/cookbooks/ark/resources/default.rb +0 -54
- data/support/cookbooks/ark/templates/default/add_to_path.sh.erb +0 -1
- data/support/cookbooks/ark/test/support/Gemfile +0 -4
- data/support/cookbooks/build-essential/README.md +0 -24
- data/support/cookbooks/build-essential/metadata.rb +0 -10
- data/support/cookbooks/build-essential/recipes/default.rb +0 -45
- data/support/cookbooks/chruby/.gitignore +0 -15
- data/support/cookbooks/chruby/.kitchen.yml +0 -26
- data/support/cookbooks/chruby/.ruby_version +0 -1
- data/support/cookbooks/chruby/Berksfile +0 -3
- data/support/cookbooks/chruby/Gemfile +0 -7
- data/support/cookbooks/chruby/LICENSE +0 -14
- data/support/cookbooks/chruby/README.md +0 -92
- data/support/cookbooks/chruby/Rakefile +0 -7
- data/support/cookbooks/chruby/Thorfile +0 -6
- data/support/cookbooks/chruby/Vagrantfile +0 -86
- data/support/cookbooks/chruby/attributes/default.rb +0 -10
- data/support/cookbooks/chruby/chefignore +0 -96
- data/support/cookbooks/chruby/metadata.rb +0 -11
- data/support/cookbooks/chruby/recipes/default.rb +0 -43
- data/support/cookbooks/chruby/recipes/system.rb +0 -25
- data/support/cookbooks/chruby/templates/default/chruby.sh.erb +0 -22
- data/support/cookbooks/chruby/test/integration/default/bash/embedded_test.sh +0 -1
- data/support/cookbooks/git/.gitignore +0 -14
- data/support/cookbooks/git/.kitchen.yml +0 -46
- data/support/cookbooks/git/Berksfile +0 -8
- data/support/cookbooks/git/CHANGELOG.md +0 -87
- data/support/cookbooks/git/CONTRIBUTING +0 -29
- data/support/cookbooks/git/Gemfile +0 -3
- data/support/cookbooks/git/LICENSE +0 -201
- data/support/cookbooks/git/README.md +0 -115
- data/support/cookbooks/git/TESTING.md +0 -25
- data/support/cookbooks/git/attributes/default.rb +0 -40
- data/support/cookbooks/git/metadata.rb +0 -35
- data/support/cookbooks/git/recipes/default.rb +0 -53
- data/support/cookbooks/git/recipes/server.rb +0 -58
- data/support/cookbooks/git/recipes/source.rb +0 -49
- data/support/cookbooks/git/recipes/windows.rb +0 -37
- data/support/cookbooks/git/templates/default/git-xinetd.d.erb +0 -10
- data/support/cookbooks/git/templates/default/sv-git-daemon-log-run.erb +0 -2
- data/support/cookbooks/git/templates/default/sv-git-daemon-run.erb +0 -3
- data/support/cookbooks/install_ruby/README.md +0 -3
- data/support/cookbooks/install_ruby/metadata.rb +0 -10
- data/support/cookbooks/install_ruby/recipes/default.rb +0 -14
- data/support/cookbooks/ruby_build/.gitignore +0 -6
- data/support/cookbooks/ruby_build/.kitchen.yml +0 -31
- data/support/cookbooks/ruby_build/.travis.yml +0 -4
- data/support/cookbooks/ruby_build/Berksfile +0 -10
- data/support/cookbooks/ruby_build/CHANGELOG.md +0 -72
- data/support/cookbooks/ruby_build/Gemfile +0 -14
- data/support/cookbooks/ruby_build/README.md +0 -338
- data/support/cookbooks/ruby_build/Rakefile +0 -21
- data/support/cookbooks/ruby_build/attributes/default.rb +0 -67
- data/support/cookbooks/ruby_build/chefignore +0 -53
- data/support/cookbooks/ruby_build/libraries/ruby_build_recipe_helpers.rb +0 -40
- data/support/cookbooks/ruby_build/metadata.rb +0 -18
- data/support/cookbooks/ruby_build/providers/ruby.rb +0 -88
- data/support/cookbooks/ruby_build/recipes/default.rb +0 -69
- data/support/cookbooks/ruby_build/resources/ruby.rb +0 -33
- data/support/cookbooks/ruby_build/test/cookbooks/alltherubies/metadata.rb +0 -10
- data/support/cookbooks/ruby_build/test/cookbooks/alltherubies/recipes/default.rb +0 -59
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/_verify_tests.bash +0 -33
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.8.7.bats +0 -29
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.9.2.bats +0 -18
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.9.3.bats +0 -18
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_2.0.0.bats +0 -18
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_jruby.bats +0 -20
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_rbx.bats +0 -18
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_ree.bats +0 -19
- data/support/cookbooks/ruby_build/test/integration/installation/bats/installation.bats +0 -6
- data/support/scripts/libsodium_ubuntu.sh +0 -80
- data/support/tasks/.gitkeep +0 -0
- data/support/tasks/libsodium_install.rb +0 -57
data/.gitignore
CHANGED
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--color
|
data/CHANGE_LOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
## 0.6.0
|
|
2
|
+
|
|
3
|
+
* Return JSON from close_vault method
|
|
4
|
+
- now open_vault and close_vault return as string
|
|
5
|
+
* Update tests to support new public interface
|
|
6
|
+
|
|
7
|
+
## 0.3.17
|
|
8
|
+
|
|
9
|
+
* Remove support for EXTERNAL_DATA Keyword
|
|
10
|
+
* Use EXTERNAL_INPUT Insead
|
|
11
|
+
|
|
12
|
+
## 0.3.16
|
|
13
|
+
|
|
14
|
+
* Remove support for GENERATED_SHAMIR_KEY Keyword
|
|
15
|
+
|
|
16
|
+
## 0.3.7
|
|
17
|
+
|
|
18
|
+
* Add Better Exception Messaging
|
|
19
|
+
* Verbose Messaging when Vault Tree Exceptions are thrown
|
|
20
|
+
* Log the Message to STDOUT
|
|
21
|
+
* Pattern for implementing future custom exceptions
|
|
22
|
+
|
|
23
|
+
## 0.3.5
|
|
24
|
+
|
|
25
|
+
* Remove support for MASTER_PASSPHRASE Keyword.
|
|
26
|
+
* MASTER_PASSPHRASE has been removed from example contracts.
|
|
27
|
+
|
|
1
28
|
## 0.3.4
|
|
2
29
|
|
|
3
30
|
* Bug Fix in Exception Handling
|
data/README.md
CHANGED
|
@@ -1,32 +1,18 @@
|
|
|
1
|
+
[](https://codeclimate.com/github/VaultTree/vault-tree)
|
|
2
|
+
|
|
1
3
|
## Vault Tree
|
|
2
4
|
|
|
3
5
|
_The Self Enforcing Contract_
|
|
4
6
|
|
|
5
|
-
Vault Tree
|
|
7
|
+
Vault Tree helps you build crypto-based business logic into your application.
|
|
6
8
|
|
|
7
9
|
Before you begin make sure you checkout the [Vault Tree Homepage] for an overview of the project.
|
|
8
10
|
|
|
9
|
-
[Vault Tree Homepage]: http://
|
|
10
|
-
|
|
11
|
-
### Welcome!
|
|
12
|
-
|
|
13
|
-
The Vault Tree Project consists of:
|
|
14
|
-
|
|
15
|
-
* A JSON based DSL for building Distributed Crytographic Contracts
|
|
16
|
-
* A a Ruby library to execute these contracts
|
|
17
|
-
* A focal point of collaboration for developers writing and testing interesting crytographic contracts
|
|
18
|
-
|
|
11
|
+
[Vault Tree Homepage]: http://vaulttree.github.io
|
|
19
12
|
|
|
20
13
|
### Install
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* To use the library in your application or want to contribute code, you're in the right place.
|
|
25
|
-
* Before you pull the trigger on the install remember we have a Vagrant Box.
|
|
26
|
-
|
|
27
|
-
Okay, lets begin.
|
|
28
|
-
|
|
29
|
-
As a prerequisite get [libsodium] (>= 0.4.3) on you machine. This is the underlying cryptographic library that Vault Tree depends on.
|
|
15
|
+
As a prerequisite, get [libsodium] version (>= 0.4.3) on you machine. This is the underlying cryptographic library that Vault Tree depends on.
|
|
30
16
|
|
|
31
17
|
[libsodium]: https://github.com/jedisct1/libsodium
|
|
32
18
|
|
|
@@ -39,13 +25,7 @@ As a prerequisite get [libsodium] (>= 0.4.3) on you machine. This is the underly
|
|
|
39
25
|
[brew]: http://brew.sh/
|
|
40
26
|
|
|
41
27
|
* If you're on a Debian based system, there is no _apt-get_ package that I know of, but there
|
|
42
|
-
are some helpful install scripts on the web.
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
vault-tree/support/scripts/libsodium_ubuntu.sh
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
* If you're on Windows, the Vagrant install gives you a Linux virtual machine that helps you to pretend that you're not on Windows.
|
|
28
|
+
are some helpful install scripts on the web.
|
|
49
29
|
|
|
50
30
|
Now that you have libsodium, if you're a Ruby developer you know the drill from here:
|
|
51
31
|
|
|
@@ -61,55 +41,17 @@ require 'vault-tree'
|
|
|
61
41
|
|
|
62
42
|
somewhere before you use it.
|
|
63
43
|
|
|
44
|
+
### Usage
|
|
64
45
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
I think it should be easy for you to get a Vault Tree development environment up and running. If you don't know about Vagrant, you should, it's awesome!
|
|
68
|
-
|
|
69
|
-
* Follow the [Vagrant] download and install steps
|
|
70
|
-
* Clone the Vault Tree Repo and go into it:
|
|
71
|
-
|
|
72
|
-
[Vagrant]: http://www.vagrantup.com/
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
git clone git@github.com:VaultTree/vault-tree.git
|
|
76
|
-
cd ~/path/to/vault-tree/
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Now you just need to Vagrant Up!
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
vagrant up
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
This will download and boot a pre-packaged Linux virtual machine with Vault-Tree and all dependencies already installed.
|
|
86
|
-
|
|
87
|
-
Once your VM is downloaded and built. You can go inside with:
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
vagrant ssh
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
As a developer working on Vault Tree you can now go to the VM's directory:
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
/vagrant
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
and run `bundle` then `rake`. This will grab your dependincies, run all the tests, and leave you in a good spot to start exploring the code.
|
|
100
|
-
|
|
101
|
-
If you're not already familiar, take a few minutes to learn about how Vagrant will [sync your files] to and from the guest machine.
|
|
102
|
-
|
|
103
|
-
[sync your files]: http://docs.vagrantup.com/v2/getting-started/synced_folders.html
|
|
46
|
+
The [Documentation] is filled with examples of how to execute Vault Tree contracts.
|
|
104
47
|
|
|
105
|
-
|
|
48
|
+
Also, a great way to get going is to simply run the tests:
|
|
106
49
|
|
|
107
|
-
|
|
108
|
-
|
|
50
|
+
* clone the repo
|
|
51
|
+
* bundle your dependencies
|
|
52
|
+
* run `rake`
|
|
109
53
|
|
|
110
|
-
|
|
54
|
+
You should see a full suite of green tests that will give you plenty of living
|
|
55
|
+
examples of how to use Vault Tree in your own application.
|
|
111
56
|
|
|
112
|
-
|
|
113
|
-
* We we need to figure out if the supported keywords are sufficient to implement basic secure computation schemes.
|
|
114
|
-
- For example, Digital Signatures are not implemented but could be.
|
|
115
|
-
- Should they be implemented? What is the use case? Ect. We need to have these conversations.
|
|
57
|
+
[Documentation]: https://www.relishapp.com/vault-tree/vault-tree/docs
|
|
@@ -13,8 +13,75 @@ Feature: Asymmetric Vaults
|
|
|
13
13
|
key and the reciprocal public key
|
|
14
14
|
|
|
15
15
|
Scenario: Bob Locks and Alice Unlocks with a Shared Key
|
|
16
|
-
Given
|
|
17
|
-
|
|
16
|
+
Given the blank contract:
|
|
17
|
+
"""javascript
|
|
18
|
+
{
|
|
19
|
+
"header": {
|
|
20
|
+
"title":"Asymmetric Vault",
|
|
21
|
+
"description":"Demonstrated use of a Vault Tree Asymmetric Vault"
|
|
22
|
+
},
|
|
23
|
+
"vaults": {
|
|
24
|
+
"bob_contract_secret":{
|
|
25
|
+
"description":"Contract specific password to lock private information",
|
|
26
|
+
"fill_with": "RANDOM_NUMBER",
|
|
27
|
+
"lock_with": "EXTERNAL_INPUT['bcs_key']",
|
|
28
|
+
"unlock_with": "EXTERNAL_INPUT['bcs_key']",
|
|
29
|
+
"contents": ""
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
"alice_contract_secret":{
|
|
33
|
+
"description":"Contract specific password to lock private information",
|
|
34
|
+
"fill_with": "RANDOM_NUMBER",
|
|
35
|
+
"lock_with": "EXTERNAL_INPUT['acs_key']",
|
|
36
|
+
"unlock_with": "EXTERNAL_INPUT['acs_key']",
|
|
37
|
+
"contents": ""
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
"alice_public_encryption_key":{
|
|
41
|
+
"description":"Public key for asymmetric encryption",
|
|
42
|
+
"fill_with": "PUBLIC_ENCRYPTION_KEY['alice_decryption_key']",
|
|
43
|
+
"lock_with": "UNLOCKED",
|
|
44
|
+
"unlock_with": "UNLOCKED",
|
|
45
|
+
"contents": ""
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
"bob_public_encryption_key":{
|
|
49
|
+
"description":"Public key for asymmetric encryption",
|
|
50
|
+
"fill_with": "PUBLIC_ENCRYPTION_KEY['bob_decryption_key']",
|
|
51
|
+
"lock_with": "UNLOCKED",
|
|
52
|
+
"unlock_with": "UNLOCKED",
|
|
53
|
+
"contents": ""
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
"alice_decryption_key":{
|
|
57
|
+
"description":"Private key for asymmetric decryption",
|
|
58
|
+
"fill_with": "DECRYPTION_KEY",
|
|
59
|
+
"lock_with": "KEY['alice_contract_secret']",
|
|
60
|
+
"unlock_with": "KEY['alice_contract_secret']",
|
|
61
|
+
"contents": ""
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
"bob_decryption_key":{
|
|
65
|
+
"description":"Private key for asymmetric decryption",
|
|
66
|
+
"fill_with": "DECRYPTION_KEY",
|
|
67
|
+
"lock_with": "KEY['bob_contract_secret']",
|
|
68
|
+
"unlock_with": "KEY['bob_contract_secret']",
|
|
69
|
+
"contents": ""
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
"message":{
|
|
73
|
+
"description":"This is an asymmetric vault. It contains a secret message.",
|
|
74
|
+
"fill_with": "EXTERNAL_INPUT['msg']",
|
|
75
|
+
"lock_with": "DH_KEY['alice_public_encryption_key','bob_decryption_key']",
|
|
76
|
+
"unlock_with": "DH_KEY['bob_public_encryption_key','alice_decryption_key']",
|
|
77
|
+
"contents": ""
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
"""
|
|
84
|
+
When Alice locks all of her public and private keys
|
|
18
85
|
And she sends the contract to Bob over the internet
|
|
19
86
|
Then Bob can access of her public keys but not her private keys
|
|
20
87
|
When Bob locks his public and private keys
|
|
@@ -25,6 +25,65 @@ Feature: Block Chain Key Transfer
|
|
|
25
25
|
|
|
26
26
|
Scenario: SENDER Transfers a BTC Signing Key to the RECEIVER
|
|
27
27
|
|
|
28
|
+
Given the blank contract:
|
|
29
|
+
"""javascript
|
|
30
|
+
{
|
|
31
|
+
"header": {
|
|
32
|
+
"title":"Block Chain Key Transfer",
|
|
33
|
+
"description":"A simple key transfer sheme utilizing a revealed BTC Wallet Address. This can be used as step within the execution of a larger contract."
|
|
34
|
+
},
|
|
35
|
+
"vaults": {
|
|
36
|
+
|
|
37
|
+
"sender_btc_signing_key":{
|
|
38
|
+
"description":"This is the secret Bitcoin Signing Key that SENDER wishes to transfer to RECEIVER. The RECEIVER can unlock only after he has the revealed address.",
|
|
39
|
+
"fill_with": "EXTERNAL_INPUT['ssk']",
|
|
40
|
+
"lock_with": "KEY['sender_concealed_destination_wallet_address']",
|
|
41
|
+
"unlock_with": "KEY['receiver_revealed_destination_wallet_address']",
|
|
42
|
+
"contents": ""
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
"sender_origin_wallet_address":{
|
|
46
|
+
"description":"SENDER origin wallet address. Chosen by SENDER and known in advance to RECEIVER.",
|
|
47
|
+
"fill_with": "EXTERNAL_INPUT['sowa']",
|
|
48
|
+
"lock_with": "UNLOCKED",
|
|
49
|
+
"unlock_with": "UNLOCKED",
|
|
50
|
+
"contents": ""
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
"sender_concealed_destination_wallet_address":{
|
|
54
|
+
"description":"SENDER concealed copy of the destination wallet address. This wallet address is kept secret until SENDER chosed to transfer BTC to it",
|
|
55
|
+
"fill_with": "EXTERNAL_INPUT['scdwa']",
|
|
56
|
+
"lock_with": "KEY['sender_secret']",
|
|
57
|
+
"unlock_with": "KEY['sender_secret']",
|
|
58
|
+
"contents": ""
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
"receiver_revealed_destination_wallet_address":{
|
|
62
|
+
"description":"RECEIVER monitors the Block Chain and fills this vault with the newly revealied destination address.",
|
|
63
|
+
"fill_with": "EXTERNAL_INPUT['rrdwa']",
|
|
64
|
+
"lock_with": "KEY['receiver_secret']",
|
|
65
|
+
"unlock_with": "KEY['receiver_secret']",
|
|
66
|
+
"contents": ""
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
"receiver_secret":{
|
|
70
|
+
"fill_with": "RANDOM_NUMBER",
|
|
71
|
+
"lock_with": "EXTERNAL_INPUT['rs_key']",
|
|
72
|
+
"unlock_with": "EXTERNAL_INPUT['rs_key']",
|
|
73
|
+
"contents": ""
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
"sender_secret":{
|
|
77
|
+
"description":"Contract specific password for SENDER. Used to Lock the SENDER private information.",
|
|
78
|
+
"fill_with": "RANDOM_NUMBER",
|
|
79
|
+
"lock_with": "EXTERNAL_INPUT['ss_key']",
|
|
80
|
+
"unlock_with": "EXTERNAL_INPUT['ss_key']",
|
|
81
|
+
"contents": ""
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
"""
|
|
28
87
|
Given the SENDER has the blank contract template
|
|
29
88
|
And the SENDER chooses an origin address and a concealed destination address
|
|
30
89
|
And he locks away the secret BTC signing key
|
|
@@ -13,7 +13,115 @@ Feature: One-Two-Three Contract
|
|
|
13
13
|
appropriate keys
|
|
14
14
|
|
|
15
15
|
Scenario: Alice and Bob Execute the One Two Three Contract
|
|
16
|
-
Given
|
|
16
|
+
Given the blank contract:
|
|
17
|
+
"""javascript
|
|
18
|
+
{
|
|
19
|
+
"header": {
|
|
20
|
+
"title":"One Two Three",
|
|
21
|
+
"description":"A simple contract to test the full Vault Tree stack. Open each vault to proceed to the next one. Unlock the congratulations message"
|
|
22
|
+
},
|
|
23
|
+
"vaults": {
|
|
24
|
+
|
|
25
|
+
"bob_contract_secret":{
|
|
26
|
+
"description":"contract specific password to lock private information",
|
|
27
|
+
"fill_with": "RANDOM_NUMBER",
|
|
28
|
+
"lock_with": "EXTERNAL_INPUT['bcs_key']",
|
|
29
|
+
"unlock_with": "EXTERNAL_INPUT['bcs_key']",
|
|
30
|
+
"contents": ""
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
"alice_contract_secret":{
|
|
34
|
+
"description":"contract specific password to lock private information",
|
|
35
|
+
"fill_with": "RANDOM_NUMBER",
|
|
36
|
+
"lock_with": "EXTERNAL_INPUT['acs_key']",
|
|
37
|
+
"unlock_with": "EXTERNAL_INPUT['acs_key']",
|
|
38
|
+
"contents": ""
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
"alice_public_encryption_key":{
|
|
42
|
+
"description":"public key for asymmetric encryption",
|
|
43
|
+
"fill_with": "PUBLIC_ENCRYPTION_KEY['alice_decryption_key']",
|
|
44
|
+
"lock_with": "UNLOCKED",
|
|
45
|
+
"unlock_with": "UNLOCKED",
|
|
46
|
+
"contents": ""
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
"bob_public_encryption_key":{
|
|
50
|
+
"description":"public key for asymmetric encryption",
|
|
51
|
+
"fill_with": "PUBLIC_ENCRYPTION_KEY['bob_decryption_key']",
|
|
52
|
+
"lock_with": "UNLOCKED",
|
|
53
|
+
"unlock_with": "UNLOCKED",
|
|
54
|
+
"contents": ""
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
"alice_decryption_key":{
|
|
58
|
+
"description":"private key for asymmetric decryption",
|
|
59
|
+
"fill_with": "DECRYPTION_KEY",
|
|
60
|
+
"lock_with": "KEY['alice_contract_secret']",
|
|
61
|
+
"unlock_with": "KEY['alice_contract_secret']",
|
|
62
|
+
"contents": ""
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
"bob_decryption_key":{
|
|
66
|
+
"description":"private key for asymmetric decryption",
|
|
67
|
+
"fill_with": "DECRYPTION_KEY",
|
|
68
|
+
"lock_with": "KEY['bob_contract_secret']",
|
|
69
|
+
"unlock_with": "KEY['bob_contract_secret']",
|
|
70
|
+
"contents": ""
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
"congratulations_message":{
|
|
74
|
+
"description":"A simple message for Bob to put in the final vault",
|
|
75
|
+
"fill_with": "EXTERNAL_INPUT['msg']",
|
|
76
|
+
"lock_with": "KEY['bob_contract_secret']",
|
|
77
|
+
"unlock_with": "KEY['bob_contract_secret']",
|
|
78
|
+
"contents": ""
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
"vault_two_key":{
|
|
82
|
+
"description":"Key to lock vault two. Once Bob locks the second vault he will put this key inside vault one.",
|
|
83
|
+
"fill_with": "RANDOM_NUMBER",
|
|
84
|
+
"lock_with": "KEY['bob_contract_secret']",
|
|
85
|
+
"unlock_with": "KEY['bob_contract_secret']",
|
|
86
|
+
"contents": ""
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
"vault_three_key":{
|
|
90
|
+
"description":"Key to lock vault three. Once Bob locks the third vault he will put this key inside vault two.",
|
|
91
|
+
"fill_with": "RANDOM_NUMBER",
|
|
92
|
+
"lock_with": "KEY['bob_contract_secret']",
|
|
93
|
+
"unlock_with": "KEY['bob_contract_secret']",
|
|
94
|
+
"contents": ""
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
"first":{
|
|
98
|
+
"description":"This is an asymmetric vault with mutual authentication. It contains the key to vault two and is locked by Bob, with Alices public key. Only Alice can unlock it.",
|
|
99
|
+
"fill_with": "CONTENTS['vault_two_key']",
|
|
100
|
+
"lock_with": "DH_KEY['alice_public_encryption_key','bob_decryption_key']",
|
|
101
|
+
"unlock_with": "DH_KEY['bob_public_encryption_key','alice_decryption_key']",
|
|
102
|
+
"contents": ""
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
"second":{
|
|
106
|
+
"description":"Alice unlocks this vault with the key held in the first vault.",
|
|
107
|
+
"fill_with": "CONTENTS['vault_three_key']",
|
|
108
|
+
"lock_with": "KEY['vault_two_key']",
|
|
109
|
+
"unlock_with": "KEY['first']",
|
|
110
|
+
"contents": ""
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
"third":{
|
|
114
|
+
"description":"Contains a simple message. Unlock the key found in the second vault.",
|
|
115
|
+
"fill_with": "CONTENTS['congratulations_message']",
|
|
116
|
+
"lock_with": "KEY['vault_three_key']",
|
|
117
|
+
"unlock_with": "KEY['second']",
|
|
118
|
+
"contents": ""
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
"""
|
|
124
|
+
And Alice has the blank contract
|
|
17
125
|
When she locks all of her attributes
|
|
18
126
|
And she sends the contract to Bob
|
|
19
127
|
Then Bob can access all of her public attributes
|
|
@@ -7,7 +7,7 @@ need to know:
|
|
|
7
7
|
- The **Vaults** section, which can be any collection of _vaults_ that form the
|
|
8
8
|
contract.
|
|
9
9
|
* The way in which you, the contract author, organize the vaults will determine the **Self-Enforcing Terms** of your contract.
|
|
10
|
-
* Each vault will typically contain either an **external
|
|
10
|
+
* Each vault will typically contain either an **external input** string that is provided by one of the contract
|
|
11
11
|
participants, or a key to anther vault.
|
|
12
12
|
|
|
13
13
|
### Writing and Simulating Contracts
|
|
@@ -47,7 +47,6 @@ Well, what if we associate each one of these steps in the scenario with some sim
|
|
|
47
47
|
|
|
48
48
|
```Ruby
|
|
49
49
|
# This file: "features/core/one_two_three/one_two_three.steps.rb"
|
|
50
|
-
# Associated Contract: "core/one_two_three.0.7.0.json"
|
|
51
50
|
|
|
52
51
|
Given(/^Alice has the blank contract$/) do
|
|
53
52
|
contract_path = VaultTree::ContractsRepo::PathHelpers.core_contracts('one_two_three.0.7.0.json')
|
|
@@ -55,15 +54,15 @@ Given(/^Alice has the blank contract$/) do
|
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
When(/^she locks all of her attributes$/) do
|
|
58
|
-
@contract = VaultTree::Contract.new(@contract_json
|
|
57
|
+
@contract = VaultTree::Contract.new(@contract_json)
|
|
59
58
|
@contract = @contract.close_vault('alice_decryption_key')
|
|
60
59
|
@contract = @contract.close_vault('alice_public_encryption_key')
|
|
61
60
|
end
|
|
62
61
|
|
|
63
62
|
When(/^she sends the contract to Bob$/) do
|
|
64
63
|
@contract_json = @contract.as_json
|
|
65
|
-
@
|
|
66
|
-
@contract = VaultTree::Contract.new(@contract_json,
|
|
64
|
+
@bobs_external_input = {"congratulations_message" => "CONGRATS! YOU OPENED THE THIRD VAULT."}
|
|
65
|
+
@contract = VaultTree::Contract.new(@contract_json, @bobs_external_input)
|
|
67
66
|
end
|
|
68
67
|
```
|
|
69
68
|
|
|
@@ -87,7 +86,7 @@ community off to a good start.
|
|
|
87
86
|
I'll update these in the coming months as we get some more experience writing simple contracts.
|
|
88
87
|
|
|
89
88
|
* The Vault Tree interpreter is stateless and always takes a contract as an input
|
|
90
|
-
* All external
|
|
89
|
+
* All external input required for contract execution must be provided to the
|
|
91
90
|
interpreter by the run time that is invoking the API. For example, there are no
|
|
92
91
|
plans for the interpreter to make any network requests or do file IO.
|
|
93
92
|
|