murky_waters 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddabc4768dc37914843c2d5e31c6b2cc693221ea
4
- data.tar.gz: 91f223fd9b0fc68753cb128201a2e3857a6134f0
3
+ metadata.gz: 846c20ecb1f9c842eaa08570f3bd29c22616ebb3
4
+ data.tar.gz: 44c1fce9c1cbe69d02b4781869903e9313a037f9
5
5
  SHA512:
6
- metadata.gz: 9048fbcbc85cf53a691e099208aeaf6421fd49053e208b96412a8fbcbddcba37a945f6052fafb8ccd007bcba38174f764c5b84499bab76fc29c30a6c9298415b
7
- data.tar.gz: 49d71d715e86a65029cbfb5cbc0665737d52ea6e58ef7cafd74bbc876c4f40f260c3dc31e5ced44c5d33c452dcd5ce98236ad1bb83c10b96c1e8db7bbd852291
6
+ metadata.gz: 52cdfe5a8cea44c0cc5c2070e6d9742e60034d398813b522a8ece4372a369dd11bcb2078b820d9b08283ccbc313a95e91f79e36f46c84fc0ee478c588f29346d
7
+ data.tar.gz: 12469b898075db70294dbb083ab9b4a50c89634fe8e70fed9151b539a8edb47447565e1aafd85fd3121bbb69d4c9d7938fe71b2405241d93170d77fa988d09ce
data/README.md CHANGED
@@ -50,10 +50,10 @@ To accesss, add and remove data to be indexed in our dict
50
50
  dict.delete("hello") # Delete data
51
51
  dict["hello"] # Retrieve data
52
52
  dict.siblings("hello") # => [
53
- # "OLpNd02wZa5e2XMKG/8rFMUKFVUq/yy6F+c3Rd09eKc=\n",
54
- # "GySoYGQjpOMz62o7F56Al67mVjB9IP5GxpBmbQvp3wc=\n"
53
+ # "\xB0\x1F0Ji\ri\xE3\xFBMI\x9FU:=\xFF\xC3t\xD1\xCA6v\x11}'Q\x8E\xCD\x16t\xF4{",
54
+ # "C\xEE\x89iS$s\xA9\xBE\xCD:\xD3ob\xE5\x8C\xBC\xE3g\x04\x00\x85Z\xBE@\x8Bu\xE4(\eR\xB4",
55
+ # "\xC9\xDCj6\xC3g\f\xB2\xCEr\x05\xFB\xA4[\x06\xF5--q\xFA\xA4\xE9\x95c\xB0\xC8]\xB5\xBD\x1D\xC5\x12"
55
56
  # ]
56
-
57
57
  dict.root # "anajKi18I3C9TlVEcU//hZsw9i4sknlYCTspTQXxCr0=\n" # The merkle root/signature of our entire dictionary contents
58
58
  ```
59
59
 
@@ -61,38 +61,28 @@ To accesss, add and remove data to be indexed in our dict
61
61
  ```ruby
62
62
  # Generate a proof that "hello" exists inside of our dictionary and a merkle root/signature for our entire dictionary contents
63
63
  dict.proof("hello")
64
- # => #<Murky::Proof:0x007f9d1ef5c810
65
- # @digest=
66
- # #<Digest::SHA256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>,
67
- # @root="anajKi18I3C9TlVEcU//hZsw9i4sknlYCTspTQXxCr0=\n",
64
+ # => #<Murky::Proof:0x007fc9c2f1ef30
65
+ # @digest=#<Digest::SHA256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>,
66
+ # @root="\x80\xF5\x9F\xFF\xAD\xC2-\x85t\xCCY\xC8\x90\xBB\x9D\xC2\x16@\x02-\x1C&k\xB8>\xA6\xC3[\x8C'I\xE6",
68
67
  # @siblings=
69
- # ["47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n",
70
- # "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n",
71
- # "qZDReXdlGqrjRUZy3nSfWXY6y8KYxwb+A7K6/Xg7Nxc=\n",
72
- # "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n",
73
- # "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n",
74
- # "jqwjgWe5ZVi9USkRcycxwiXtFtSLbycfKHJRJ8Scm3A=\n",
75
- # "ujOfV44N03rF/+m6+eONFRPJYmstEnhsh2YcKdIUyVU=\n"],
68
+ # ["\xB0\x1F0Ji\ri\xE3\xFBMI\x9FU:=\xFF\xC3t\xD1\xCA6v\x11}'Q\x8E\xCD\x16t\xF4{",
69
+ # "C\xEE\x89iS$s\xA9\xBE\xCD:\xD3ob\xE5\x8C\xBC\xE3g\x04\x00\x85Z\xBE@\x8Bu\xE4(\eR\xB4",
70
+ # "}q\x80\xE0:\xD1Am\xDB.@g\xDE\xE8u\xC1h\xD92\x8F\x19l\xAD]\x02)I\rn\xC1z\x96"],
71
+ # @signature="\x90\xE3\xC8\xFCn\x86\x15\"\x94\x84`\xEC\xFB\xC2\xEE^;\xDD\x9B\xF1\x89\v\xE04u\r\xE4\b\xA5\xE0$l",
76
72
  # @valid=true>
73
+ #
77
74
  ```
75
+
78
76
  ### Verification
79
77
  ```ruby
80
78
  # Perform a verification for a root, and a merkle path/sibling list and some value.
81
79
  It verifies that this value resides in the dictionary represented by our root signature. From this we can conclude that the size, shape and order of the tree for this merkle root are unchanged from when this proof was generated and that our value does indeed exist within the dictionary.
82
80
 
83
- # Murky.verify(root, siblings, value) # => true/false
81
+ # Murky.verify(root, siblings, data) # => true/false
84
82
  Murky.verify(
85
- "EpU7Zx9tzTCGGyQtNQgC5Iu8IxRlXFjwG7KCjqfuRwI=\n",
86
- [
87
- "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n",
88
- "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n",
89
- "qZDReXdlGqrjRUZy3nSfWXY6y8KYxwb+A7K6/Xg7Nxc=\n",
90
- "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n",
91
- "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n",
92
- "jqwjgWe5ZVi9USkRcycxwiXtFtSLbycfKHJRJ8Scm3A=\n",
93
- "ujOfV44N03rF/+m6+eONFRPJYmstEnhsh2YcKdIUyVU=\n"
94
- ],
95
- "world"
83
+ root,
84
+ siblings,
85
+ data
96
86
  ) # => true if verification passes
97
87
  ```
98
88
  A tree can optionally be backed by any dictionary like data structure to store the real leaf data.
@@ -1,5 +1,6 @@
1
1
  module Murky
2
2
  class Dict
3
+ include Enumerable
3
4
  attr_reader :root
4
5
 
5
6
  def initialize(data: {}, digest: Digest::SHA256.new)
@@ -55,6 +56,10 @@ module Murky
55
56
  @root = @changed ? compute_root : @root
56
57
  end
57
58
 
59
+ def each(&block)
60
+ data.each(&block)
61
+ end
62
+
58
63
  def proof(key)
59
64
  Proof.new({
60
65
  root: root,
@@ -80,11 +85,11 @@ module Murky
80
85
  end
81
86
 
82
87
  def to_s
83
- "Murky::Dict(#{data.to_s})"
88
+ "Murky::Dict(data: #{data.to_s})"
84
89
  end
85
90
 
86
91
  def inspect
87
- "Murky::Dict(#{data.inspect})"
92
+ "Murky::Dict(data: #{data.inspect})"
88
93
  end
89
94
 
90
95
  private
@@ -1,3 +1,3 @@
1
1
  module Murky
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.bindir = "exe"
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "simplecov"
26
28
  spec.add_development_dependency "bundler", "~> 1.15"
27
29
  spec.add_development_dependency "rake", "~> 10.0"
28
30
  spec.add_development_dependency "minitest", "~>5.8.4"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: murky_waters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
@@ -10,6 +10,34 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2017-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement