vault-tree 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. data/.gitignore +26 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +43 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +118 -0
  6. data/Rakefile +17 -0
  7. data/VagrantFile +30 -0
  8. data/features/core.feature +44 -0
  9. data/features/exceptions.feature +41 -0
  10. data/features/steps/core.steps.rb +168 -0
  11. data/features/steps/exceptions.steps.rb +103 -0
  12. data/features/support/env.rb +1 -0
  13. data/features/world.rb +3 -0
  14. data/lib/vault-tree.rb +7 -0
  15. data/lib/vault-tree/config/dependencies.rb +4 -0
  16. data/lib/vault-tree/config/lib.rb +2 -0
  17. data/lib/vault-tree/config/path_helpers.rb +49 -0
  18. data/lib/vault-tree/config/string.rb +25 -0
  19. data/lib/vault-tree/contract/close_validator.rb +35 -0
  20. data/lib/vault-tree/contract/contract.rb +85 -0
  21. data/lib/vault-tree/contract/contract_presenter.rb +27 -0
  22. data/lib/vault-tree/contract/doorman.rb +112 -0
  23. data/lib/vault-tree/contract/null_vault.rb +16 -0
  24. data/lib/vault-tree/contract/open_validator.rb +20 -0
  25. data/lib/vault-tree/contract/vault.rb +96 -0
  26. data/lib/vault-tree/exceptions/empty_vault.rb +8 -0
  27. data/lib/vault-tree/exceptions/fill_attempt_master_password.rb +6 -0
  28. data/lib/vault-tree/exceptions/invalid_signature.rb +0 -0
  29. data/lib/vault-tree/exceptions/malformed_json.rb +0 -0
  30. data/lib/vault-tree/exceptions/missing_external_data.rb +6 -0
  31. data/lib/vault-tree/exceptions/missing_partner_decryption_key.rb +6 -0
  32. data/lib/vault-tree/exceptions/missing_passphrase.rb +6 -0
  33. data/lib/vault-tree/exceptions/non_unique_vault_id.rb +0 -0
  34. data/lib/vault-tree/exceptions/unsupported_keyword.rb +6 -0
  35. data/lib/vault-tree/exceptions/vault_does_not_exist.rb +6 -0
  36. data/lib/vault-tree/exceptions/vault_tree_exception.rb +6 -0
  37. data/lib/vault-tree/keywords/decryption_key.rb +14 -0
  38. data/lib/vault-tree/keywords/external_data.rb +13 -0
  39. data/lib/vault-tree/keywords/keyword.rb +19 -0
  40. data/lib/vault-tree/keywords/keyword_interpreter.rb +45 -0
  41. data/lib/vault-tree/keywords/master_passphrase.rb +9 -0
  42. data/lib/vault-tree/keywords/public_encryption_key.rb +27 -0
  43. data/lib/vault-tree/keywords/random_number.rb +9 -0
  44. data/lib/vault-tree/keywords/shared_key.rb +24 -0
  45. data/lib/vault-tree/keywords/unlocked.rb +9 -0
  46. data/lib/vault-tree/keywords/vault_contents.rb +13 -0
  47. data/lib/vault-tree/lock_smith/asymmetric_cipher.rb +31 -0
  48. data/lib/vault-tree/lock_smith/crypto_hash.rb +11 -0
  49. data/lib/vault-tree/lock_smith/digital_signature.rb +32 -0
  50. data/lib/vault-tree/lock_smith/encryption_key_pair.rb +25 -0
  51. data/lib/vault-tree/lock_smith/null_vault.rb +4 -0
  52. data/lib/vault-tree/lock_smith/random_number.rb +11 -0
  53. data/lib/vault-tree/lock_smith/shared_key_pair.rb +12 -0
  54. data/lib/vault-tree/lock_smith/signing_key_pair.rb +25 -0
  55. data/lib/vault-tree/lock_smith/symmetric_cipher.rb +25 -0
  56. data/lib/vault-tree/util/json.rb +16 -0
  57. data/lib/vault-tree/version.rb +3 -0
  58. data/spec/app/locksmith/asymmetric_cipher_spec.rb +25 -0
  59. data/spec/app/locksmith/signing_key_pair_spec.rb +22 -0
  60. data/spec/spec_helper.rb +5 -0
  61. data/spec/support/fixtures/blank_simple_test_contract.json +14 -0
  62. data/spec/support/fixtures/broken_contract.json +55 -0
  63. data/spec/support/fixtures/one_two_three-0.5.0.EXP.json +105 -0
  64. data/spec/support/fixtures/reference_contract.1.0.0.json +227 -0
  65. data/spec/support/fixtures/simple_test_contract.json +14 -0
  66. data/support/cookbooks/ark/.gitignore +12 -0
  67. data/support/cookbooks/ark/.kitchen.yml +34 -0
  68. data/support/cookbooks/ark/.travis.yml +6 -0
  69. data/support/cookbooks/ark/Berksfile +9 -0
  70. data/support/cookbooks/ark/CHANGELOG.md +87 -0
  71. data/support/cookbooks/ark/CONTRIBUTING.md +257 -0
  72. data/support/cookbooks/ark/README.md +301 -0
  73. data/support/cookbooks/ark/Rakefile +36 -0
  74. data/support/cookbooks/ark/TESTING.md +25 -0
  75. data/support/cookbooks/ark/Toftfile +15 -0
  76. data/support/cookbooks/ark/attributes/default.rb +6 -0
  77. data/support/cookbooks/ark/chefignore +96 -0
  78. data/support/cookbooks/ark/files/default/foo.tar.gz +0 -0
  79. data/support/cookbooks/ark/files/default/foo.tbz +0 -0
  80. data/support/cookbooks/ark/files/default/foo.tgz +0 -0
  81. data/support/cookbooks/ark/files/default/foo.zip +0 -0
  82. data/support/cookbooks/ark/files/default/tests/minitest/default_test.rb +0 -0
  83. data/support/cookbooks/ark/files/default/tests/minitest/support/helpers.rb +0 -0
  84. data/support/cookbooks/ark/files/default/tests/minitest/test_test.rb +94 -0
  85. data/support/cookbooks/ark/libraries/default.rb +167 -0
  86. data/support/cookbooks/ark/metadata.rb +13 -0
  87. data/support/cookbooks/ark/providers/default.rb +370 -0
  88. data/support/cookbooks/ark/recipes/default.rb +31 -0
  89. data/support/cookbooks/ark/recipes/test.rb +138 -0
  90. data/support/cookbooks/ark/resources/default.rb +54 -0
  91. data/support/cookbooks/ark/templates/default/add_to_path.sh.erb +1 -0
  92. data/support/cookbooks/ark/test/support/Gemfile +4 -0
  93. data/support/cookbooks/build-essential/README.md +24 -0
  94. data/support/cookbooks/build-essential/metadata.rb +10 -0
  95. data/support/cookbooks/build-essential/recipes/default.rb +45 -0
  96. data/support/cookbooks/chruby/.gitignore +15 -0
  97. data/support/cookbooks/chruby/.kitchen.yml +26 -0
  98. data/support/cookbooks/chruby/.ruby_version +1 -0
  99. data/support/cookbooks/chruby/Berksfile +3 -0
  100. data/support/cookbooks/chruby/Gemfile +7 -0
  101. data/support/cookbooks/chruby/LICENSE +14 -0
  102. data/support/cookbooks/chruby/README.md +92 -0
  103. data/support/cookbooks/chruby/Rakefile +7 -0
  104. data/support/cookbooks/chruby/Thorfile +6 -0
  105. data/support/cookbooks/chruby/Vagrantfile +86 -0
  106. data/support/cookbooks/chruby/attributes/default.rb +10 -0
  107. data/support/cookbooks/chruby/chefignore +96 -0
  108. data/support/cookbooks/chruby/metadata.rb +11 -0
  109. data/support/cookbooks/chruby/recipes/default.rb +43 -0
  110. data/support/cookbooks/chruby/recipes/system.rb +25 -0
  111. data/support/cookbooks/chruby/templates/default/chruby.sh.erb +22 -0
  112. data/support/cookbooks/chruby/test/integration/default/bash/embedded_test.sh +1 -0
  113. data/support/cookbooks/git/.gitignore +14 -0
  114. data/support/cookbooks/git/.kitchen.yml +46 -0
  115. data/support/cookbooks/git/Berksfile +8 -0
  116. data/support/cookbooks/git/CHANGELOG.md +87 -0
  117. data/support/cookbooks/git/CONTRIBUTING +29 -0
  118. data/support/cookbooks/git/Gemfile +3 -0
  119. data/support/cookbooks/git/LICENSE +201 -0
  120. data/support/cookbooks/git/README.md +115 -0
  121. data/support/cookbooks/git/TESTING.md +25 -0
  122. data/support/cookbooks/git/attributes/default.rb +40 -0
  123. data/support/cookbooks/git/metadata.rb +35 -0
  124. data/support/cookbooks/git/recipes/default.rb +53 -0
  125. data/support/cookbooks/git/recipes/server.rb +58 -0
  126. data/support/cookbooks/git/recipes/source.rb +49 -0
  127. data/support/cookbooks/git/recipes/windows.rb +37 -0
  128. data/support/cookbooks/git/templates/default/git-xinetd.d.erb +10 -0
  129. data/support/cookbooks/git/templates/default/sv-git-daemon-log-run.erb +2 -0
  130. data/support/cookbooks/git/templates/default/sv-git-daemon-run.erb +3 -0
  131. data/support/cookbooks/install_ruby/README.md +3 -0
  132. data/support/cookbooks/install_ruby/metadata.rb +10 -0
  133. data/support/cookbooks/install_ruby/recipes/default.rb +14 -0
  134. data/support/cookbooks/ruby_build/.gitignore +6 -0
  135. data/support/cookbooks/ruby_build/.kitchen.yml +31 -0
  136. data/support/cookbooks/ruby_build/.travis.yml +4 -0
  137. data/support/cookbooks/ruby_build/Berksfile +10 -0
  138. data/support/cookbooks/ruby_build/CHANGELOG.md +72 -0
  139. data/support/cookbooks/ruby_build/Gemfile +14 -0
  140. data/support/cookbooks/ruby_build/README.md +338 -0
  141. data/support/cookbooks/ruby_build/Rakefile +21 -0
  142. data/support/cookbooks/ruby_build/attributes/default.rb +67 -0
  143. data/support/cookbooks/ruby_build/chefignore +53 -0
  144. data/support/cookbooks/ruby_build/libraries/ruby_build_recipe_helpers.rb +40 -0
  145. data/support/cookbooks/ruby_build/metadata.rb +18 -0
  146. data/support/cookbooks/ruby_build/providers/ruby.rb +88 -0
  147. data/support/cookbooks/ruby_build/recipes/default.rb +69 -0
  148. data/support/cookbooks/ruby_build/resources/ruby.rb +33 -0
  149. data/support/cookbooks/ruby_build/test/cookbooks/alltherubies/metadata.rb +10 -0
  150. data/support/cookbooks/ruby_build/test/cookbooks/alltherubies/recipes/default.rb +59 -0
  151. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/_verify_tests.bash +33 -0
  152. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.8.7.bats +29 -0
  153. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.9.2.bats +18 -0
  154. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.9.3.bats +18 -0
  155. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_2.0.0.bats +18 -0
  156. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_jruby.bats +20 -0
  157. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_rbx.bats +18 -0
  158. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_ree.bats +19 -0
  159. data/support/cookbooks/ruby_build/test/integration/installation/bats/installation.bats +6 -0
  160. data/support/scripts/libsodium_ubuntu.sh +80 -0
  161. data/support/tasks/.gitkeep +0 -0
  162. data/support/tasks/libsodium_install.rb +57 -0
  163. data/vault-tree.gemspec +26 -0
  164. metadata +305 -0
@@ -0,0 +1,26 @@
1
+ # simple_cove generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Vagrant
19
+ .vagrant/
20
+ package.box
21
+
22
+ # ignore contracts directory
23
+ contracts/
24
+
25
+ # ignore built gem
26
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vault-tree (0.1.3)
5
+ rbnacl (= 1.1.0)
6
+ require_all
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ builder (3.2.2)
12
+ cucumber (1.3.8)
13
+ builder (>= 2.1.2)
14
+ diff-lcs (>= 1.1.3)
15
+ gherkin (~> 2.12.1)
16
+ multi_json (>= 1.7.5, < 2.0)
17
+ multi_test (>= 0.0.2)
18
+ diff-lcs (1.2.4)
19
+ ffi (1.9.3)
20
+ gherkin (2.12.2)
21
+ multi_json (~> 1.3)
22
+ multi_json (1.8.1)
23
+ multi_test (0.0.2)
24
+ rbnacl (1.1.0)
25
+ ffi
26
+ require_all (1.3.2)
27
+ rspec (2.14.1)
28
+ rspec-core (~> 2.14.0)
29
+ rspec-expectations (~> 2.14.0)
30
+ rspec-mocks (~> 2.14.0)
31
+ rspec-core (2.14.5)
32
+ rspec-expectations (2.14.3)
33
+ diff-lcs (>= 1.1.3, < 2.0)
34
+ rspec-mocks (2.14.3)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ bundler (~> 1.3)
41
+ cucumber
42
+ rspec
43
+ vault-tree!
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Andrew Bashelor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,118 @@
1
+ ## Vault Tree
2
+
3
+ _The Self Enforcing Contract_
4
+
5
+ Vault Tree is a collection of tools for building and executing distributed cryptographic contracts.
6
+
7
+ Before you begin make sure you checkout the [Vault Tree Homepage] for an overview of the project.
8
+
9
+ [Vault Tree Homepage]: http://www.vault-tree.org
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 Github [Contracts Repository] that acts as a focal point of collaboration for developers writing and testing interesting crytographic contracts
18
+
19
+ [Contracts Repository]: https://github.com/VaultTree/contracts
20
+
21
+ ### Install
22
+
23
+ Before you start:
24
+
25
+ * If you just want to use Vault Tree to build and execute contracts go to the [Contracts Repository].
26
+ * To use the library in your application or want to contribute code, you're in the right place.
27
+ * Before you pull the trigger on the install remember we have a Vagrant Box.
28
+
29
+ [Contracts Repository]: https://github.com/VaultTree/contracts
30
+
31
+ Okay, lets begin.
32
+
33
+ As a prerequisite get [libsodium] on you machine. This is the underlying cryptographic library that Vault Tree depends on.
34
+
35
+ [libsodium]: https://github.com/jedisct1/libsodium
36
+
37
+ * If you are on _OSX_ there is a [brew] package available. So just:
38
+
39
+ ```
40
+ brew install libsodium
41
+ ```
42
+
43
+ [brew]: http://brew.sh/
44
+
45
+ * If you're on a Debian based system, there is no _apt-get_ package that I know of, but there
46
+ are some helpful install scripts on the web. I've checked one of these in at:
47
+
48
+ ```
49
+ vault-tree/support/scripts/libsodium_ubuntu.sh
50
+ ```
51
+
52
+ * 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.
53
+
54
+ Now that you have libsodium, if you're a Ruby developer you know the drill from here:
55
+
56
+ ```
57
+ gem install vault-tree
58
+ ```
59
+
60
+ and then
61
+
62
+ ```
63
+ require 'vault-tree'
64
+ ```
65
+
66
+ somewhere before you use it.
67
+
68
+
69
+ ### Vagrant
70
+
71
+ 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!
72
+
73
+ * Follow the [Vagrant] download and install steps
74
+ * Clone the Vault Tree Repo and go into it:
75
+
76
+ [Vagrant]: http://www.vagrantup.com/
77
+
78
+ ```
79
+ git clone git@github.com:VaultTree/vault-tree.git
80
+ cd ~/path/to/vault-tree/
81
+ ```
82
+
83
+ Now you just need to Vagrant Up!
84
+
85
+ ```
86
+ vagrant up
87
+ ```
88
+
89
+ This will download and boot a pre-packaged Linux virtual machine with Vault-Tree and all dependencies already installed.
90
+
91
+ Once your VM is downloaded and built. You can go inside with:
92
+
93
+ ```
94
+ vagrant shh
95
+ ```
96
+
97
+ As a developer working on Vault Tree you can now go to the VM's directory:
98
+
99
+ ```
100
+ /vagrant
101
+ ```
102
+
103
+ and run `rake`. This will run all the tests and put you in a good spot to start exploring the code.
104
+
105
+ 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.
106
+
107
+ [sync your files]: http://docs.vagrantup.com/v2/getting-started/synced_folders.html
108
+
109
+ ### Is it production ready?
110
+
111
+ Absolutely not. We have a long way to go.
112
+
113
+ Here are some of the big issues that I could use your help on as we move to version 1.0:
114
+
115
+ * This is a crypto application so vulnerabilities need to be identified and corrected. We need more eyes in this area.
116
+ * We we need to figure out if the supported keywords are sufficient to implement basic secure computation schemes.
117
+ - For example, Digital Signatures and HMACs are not implemented but could be.
118
+ - Should they be implemented? What is the use case? Ect. We need to have these conversations.
@@ -0,0 +1,17 @@
1
+ require_relative 'lib/vault-tree.rb'
2
+ require 'cucumber'
3
+ require 'cucumber/rake/task'
4
+ require 'rspec/core/rake_task'
5
+ require "bundler/gem_tasks"
6
+
7
+ task :default => 'spec'
8
+
9
+ Cucumber::Rake::Task.new('cuke') do |t|
10
+ # -r means you require all support files first
11
+ # this allows you to organize and run by subdirectory
12
+ t.cucumber_opts = "-r features features --format pretty"
13
+ end
14
+
15
+ task :spec => 'cuke' do
16
+ STDOUT.write %x[rspec --format doc]
17
+ end
@@ -0,0 +1,30 @@
1
+ Vagrant::Config.run do |config|
2
+ config.vm.box = "vault-tree-box"
3
+ config.vm.box_url = "http://vault-tree-box.s3.amazonaws.com/package.box"
4
+ #config.vm.provision :chef_solo do |chef|
5
+ # chef.cookbooks_path = "support/cookbooks"
6
+ # chef.add_recipe("git")
7
+ # chef.add_recipe("build-essential")
8
+ # chef.add_recipe("ruby_build")
9
+ # chef.add_recipe("chruby")
10
+ # chef.add_recipe("install_ruby")
11
+ #end
12
+ end
13
+
14
+ module VagrantHelpers
15
+ module PathHelpers
16
+ extend self
17
+
18
+ def provision_dir
19
+ "#{project_dir}/lib/vagrant"
20
+ end
21
+
22
+ def project_dir
23
+ File.expand_path(current_dir_rel)
24
+ end
25
+
26
+ def current_dir_rel
27
+ File.dirname(__FILE__)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,44 @@
1
+ Feature: Core Functionality
2
+
3
+ Scenario: Close And Open With Master Password
4
+ Given I have a blank reference contract
5
+ When I lock a message in a vault with my Master Password
6
+ Then I can recover the message with my Master Password
7
+
8
+ Scenario: Close And Open With Random Key
9
+ Given I have a blank reference contract
10
+ When I lock away a random vault key
11
+ And I use the random key to lock a message
12
+ Then I can recover the message with the Random Key
13
+
14
+ Scenario: Transfer Key Via Unlocked Vault
15
+ Given I have a blank reference contract
16
+ When I lock away a random vault key
17
+ And I use the random key to lock a message
18
+ And I put this random key in an unlocked vault
19
+ Then another user can recover the message with the Unlocked Random Key
20
+
21
+ Scenario: Asymmetric Vault
22
+ Given I have a blank reference contract
23
+ And I have access to the another user's unlocked public key
24
+ And I lock a simple message with a shared key
25
+ When I transfer the contract to the other user
26
+ Then they can create a shared key and unlock the message
27
+
28
+ Scenario: Example - Alice and Bob Execute a One Two Three Contract
29
+ Given Alice has the blank contract
30
+ When she locks all of her attributes
31
+ And she sends the contract to Bob
32
+ Then Bob can access her public attributes
33
+ When Bob locks his attributes
34
+ And He fills and locks each of the three vaults
35
+ Then Alice can execute the contract to recover the final message
36
+
37
+ Scenario: Example - A Simple Block Chain Key Transfer
38
+ Given the SENDER has the blank BTC Key Transfer template
39
+ And the SENDER chooses an origin wallet address and concealed destination address
40
+ And he locks away the secret BTC signing key
41
+ When the SENDER transfers the Vault-Tree contract to the RECEIVER
42
+ Then the RECEIVER can access the origin wallet address
43
+ When the SENDER reveals the hidden wallet address by Blockchain payment from the origin address
44
+ Then the RECEIVER can unlock the vault to recover the transfered signing key
@@ -0,0 +1,41 @@
1
+ Feature: Vault Tree Exceptions
2
+
3
+ Scenario: Empty Vault
4
+ Given the broken contract
5
+ When I attempt to open an empty vault
6
+ Then an EmptyVault exception is raised
7
+
8
+ Scenario: Attempted Fill with Master Password
9
+ Given the broken contract
10
+ When I attempt fill a vault with my Master Password
11
+ Then a FillAttemptMasterPassword exception is raised
12
+
13
+ Scenario: Missing External Data
14
+ Given the broken contract
15
+ When I attempt fill a vault with External Data that does not exists
16
+ Then a MissingExternalData exception is raised
17
+
18
+ Scenario: Missing Passphrase
19
+ Given a valid blank contract
20
+ When I attempt fill a vault without providing a master passphrase
21
+ Then a MissingPassphrase exception is raised
22
+
23
+ Scenario: Unsupported Keyword
24
+ Given the broken contract
25
+ When I attempt fill a vault with an unsupported Keyword
26
+ Then an UnsupportedKeyword exception is raised
27
+
28
+ Scenario: Vault Does Not Exists on Retrieval
29
+ Given the broken contract
30
+ When I attempt to open a vault that does not exists
31
+ Then a VaultDoesNotExist exception is raised
32
+
33
+ Scenario: Vault Does Not Exists on Closing
34
+ Given the broken contract
35
+ When I attempt to close a vault that does not exists
36
+ Then a VaultDoesNotExist exception is raised
37
+
38
+ Scenario: Missing Partner Decryption Key
39
+ Given the broken contract
40
+ When I attempt to fill with an encryption key without first establishing the decryption key
41
+ Then a MissingPartnerDecryptionKey exception is raised
@@ -0,0 +1,168 @@
1
+ Given(/^Alice has the blank contract$/) do
2
+ contract_path = VaultTree::PathHelpers.reference_contract
3
+ @contract_json = File.read(contract_path)
4
+ end
5
+
6
+ # Change this to just attributes vice public attributes
7
+ When(/^she locks all of her attributes$/) do
8
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'ALICE_SECURE_PASS', external_data: {})
9
+ @contract = @contract.close_vault('alice_decryption_key')
10
+ @contract = @contract.close_vault('alice_public_encryption_key')
11
+ end
12
+
13
+ When(/^she sends the contract to Bob$/) do
14
+ @contract_json = @contract.as_json
15
+ @bobs_external_data = {"congratulations_message" => "CONGRATS! YOU OPENED THE THIRD VAULT."}
16
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'BOB_SECURE_PASS', external_data: @bobs_external_data)
17
+ end
18
+
19
+ Then(/^Bob can access her public attributes$/) do
20
+ @contents = @contract.retrieve_contents('alice_public_encryption_key')
21
+ end
22
+
23
+ When(/^Bob locks his attributes$/) do
24
+
25
+ @contract = @contract.close_vault('bob_decryption_key')
26
+ # Verify can reopen
27
+ @contract.retrieve_contents('bob_decryption_key')
28
+
29
+ @contract = @contract.close_vault('congratulations_message')
30
+ # Verify can reopen
31
+ @contract.retrieve_contents('congratulations_message')
32
+
33
+ @contract = @contract.close_vault('vault_two_key')
34
+ # Verify they can reopen
35
+ @contract.retrieve_contents('vault_two_key')
36
+
37
+ @contract = @contract.close_vault('vault_three_key')
38
+ # Verify they can reopen
39
+ @contract.retrieve_contents('vault_three_key')
40
+
41
+ @contract = @contract.close_vault('bob_public_encryption_key')
42
+ # Verify they can reopen
43
+ @contract.retrieve_contents('bob_public_encryption_key')
44
+ end
45
+
46
+ When(/^He fills and locks each of the three vaults$/) do
47
+ @contract = @contract.close_vault('first')
48
+ @contract = @contract.close_vault('second')
49
+ @contract = @contract.close_vault('third')
50
+ end
51
+
52
+ Then(/^Alice can execute the contract to recover the final message$/) do
53
+ @contract_json = @contract.as_json
54
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'ALICE_SECURE_PASS', external_data: {})
55
+ puts @contract.retrieve_contents('third')
56
+ @contract.retrieve_contents('third').should == @bobs_external_data['congratulations_message']
57
+ end
58
+
59
+ Given(/^the SENDER has the blank BTC Key Transfer template$/) do
60
+ contract_path = VaultTree::PathHelpers.reference_contract
61
+ @contract_json = File.read(contract_path)
62
+ end
63
+
64
+ Given(/^the SENDER chooses an origin wallet address and concealed destination address$/) do
65
+ @sender_external_data =
66
+ {
67
+ 'sender_origin_wallet_address' => '1XJEBF8EUBF855NEBHVENPFE9JE74E',
68
+ 'sender_concealed_destination_wallet_address' => '1JVKE8HD5JDHFEJHF678JEH8DEJGHE',
69
+ 'sender_btc_signing_key' => 'BITCOIN_SIGNING_KEY_KEEP_IT_SECRET'
70
+ }
71
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'SENDER_SECURE_PASS', external_data: @sender_external_data)
72
+ @contract = @contract.close_vault('sender_origin_wallet_address')
73
+ @contract = @contract.close_vault('sender_concealed_destination_wallet_address')
74
+ end
75
+
76
+ Given(/^he locks away the secret BTC signing key$/) do
77
+ @contract = @contract.close_vault('sender_btc_signing_key')
78
+ end
79
+
80
+ When(/^the SENDER transfers the Vault\-Tree contract to the RECEIVER$/) do
81
+ @contract_json_over_the_wire = @contract.as_json
82
+ @contract = VaultTree::Contract.new(@contract_json_over_the_wire, master_passphrase: 'RECEIVER_SECURE_PASS')
83
+ end
84
+
85
+ Then(/^the RECEIVER can access the origin wallet address$/) do
86
+ @contract.retrieve_contents('sender_origin_wallet_address').should == @sender_external_data['sender_origin_wallet_address']
87
+ end
88
+
89
+ When(/^the SENDER reveals the hidden wallet address by Blockchain payment from the origin address$/) do
90
+ @contract_json = @contract.as_json # save the json state
91
+ wallet_address_from_watching_blockchain = @sender_external_data['sender_concealed_destination_wallet_address']
92
+ @receiver_external_data = { 'receiver_revealed_destination_wallet_address' => wallet_address_from_watching_blockchain}
93
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'RECEIVER_SECURE_PASS', external_data: @receiver_external_data)
94
+ @contract = @contract.close_vault('receiver_revealed_destination_wallet_address')
95
+ end
96
+
97
+ Then(/^the RECEIVER can unlock the vault to recover the transfered signing key$/) do
98
+ transfered_secret_key = @contract.retrieve_contents('sender_btc_signing_key')
99
+ transfered_secret_key.should == @sender_external_data['sender_btc_signing_key']
100
+ puts "PROPERLY TRANSFERED: #{transfered_secret_key} !"
101
+ end
102
+
103
+ Given(/^I have a blank reference contract$/) do
104
+ contract_path = VaultTree::PathHelpers.reference_contract
105
+ @contract_json = File.read(contract_path)
106
+ end
107
+
108
+ When(/^I lock a message in a vault with my Master Password$/) do
109
+ @external_data = {"message" => "CONGRATS! YOU OPENED THE VAULT."}
110
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'MY_SECURE_PASS', external_data: @external_data)
111
+ @contract = @contract.close_vault('message')
112
+ end
113
+
114
+ Then(/^I can recover the message with my Master Password$/) do
115
+ @contract.retrieve_contents('message').should == @external_data['message']
116
+ end
117
+
118
+ When(/^I lock away a random vault key$/) do
119
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'MY_SECURE_PASS')
120
+ @contract = @contract.close_vault('random_vault_key')
121
+ end
122
+
123
+ When(/^I use the random key to lock a message$/) do
124
+ @external_data = {"message_locked_with_random" => "CONGRATS! YOU OPENED THE VAULT WITH A RANDOM KEY."}
125
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'MY_SECURE_PASS', external_data: @external_data)
126
+ @contract = @contract.close_vault('message_locked_with_random')
127
+ end
128
+
129
+ Then(/^I can recover the message with the Random Key$/) do
130
+ @contract.retrieve_contents('message_locked_with_random').should == @external_data['message_locked_with_random']
131
+ end
132
+
133
+ When(/^I put this random key in an unlocked vault$/) do
134
+ @contract = @contract.close_vault('unlocked_random_key')
135
+ end
136
+
137
+ Then(/^another user can recover the message with the Unlocked Random Key$/) do
138
+ @contract = @contract.close_vault('message_locked_with_unlocked_random_number')
139
+ @contract_json = @contract.as_json
140
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'ANOTHER_SECURE_PASS')
141
+ @contract.retrieve_contents('message_locked_with_unlocked_random_number').should == @external_data['message_locked_with_random']
142
+ end
143
+
144
+ Given(/^I have access to the another user's unlocked public key$/) do
145
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'ANOTHER_USERS_SECURE_PASS')
146
+ @contract = @contract.close_vault('another_decryption_key')
147
+ @contract = @contract.close_vault('another_public_key')
148
+ @contract_json = @contract.as_json
149
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'MY_SECURE_PASS')
150
+ @contract = @contract.close_vault('my_decryption_key')
151
+ @contract = @contract.close_vault('my_public_key')
152
+ end
153
+
154
+ Given(/^I lock a simple message with a shared key$/) do
155
+ @contract_json = @contract.as_json
156
+ @external_data = {"asymmetric_message" => "CONGRATS! YOU OPENED THE ASYMMETRIC VAULT."}
157
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'MY_SECURE_PASS', external_data: @external_data)
158
+ @contract = @contract.close_vault('asymmetric_message')
159
+ end
160
+
161
+ When(/^I transfer the contract to the other user$/) do
162
+ @contract_json = @contract.as_json
163
+ @contract = VaultTree::Contract.new(@contract_json, master_passphrase: 'ANOTHER_USERS_SECURE_PASS')
164
+ end
165
+
166
+ Then(/^they can create a shared key and unlock the message$/) do
167
+ @contract.retrieve_contents('asymmetric_message').should == @external_data['asymmetric_message']
168
+ end