oydid 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/oydid.rb +51 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 302dab4436bd984d28adc707c31528a0de49abc37c20e0b0099e25a74a1b0487
|
4
|
+
data.tar.gz: 847a3c2efde464428f407df125563ddb3132fef1233af76ad5fd205dc51eecf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f61488457caa9c132676802b0d345c1918a74d125a571f02e41120a87b47ee0ce1bbb02540f6fc72b2100e46dafdc6e547b0fd99a3e9616c82dc21a895a9c45f
|
7
|
+
data.tar.gz: a5f9ad43d728560c63bc81cd7daa57702db6ff8162dfbfe7f38864f57d524479a9e5bbea0430cf59addf5ff2838b964778e2f6853b85ed3bb09173e13a7f865f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/oydid.rb
CHANGED
@@ -467,7 +467,7 @@ class Oydid
|
|
467
467
|
end
|
468
468
|
end
|
469
469
|
|
470
|
-
def self.
|
470
|
+
def self.revoke_base(did, options)
|
471
471
|
did_orig = did.dup
|
472
472
|
doc_location = options[:doc_location]
|
473
473
|
if options[:ts].nil?
|
@@ -498,25 +498,40 @@ class Oydid
|
|
498
498
|
did_old = did.dup
|
499
499
|
did10_old = did10.dup
|
500
500
|
log_old = did_info["log"]
|
501
|
-
privateKey_old = read_private_storage(did10_old + "_private_key.b58")
|
502
|
-
revocationKey_old = read_private_storage(did10_old + "_revocation_key.b58")
|
503
501
|
|
504
|
-
if options[:
|
505
|
-
if options[:
|
506
|
-
if options[:
|
507
|
-
|
502
|
+
if options[:old_doc_key].nil?
|
503
|
+
if options[:old_doc_enc].nil?
|
504
|
+
if options[:old_doc_pwd].nil?
|
505
|
+
privateKey_old = read_private_storage(did10_old + "_private_key.b58")
|
508
506
|
else
|
509
|
-
|
507
|
+
privateKey_old, msg = generate_private_key(options[:old_doc_pwd].to_s, 'ed25519-priv')
|
508
|
+
end
|
509
|
+
else
|
510
|
+
privateKey_old, msg = decode_private_key(options[:old_doc_enc].to_s)
|
511
|
+
end
|
512
|
+
else
|
513
|
+
privateKey_old, msg = read_private_key(options[:old_doc_key].to_s)
|
514
|
+
end
|
515
|
+
if privateKey_old.nil?
|
516
|
+
return [nil, "invalid or missing old private document key"]
|
517
|
+
end
|
518
|
+
if options[:old_rev_key].nil?
|
519
|
+
if options[:old_rev_enc].nil?
|
520
|
+
if options[:old_rev_pwd].nil?
|
521
|
+
revocationKey_old = read_private_storage(did10_old + "_revocation_key.b58")
|
522
|
+
else
|
523
|
+
revocationKey_old, msg = generate_private_key(options[:old_rev_pwd].to_s, 'ed25519-priv')
|
510
524
|
end
|
511
525
|
else
|
512
|
-
|
526
|
+
revocationKey_old, msg = decode_private_key(options[:old_rev_enc].to_s)
|
513
527
|
end
|
514
528
|
else
|
515
|
-
|
529
|
+
revocationKey_old, msg = read_private_key(options[:old_rev_key].to_s)
|
516
530
|
end
|
517
|
-
if
|
518
|
-
return [nil, "private key
|
531
|
+
if revocationKey_old.nil?
|
532
|
+
return [nil, "invalid or missing old private revocation key"]
|
519
533
|
end
|
534
|
+
|
520
535
|
if options[:rev_key].nil? && options[:rev_pwd].nil? && options[:rev_enc].nil?
|
521
536
|
revocationKey, msg = read_private_key(did10 + "_revocation_key.b58")
|
522
537
|
revocationLog = read_private_storage(did10 + "_revocation.json")
|
@@ -538,7 +553,7 @@ class Oydid
|
|
538
553
|
did_key_old = publicKey_old + ":" + pubRevoKey_old
|
539
554
|
subDid = {"doc": did_old_doc, "key": did_key_old}.to_json
|
540
555
|
subDidHash = hash(subDid)
|
541
|
-
signedSubDidHash = sign(subDidHash,
|
556
|
+
signedSubDidHash = sign(subDidHash, revocationKey_old).first
|
542
557
|
revocationLog = {
|
543
558
|
"ts": ts_old,
|
544
559
|
"op": 1, # REVOKE
|
@@ -555,7 +570,18 @@ class Oydid
|
|
555
570
|
hash(canonical(log_old[did_info["doc_log_id"].to_i])),
|
556
571
|
hash(canonical(log_old[did_info["termination_log_id"].to_i]))
|
557
572
|
]
|
573
|
+
return [revoc_log, ""]
|
574
|
+
end
|
558
575
|
|
576
|
+
def self.revoke_publish(did, revoc_log, options)
|
577
|
+
did_hash = did.delete_prefix("did:oyd:")
|
578
|
+
did10 = did_hash[0,10]
|
579
|
+
doc_location = options[:doc_location]
|
580
|
+
if did_hash.include?(LOCATION_PREFIX)
|
581
|
+
hash_split = did_hash.split(LOCATION_PREFIX)
|
582
|
+
did_hash = hash_split[0]
|
583
|
+
doc_location = hash_split[1]
|
584
|
+
end
|
559
585
|
if doc_location.to_s == ""
|
560
586
|
doc_location = DEFAULT_LOCATION
|
561
587
|
end
|
@@ -563,22 +589,29 @@ class Oydid
|
|
563
589
|
# publish revocation log based on location
|
564
590
|
case doc_location.to_s
|
565
591
|
when /^http/
|
566
|
-
retVal = HTTParty.post(doc_location.to_s + "/log/" +
|
592
|
+
retVal = HTTParty.post(doc_location.to_s + "/log/" + did_hash.to_s,
|
567
593
|
headers: { 'Content-Type' => 'application/json' },
|
568
594
|
body: {"log": revoc_log}.to_json )
|
569
595
|
if retVal.code != 200
|
570
|
-
msg = retVal.parsed_response("error").to_s rescue "invalid response from " + doc_location.to_s + "/log/" +
|
596
|
+
msg = retVal.parsed_response("error").to_s rescue "invalid response from " + doc_location.to_s + "/log/" + did_hash.to_s
|
571
597
|
return [nil, msg]
|
572
598
|
end
|
573
599
|
else
|
574
|
-
File.write(did10 + ".log",
|
600
|
+
File.write(did10 + ".log", revoc_log.to_json)
|
575
601
|
if !did_old.nil?
|
576
|
-
File.write(did10_old + ".log",
|
602
|
+
File.write(did10_old + ".log", revoc_log.to_json)
|
577
603
|
end
|
578
604
|
end
|
579
605
|
|
580
|
-
return [
|
606
|
+
return [did, ""]
|
607
|
+
end
|
581
608
|
|
609
|
+
def self.revoke(did, options)
|
610
|
+
revoc_log, msg = revoke_base(did, options)
|
611
|
+
if revoc_log.nil?
|
612
|
+
return [nil, msg]
|
613
|
+
end
|
614
|
+
success, msg = revoke_publish(did, revoc_log, options)
|
582
615
|
end
|
583
616
|
|
584
617
|
def self.clone(did, options)
|
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.
|
4
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2022-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dag
|