oydid 0.4.4 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/oydid/basic.rb +149 -33
  4. data/lib/oydid/didcomm.rb +9 -9
  5. data/lib/oydid/log.rb +14 -7
  6. data/lib/oydid/vc.rb +308 -0
  7. data/lib/oydid.rb +305 -112
  8. data/spec/input/basic/sample_b16_dec.doc +1 -0
  9. data/spec/input/basic/sample_b17_edec.doc +1 -0
  10. data/spec/input/basic/sample_b32_dec.doc +1 -0
  11. data/spec/input/basic/sample_b58_enc.doc +1 -0
  12. data/spec/input/basic/sample_b64_dec.doc +1 -0
  13. data/spec/input/basic/sample_b64_enc.doc +1 -0
  14. data/spec/input/basic/sample_blake2b-16_b16_hash.doc +1 -0
  15. data/spec/input/basic/sample_blake2b-32_b32_hash.doc +1 -0
  16. data/spec/input/basic/sample_blake2b-64_b58_hash.doc +1 -0
  17. data/spec/input/basic/sample_invalid2_readkey.doc +1 -1
  18. data/spec/input/basic/sample_invalid3_readkey.doc +1 -1
  19. data/spec/input/basic/sample_readkey.doc +1 -1
  20. data/spec/input/basic/sample_sha2-256_b58_hash.doc +1 -0
  21. data/spec/input/basic/sample_sha2-512_b58_hash.doc +1 -0
  22. data/spec/input/basic/sample_sha3-224_b64_hash.doc +1 -0
  23. data/spec/output/basic/sample_b16_dec.doc +1 -0
  24. data/spec/output/basic/sample_b16_enc.doc +1 -0
  25. data/spec/output/basic/sample_b17_edec.doc +2 -0
  26. data/spec/output/basic/sample_b17_enc.doc +1 -0
  27. data/spec/output/basic/sample_b32_dec.doc +1 -0
  28. data/spec/output/basic/sample_b32_enc.doc +1 -0
  29. data/spec/output/basic/sample_b58_dec.doc +1 -0
  30. data/spec/output/basic/sample_b64_dec.doc +1 -0
  31. data/spec/output/basic/sample_b64_enc.doc +1 -0
  32. data/spec/output/basic/sample_blake2b-16_b16_hash.doc +1 -0
  33. data/spec/output/basic/sample_blake2b-32_b32_hash.doc +1 -0
  34. data/spec/output/basic/sample_blake2b-64_b58_hash.doc +1 -0
  35. data/spec/output/basic/sample_sha2-512_b58_hash.doc +1 -0
  36. data/spec/output/basic/sample_sha3-224_b64_hash.doc +1 -0
  37. data/spec/oydid_spec.rb +95 -13
  38. metadata +72 -19
  39. /data/spec/input/basic/{sample_enc.doc → sample_b16_enc.doc} +0 -0
  40. /data/spec/input/basic/{sample_hash.doc → sample_b17_enc.doc} +0 -0
  41. /data/spec/{output/basic/sample_dec.doc → input/basic/sample_b32_enc.doc} +0 -0
  42. /data/spec/input/basic/{sample_dec.doc → sample_b58_dec.doc} +0 -0
  43. /data/spec/output/basic/{sample_enc.doc → sample_b58_enc.doc} +0 -0
  44. /data/spec/output/basic/{sample_hash.doc → sample_sha2-256_b58_hash.doc} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56c65853f4983bcb8214a4027986839c0503adcc1133933f817d8401d8881be7
4
- data.tar.gz: 2a6048ab2023f8641e83e7b0162a8c15ef6bdb2c0855d70cef8d6c015ca34720
3
+ metadata.gz: 171ab373123506d42a8dd20b80df654ebd3cf35ac1d53e65f36580b4a3d92374
4
+ data.tar.gz: 2bab378e7f1d284f7e730f32acb52964f7c84456ae5a41a786429d0f6ff11134
5
5
  SHA512:
6
- metadata.gz: 799e94f77486d60beb09c8b8f5101ac5789eb1d000052a1aa396121acbd13e0a935cb06fe0c1849ef4deb75b407da049d1111bd15f0d49bd2863671419da4480
7
- data.tar.gz: d513c74e0b307a74a9c7fced1bd3ce5bdaef1941290a70aef447a183e3e31da5c44582d25969cd401ec25379412fb7850d55e5e547972e87ee39e4297e79866c
6
+ metadata.gz: e3d84952f40b4b7680f1c49cb351516b25b901f696f4db73222a3a5f82a645ee23da62881f24237e29cac195da2857f4392ab289ba78d29f83a14332d970ea91
7
+ data.tar.gz: 555e144d9581d897b91eadd480267c9e76bfed1145077cf524537d13cc571be3efca39512aefdb7ce798390de22fc87ea922ac6e53db3e67dfba8dfa65cedd08
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.5.4
data/lib/oydid/basic.rb CHANGED
@@ -4,16 +4,79 @@
4
4
  class Oydid
5
5
 
6
6
  # basic functions ---------------------------
7
- def self.encode(message, method = "base58btc")
8
- Multibases.pack(method, message).to_s
7
+ # %w[multibases multihashes rbnacl json].each { |f| require f }
8
+ def self.multi_encode(message, options)
9
+ method = options[:encode] || DEFAULT_ENCODING rescue DEFAULT_ENCODING
10
+ case method
11
+ when *SUPPORTED_ENCODINGS
12
+ return [Multibases.pack(method, message).to_s, ""]
13
+ else
14
+ return [nil, "unsupported encoding: '" + method + "'"]
15
+ end
9
16
  end
10
17
 
11
- def self.decode(message)
12
- Multibases.unpack(message).decode.to_s('ASCII-8BIT')
18
+ def self.multi_decode(message)
19
+ begin
20
+ [Multibases.unpack(message).decode.to_s('ASCII-8BIT'), ""]
21
+ rescue => error
22
+ [nil, error.message]
23
+ end
13
24
  end
14
25
 
15
26
  def self.hash(message)
16
- encode(Multihashes.encode(RbNaCl::Hash.sha256(message), "sha2-256").unpack('C*'))
27
+ return multi_hash(message, {:digest => DEFAULT_DIGEST}).first
28
+ end
29
+
30
+ def self.multi_hash(message, options)
31
+ method = options[:digest] || DEFAULT_DIGEST
32
+ case method.to_s
33
+ when "sha2-256"
34
+ digest = RbNaCl::Hash.sha256(message)
35
+ when "sha2-512"
36
+ digest = RbNaCl::Hash.sha512(message)
37
+ when "sha3-224", "sha3-256", "sha3-384", "sha3-512"
38
+ digest = OpenSSL::Digest.digest(method, message)
39
+ when "blake2b-16"
40
+ digest = RbNaCl::Hash.blake2b(message, {digest_size: 16})
41
+ when "blake2b-32"
42
+ digest = RbNaCl::Hash.blake2b(message, {digest_size: 32})
43
+ when "blake2b-64"
44
+ digest = RbNaCl::Hash.blake2b(message)
45
+ else
46
+ return [nil, "unsupported digest: '" + method.to_s + "'"]
47
+ end
48
+ encoded = multi_encode(Multihashes.encode(digest, method.to_s), options)
49
+ if encoded.first.nil?
50
+ return [nil, encoded.last]
51
+ else
52
+ return [encoded.first, ""]
53
+ end
54
+ end
55
+
56
+ def self.get_digest(message)
57
+ retVal = Multihashes.decode Oydid.multi_decode(message).first
58
+ if retVal[:hash_function].to_s != ""
59
+ return [retVal[:hash_function].to_s, ""]
60
+ end
61
+ case Oydid.multi_decode(message).first[0..1].to_s
62
+ when "\x02\x10"
63
+ return ["blake2b-16", ""]
64
+ when "\x04 "
65
+ return ["blake2b-32", ""]
66
+ when "\b@"
67
+ return ["blake2b-64", ""]
68
+ else
69
+ return [nil, "unknown digest"]
70
+ end
71
+ end
72
+
73
+ def self.get_encoding(message)
74
+ # from https://github.com/multiformats/multibase/blob/master/multibase.csv
75
+ begin
76
+ [Multibases.unpack(message).encoding, ""]
77
+ rescue => error
78
+ [nil, error.message]
79
+ end
17
80
  end
18
81
 
19
82
  def self.canonical(message)
@@ -27,11 +90,11 @@ class Oydid
27
90
 
28
91
  def self.percent_encode(did)
29
92
  # remove "https://" from string as it is default
30
- did = did.sub("https://","").sub("@", "%40").sub("http://","http%3A%2F%2F")
93
+ did = did.sub("https://","").sub("@", "%40").sub("http://","http%3A%2F%2F").gsub(":","%3A").sub("did%3Aoyd%3A", "did:oyd:")
31
94
  end
32
95
 
33
96
  # key management ----------------------------
34
- def self.generate_private_key(input, method = "ed25519-priv")
97
+ def self.generate_private_key(input, method = "ed25519-priv", options)
35
98
  begin
36
99
  omc = Multicodecs[method].code
37
100
  rescue
@@ -49,11 +112,16 @@ class Oydid
49
112
  return [nil, "unsupported key codec"]
50
113
  end
51
114
  length = raw_key.bytesize
52
- return [encode([omc, length, raw_key].pack("SCa#{length}")), ""]
115
+ encoded = multi_encode([omc, length, raw_key].pack("SCa#{length}"), options)
116
+ if encoded.first.nil?
117
+ return [nil, encoded.last]
118
+ else
119
+ return [encoded.first, ""]
120
+ end
53
121
  end
54
122
 
55
- def self.public_key(private_key, method = "ed25519-pub")
56
- code, length, digest = decode(private_key).unpack('SCa*')
123
+ def self.public_key(private_key, options, method = "ed25519-pub")
124
+ code, length, digest = multi_decode(private_key).first.unpack('SCa*')
57
125
  case Multicodecs[code].name
58
126
  when 'ed25519-priv'
59
127
  case method
@@ -65,18 +133,49 @@ class Oydid
65
133
  return [nil, "unsupported key codec"]
66
134
  end
67
135
  length = public_key.to_bytes.bytesize
68
- return [encode([Multicodecs[method].code, length, public_key].pack("CCa#{length}")), ""]
69
-
136
+ encoded = multi_encode([Multicodecs[method].code, length, public_key].pack("CCa#{length}"), options)
137
+ if encoded.first.nil?
138
+ return [nil, encoded.last]
139
+ else
140
+ return [encoded.first, ""]
141
+ end
70
142
  else
71
143
  return [nil, "unsupported key codec"]
72
144
  end
73
145
  end
74
146
 
75
- def self.sign(message, private_key)
76
- code, length, digest = decode(private_key).unpack('SCa*')
147
+ def self.getPubKeyFromDID(did)
148
+ identifier = did.split(LOCATION_PREFIX).first.split(CGI.escape LOCATION_PREFIX).first rescue did
149
+ identifier = identifier.delete_prefix("did:oyd:")
150
+
151
+ # check if identifier is already PubKey
152
+ if decode_public_key(identifier).first.nil?
153
+ did_document, msg = read(did, {})
154
+ if did_document.nil?
155
+ return [nil, msg]
156
+ exit
157
+ end
158
+ pubKey = did_document["doc"]["key"].split(":").first rescue nil
159
+ if pubKey.nil?
160
+ return [nil, "cannot resolve " + did.to_s]
161
+ else
162
+ return [pubKey, ""]
163
+ end
164
+ else
165
+ return [identifier, ""]
166
+ end
167
+ end
168
+
169
+ def self.sign(message, private_key, options)
170
+ code, length, digest = multi_decode(private_key).first.unpack('SCa*')
77
171
  case Multicodecs[code].name
78
172
  when 'ed25519-priv'
79
- return [encode(Ed25519::SigningKey.new(digest).sign(message)), ""]
173
+ encoded = multi_encode(Ed25519::SigningKey.new(digest).sign(message), options)
174
+ if encoded.first.nil?
175
+ return [nil, encoded.last]
176
+ else
177
+ return [encoded.first, ""]
178
+ end
80
179
  else
81
180
  return [nil, "unsupported key codec"]
82
181
  end
@@ -84,13 +183,13 @@ class Oydid
84
183
 
85
184
  def self.verify(message, signature, public_key)
86
185
  begin
87
- code, length, digest = decode(public_key).unpack('CCa*')
186
+ code, length, digest = multi_decode(public_key).first.unpack('CCa*')
88
187
  case Multicodecs[code].name
89
188
  when 'ed25519-pub'
90
189
  verify_key = Ed25519::VerifyKey.new(digest)
91
190
  signature_verification = false
92
191
  begin
93
- verify_key.verify(decode(signature), message)
192
+ verify_key.verify(multi_decode(signature).first, message)
94
193
  signature_verification = true
95
194
  rescue Ed25519::VerifyError
96
195
  signature_verification = false
@@ -104,9 +203,9 @@ class Oydid
104
203
  end
105
204
  end
106
205
 
107
- def self.encrypt(message, public_key)
206
+ def self.encrypt(message, public_key, options)
108
207
  begin
109
- code, length, digest = decode(public_key).unpack('CCa*')
208
+ code, length, digest = multi_decode(public_key).first.unpack('CCa*')
110
209
  case Multicodecs[code].name
111
210
  when 'x25519-pub'
112
211
  pubKey = RbNaCl::PublicKey.new(digest)
@@ -130,11 +229,11 @@ class Oydid
130
229
  end
131
230
  end
132
231
 
133
- def self.decrypt(message, private_key)
232
+ def self.decrypt(message, private_key, options)
134
233
  begin
135
234
  cipher = [JSON.parse(message)["value"]].pack('H*')
136
235
  nonce = [JSON.parse(message)["nonce"]].pack('H*')
137
- code, length, digest = decode(private_key).unpack('SCa*')
236
+ code, length, digest = multi_decode(private_key).first.unpack('SCa*')
138
237
  case Multicodecs[code].name
139
238
  when 'ed25519-priv'
140
239
  privKey = RbNaCl::PrivateKey.new(digest)
@@ -151,7 +250,7 @@ class Oydid
151
250
  end
152
251
  end
153
252
 
154
- def self.read_private_key(filename)
253
+ def self.read_private_key(filename, options)
155
254
  begin
156
255
  f = File.open(filename)
157
256
  key_encoded = f.read
@@ -159,12 +258,12 @@ class Oydid
159
258
  rescue
160
259
  return [nil, "cannot read file"]
161
260
  end
162
- decode_private_key(key_encoded)
261
+ decode_private_key(key_encoded, options)
163
262
  end
164
263
 
165
- def self.decode_private_key(key_encoded)
264
+ def self.decode_private_key(key_encoded, options)
166
265
  begin
167
- code, length, digest = decode(key_encoded).unpack('SCa*')
266
+ code, length, digest = multi_decode(key_encoded).first.unpack('SCa*')
168
267
  case Multicodecs[code].name
169
268
  when 'ed25519-priv'
170
269
  private_key = Ed25519::SigningKey.new(digest).to_bytes
@@ -172,12 +271,27 @@ class Oydid
172
271
  return [nil, "unsupported key codec"]
173
272
  end
174
273
  length = private_key.bytesize
175
- return [Oydid.encode([code, length, private_key].pack("SCa#{length}")), ""]
274
+ return multi_encode([code, length, private_key].pack("SCa#{length}"), options)
176
275
  rescue
177
276
  return [nil, "invalid key"]
178
277
  end
179
278
  end
180
279
 
280
+ def self.decode_public_key(key_encoded)
281
+ begin
282
+ code, length, digest = multi_decode(key_encoded).first.unpack('CCa*')
283
+ case Multicodecs[code].name
284
+ when 'ed25519-pub'
285
+ verify_key = Ed25519::VerifyKey.new(digest)
286
+ return [verify_key, ""]
287
+ else
288
+ return [nil, "unsupported key codec"]
289
+ end
290
+ rescue
291
+ return [nil, "unknown key codec"]
292
+ end
293
+ end
294
+
181
295
  # storage functions -----------------------------
182
296
  def self.write_private_storage(payload, filename)
183
297
  File.open(filename, 'w') {|f| f.write(payload)}
@@ -205,7 +319,7 @@ class Oydid
205
319
  end
206
320
  end
207
321
 
208
- def self.retrieve_document(doc_hash, doc_file, doc_location, options)
322
+ def self.retrieve_document(doc_identifier, doc_file, doc_location, options)
209
323
  if doc_location == ""
210
324
  doc_location = DEFAULT_LOCATION
211
325
  end
@@ -214,18 +328,17 @@ class Oydid
214
328
  doc_location = "https://" + doc_location
215
329
  end
216
330
  end
217
-
218
331
  case doc_location
219
332
  when /^http/
220
- doc_location = doc_location.sub("%3A%2F%2F","://")
221
- retVal = HTTParty.get(doc_location + "/doc/" + doc_hash)
333
+ doc_location = doc_location.sub("%3A%2F%2F","://").sub("%3A", ":")
334
+ retVal = HTTParty.get(doc_location + "/doc/" + doc_identifier)
222
335
  if retVal.code != 200
223
- msg = retVal.parsed_response("error").to_s rescue "invalid response from " + doc_location.to_s + "/doc/" + doc_hash.to_s
336
+ msg = retVal.parsed_response("error").to_s rescue "invalid response from " + doc_location.to_s + "/doc/" + doc_identifier.to_s
224
337
  return [nil, msg]
225
338
  end
226
339
  if options.transform_keys(&:to_s)["trace"]
227
340
  if options[:silent].nil? || !options[:silent]
228
- puts "GET " + doc_hash + " from " + doc_location
341
+ puts "GET " + doc_identifier + " from " + doc_location
229
342
  end
230
343
  end
231
344
  return [retVal.parsed_response, ""]
@@ -240,6 +353,9 @@ class Oydid
240
353
  end
241
354
 
242
355
  def self.retrieve_document_raw(doc_hash, doc_file, doc_location, options)
356
+ doc_hash = doc_hash.split(LOCATION_PREFIX).first.split(CGI.escape LOCATION_PREFIX).first rescue doc_hash
357
+ doc_hash = doc_hash.delete_prefix("did:oyd:")
358
+
243
359
  if doc_location == ""
244
360
  doc_location = DEFAULT_LOCATION
245
361
  end
@@ -251,7 +367,7 @@ class Oydid
251
367
 
252
368
  case doc_location
253
369
  when /^http/
254
- doc_location = doc_location.sub("%3A%2F%2F","://")
370
+ doc_location = doc_location.sub("%3A%2F%2F","://").sub("%3A", ":")
255
371
  retVal = HTTParty.get(doc_location + "/doc_raw/" + doc_hash)
256
372
  if retVal.code != 200
257
373
  msg = retVal.parsed_response("error").to_s rescue "invalid response from " + doc_location.to_s + "/doc/" + doc_hash.to_s
data/lib/oydid/didcomm.rb CHANGED
@@ -21,7 +21,7 @@ class Oydid
21
21
  # DIDComm Signed Message --------------------
22
22
  def self.dcsm(payload, private_key_encoded, options)
23
23
  error = ""
24
- code, length, digest = decode(private_key_encoded).unpack('SCa*')
24
+ code, length, digest = multi_decode(private_key_encoded).first.unpack('SCa*')
25
25
  case Multicodecs[code].name
26
26
  when 'ed25519-priv'
27
27
  private_key = RbNaCl::Signatures::Ed25519::SigningKey.new(digest)
@@ -40,7 +40,7 @@ class Oydid
40
40
  result, msg = Oydid.read(pubkey_did, options)
41
41
  public_key_encoded = Oydid.w3c(result, options)["authentication"].first["publicKeyMultibase"]
42
42
  begin
43
- code, length, digest = Oydid.decode(public_key_encoded).unpack('CCa*')
43
+ code, length, digest = multi_decode(public_key_encoded).first.unpack('CCa*')
44
44
  case Multicodecs[code].name
45
45
  when 'ed25519-pub'
46
46
  public_key = RbNaCl::Signatures::Ed25519::VerifyKey.new(digest)
@@ -56,9 +56,9 @@ class Oydid
56
56
  end
57
57
 
58
58
  # encryption -----------------------------------
59
- def self.msg_encrypt(payload, private_key_encoded, did)
59
+ def self.msg_encrypt(payload, private_key_encoded, did, options)
60
60
  error = ""
61
- code, length, digest = decode(private_key_encoded).unpack('SCa*')
61
+ code, length, digest = multi_decode(private_key_encoded).first.unpack('SCa*')
62
62
  case Multicodecs[code].name
63
63
  when 'ed25519-priv'
64
64
  private_key = RbNaCl::Signatures::Ed25519::SigningKey.new(digest)
@@ -70,9 +70,9 @@ class Oydid
70
70
  return [token, error]
71
71
  end
72
72
 
73
- def self.msg_decrypt(token, public_key_encoded)
73
+ def self.msg_decrypt(token, public_key_encoded, options)
74
74
  error = ""
75
- code, length, digest = Oydid.decode(public_key_encoded).unpack('CCa*')
75
+ code, length, digest = Oydid.multi_decode(public_key_encoded).first.unpack('CCa*')
76
76
  case Multicodecs[code].name
77
77
  when 'ed25519-pub'
78
78
  public_key = RbNaCl::Signatures::Ed25519::VerifyKey.new(digest)
@@ -100,14 +100,14 @@ class Oydid
100
100
  end
101
101
 
102
102
  # DID Auth for data container with challenge ---
103
- def self.token_from_challenge(host, pwd)
103
+ def self.token_from_challenge(host, pwd, options = {})
104
104
  sid = SecureRandom.hex(20).to_s
105
105
  retVal = HTTParty.post(host + "/oydid/init",
106
106
  headers: { 'Content-Type' => 'application/json' },
107
107
  body: { "session_id": sid }.to_json )
108
108
  challenge = retVal.parsed_response["challenge"]
109
- signed_challenge = Oydid.sign(challenge, Oydid.generate_private_key(pwd).first).first
110
- public_key = Oydid.public_key(Oydid.generate_private_key(pwd).first).first
109
+ signed_challenge = sign(challenge, Oydid.generate_private_key(pwd, options).first, options).first
110
+ public_key = public_key(generate_private_key(pwd, options).first, options).first
111
111
  retVal = HTTParty.post(host + "/oydid/token",
112
112
  headers: { 'Content-Type' => 'application/json' },
113
113
  body: {
data/lib/oydid/log.rb CHANGED
@@ -7,9 +7,9 @@ class Oydid
7
7
  log.map do |item|
8
8
  i = item.dup
9
9
  i.delete("previous")
10
- item["entry-hash"] = hash(canonical(item))
10
+ item["entry-hash"] = multi_hash(canonical(item), LOG_HASH_OPTIONS).first
11
11
  if item.transform_keys(&:to_s)["op"] == 1
12
- item["sub-entry-hash"] = hash(canonical(i))
12
+ item["sub-entry-hash"] = multi_hash(canonical(i), LOG_HASH_OPTIONS).first
13
13
  end
14
14
  item
15
15
  end
@@ -79,11 +79,14 @@ class Oydid
79
79
  if el["op"].to_i == 0
80
80
  terminate_indices << i
81
81
  end
82
- log_hash << Oydid.hash(Oydid.canonical(el))
82
+ log_options = options.dup
83
+ el_hash = el["doc"].split(LOCATION_PREFIX).first.split(CGI.escape LOCATION_PREFIX).first
84
+ log_options[:digest] = Oydid.get_digest(el_hash).first
85
+ log_options[:encode] = Oydid.get_encoding(el_hash).first
86
+ log_hash << Oydid.multi_hash(Oydid.canonical(el), LOG_HASH_OPTIONS).first
83
87
  dag_log << dag.add_vertex(id: i)
84
88
  i += 1
85
89
  end unless logs.nil?
86
-
87
90
  if create_entries != 1
88
91
  return [nil, nil, nil, "wrong number of CREATE entries (" + create_entries.to_s + ") in log" ]
89
92
  end
@@ -238,7 +241,11 @@ class Oydid
238
241
  log_location = DEFAULT_LOCATION
239
242
  end
240
243
  term = term.split(LOCATION_PREFIX).first
241
- if hash(canonical(el)) != term
244
+ log_options = options.dup
245
+ el_hash = el["doc"].split(LOCATION_PREFIX).first.split(CGI.escape LOCATION_PREFIX).first
246
+ log_options[:digest] = Oydid.get_digest(el_hash).first
247
+ log_options[:encode] = Oydid.get_encoding(el_hash).first
248
+ if multi_hash(canonical(el), log_options).first != term
242
249
  currentDID["error"] = 1
243
250
  currentDID["message"] = "Log reference and record don't match"
244
251
  if verification_output
@@ -267,7 +274,7 @@ class Oydid
267
274
  if log_el["op"].to_i == 1 # TERMINATE
268
275
  log_el_structure.delete("previous")
269
276
  end
270
- if hash(canonical(log_el_structure)) == revoc_term
277
+ if multi_hash(canonical(log_el_structure), log_options).first == revoc_term
271
278
  revoc_term_found = true
272
279
  revocation_record = log_el.dup
273
280
  if verification_output
@@ -307,7 +314,7 @@ class Oydid
307
314
  update_term_found = false
308
315
  log_array.each do |log_el|
309
316
  if log_el["op"].to_i == 3
310
- if log_el["previous"].include?(hash(canonical(revocation_record)))
317
+ if log_el["previous"].include?(multi_hash(canonical(revocation_record), LOG_HASH_OPTIONS).first)
311
318
  update_term_found = true
312
319
  message = log_el["doc"].to_s
313
320