oydid 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/oydid/basic.rb +5 -1
  4. data/lib/oydid.rb +44 -8
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84460bc149df8e10a4f5094879894399bd3d6670ff5ef1fc8c500811af5fb5e2
4
- data.tar.gz: 3515b7f22cf286b3abda13299fd15a6a713f39a2048c8f1d3553f36832577e24
3
+ metadata.gz: fd217dec02b21cc0f67b4468ca7512cdc407042f5800ba9321453a40578b0fca
4
+ data.tar.gz: dc2456c039c57454dda2586e0791fe5c21ed854973a9223e6900e5414298f0cd
5
5
  SHA512:
6
- metadata.gz: 1eadd2c6dfba9ef8788e72514b3c12561e8628a20c6fc14bb21172d3777227bde42accb6dfe5cda14ccdeb027cb53415c179193cbd70bf1fa637b1bfe1208078
7
- data.tar.gz: 9e0f47ca1316e508faf65af727afb8a61de3a89e023d789d21ce69ca9328da46f4d1c9a197ee7486aba3c460476112bebf919803c26b7f0c06896f911b1ecfa6
6
+ metadata.gz: 960ff5f588095f07401e4eb2c70b29a1e3393fb335f757188cf91ac026c9f066a22f5e660a927cbe6bbc70d9b3524f423dacf1b4fb417945d3bbe2c750cb29d2
7
+ data.tar.gz: bae80cb73bb3029a1b157fb85c579ac0d394f713b50b2f3eff6968b0a672528d45ae06969a52b3f13c077b55ab9792fe75630417bf19952f18ce7847b834c66a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/lib/oydid/basic.rb CHANGED
@@ -124,7 +124,11 @@ class Oydid
124
124
  end
125
125
 
126
126
  def self.read_private_storage(filename)
127
- File.open(filename, 'r') { |f| f.read }
127
+ begin
128
+ File.open(filename, 'r') { |f| f.read }
129
+ rescue
130
+ nil
131
+ end
128
132
  end
129
133
 
130
134
  def self.get_location(id)
data/lib/oydid.rb CHANGED
@@ -205,8 +205,38 @@ class Oydid
205
205
  did_old = did.dup
206
206
  did10_old = did10.dup
207
207
  log_old = did_info["log"]
208
- privateKey_old = read_private_storage(did10_old + "_private_key.b58")
209
- revocationKey_old = read_private_storage(did10_old + "_revocation_key.b58")
208
+ if options[:old_doc_key].nil?
209
+ if options[:old_doc_enc].nil?
210
+ if options[:old_doc_pwd].nil?
211
+ privateKey_old = read_private_storage(did10_old + "_private_key.b58")
212
+ else
213
+ privateKey_old, msg = generate_private_key(options[:old_doc_pwd].to_s, 'ed25519-priv')
214
+ end
215
+ else
216
+ privateKey_old, msg = decode_private_key(options[:old_doc_enc].to_s)
217
+ end
218
+ else
219
+ privateKey_old, msg = read_private_key(options[:old_doc_key].to_s)
220
+ end
221
+ if privateKey_old.nil?
222
+ return [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "invalid or missing old private document key"]
223
+ end
224
+ if options[:old_rev_key].nil?
225
+ if options[:old_rev_enc].nil?
226
+ if options[:old_rev_pwd].nil?
227
+ revocationKey_old = read_private_storage(did10_old + "_revocation_key.b58")
228
+ else
229
+ revocationKey_old, msg = generate_private_key(options[:old_rev_pwd].to_s, 'ed25519-priv')
230
+ end
231
+ else
232
+ revocationKey_old, msg = decode_private_key(options[:old_rev_enc].to_s)
233
+ end
234
+ else
235
+ revocationKey_old, msg = read_private_key(options[:old_rev_key].to_s)
236
+ end
237
+ if revocationKey_old.nil?
238
+ return [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "invalid or missing old private revocation key"]
239
+ end
210
240
 
211
241
  # key management
212
242
  if options[:doc_key].nil?
@@ -218,13 +248,19 @@ class Oydid
218
248
  else
219
249
  privateKey, msg = read_private_key(options[:doc_key].to_s)
220
250
  end
221
- if options[:rev_key].nil? && options[:rev_pwd].nil?
222
- revocationKey, msg = generate_private_key("", 'ed25519-priv')
223
- revocationLog = read_private_storage(did10 + "_revocation.json")
224
- else
251
+ # if options[:rev_key].nil? && options[:rev_pwd].nil? && options[:rev_enc].nil?
252
+ # revocationLog = read_private_storage(did10 + "_revocation.json")
253
+ # if revocationLog.nil?
254
+ # return [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "invalid or missing old revocation log"]
255
+ # end
256
+ # else
225
257
  if options[:rev_key].nil?
226
258
  if options[:rev_enc].nil?
227
- revocationKey, msg = generate_private_key(options[:rev_pwd].to_s, 'ed25519-priv')
259
+ if options[:rev_pwd].nil?
260
+ revocationKey, msg = generate_private_key("", 'ed25519-priv')
261
+ else
262
+ revocationKey, msg = generate_private_key(options[:rev_pwd].to_s, 'ed25519-priv')
263
+ end
228
264
  else
229
265
  revocationKey, msg = decode_private_key(options[:rev_enc].to_s)
230
266
  end
@@ -246,7 +282,7 @@ class Oydid
246
282
  "op": 1, # REVOKE
247
283
  "doc": subDidHash,
248
284
  "sig": signedSubDidHash }.transform_keys(&:to_s).to_json
249
- end
285
+ # end
250
286
  revoc_log = JSON.parse(revocationLog)
251
287
  revoc_log["previous"] = [
252
288
  hash(canonical(log_old[did_info["doc_log_id"].to_i])),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oydid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Fabianek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-14 00:00:00.000000000 Z
11
+ date: 2022-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dag