ppldid 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/{oydid → ppldid}/basic.rb +2 -2
- data/lib/{oydid → ppldid}/didcomm.rb +7 -7
- data/lib/{oydid → ppldid}/log.rb +2 -2
- data/lib/{oydid.rb → ppldid.rb} +5 -5
- data/spec/{oydid_spec.rb → ppldid_spec.rb} +25 -25
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a77befbb337135d0b5f3610a04e69eefc58740d407d7d78dac02a751012b400e
|
4
|
+
data.tar.gz: dae893a695580c421e22b7e5c481edb81f8ba33a7f55f199fb9ae0e1f987844d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 646df544824fb68424c1a72df4d2c5589622e3e1ff65c93a397056d114965d838f41b9f588a9aa1b26d5d69f51d93eb3deaaccb3f6de2e016bd858c39fc4fb79
|
7
|
+
data.tar.gz: 387398f7e68ab20111ea8b0530842e55efdb93137df80aea9816e7bdb5c93dc159db2ac5b2f086b72c54b0a1177c5a8ca8d08d0313dcd54066adc1695d1bdbf4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.1
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
class
|
4
|
+
class ppldid
|
5
5
|
|
6
6
|
# basic functions ---------------------------
|
7
7
|
def self.encode(message, method = "base58btc")
|
@@ -172,7 +172,7 @@ class Oydid
|
|
172
172
|
return [nil, "unsupported key codec"]
|
173
173
|
end
|
174
174
|
length = private_key.bytesize
|
175
|
-
return [
|
175
|
+
return [ppldid.encode([code, length, private_key].pack("SCa#{length}")), ""]
|
176
176
|
rescue
|
177
177
|
return [nil, "invalid key"]
|
178
178
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
class
|
4
|
+
class ppldid
|
5
5
|
|
6
6
|
# DIDComm Plain Message ---------------------
|
7
7
|
def self.dcpm(payload, options)
|
@@ -37,10 +37,10 @@ class Oydid
|
|
37
37
|
error = ""
|
38
38
|
decoded_payload = JWT.decode token, nil, false
|
39
39
|
pubkey_did = decoded_payload.last["kid"]
|
40
|
-
result, msg =
|
41
|
-
public_key_encoded =
|
40
|
+
result, msg = ppldid.read(pubkey_did, options)
|
41
|
+
public_key_encoded = ppldid.w3c(result, options)["authentication"].first["publicKeyMultibase"]
|
42
42
|
begin
|
43
|
-
code, length, digest =
|
43
|
+
code, length, digest = ppldid.decode(public_key_encoded).unpack('CCa*')
|
44
44
|
case Multicodecs[code].name
|
45
45
|
when 'ed25519-pub'
|
46
46
|
public_key = RbNaCl::Signatures::Ed25519::VerifyKey.new(digest)
|
@@ -72,7 +72,7 @@ class Oydid
|
|
72
72
|
|
73
73
|
def self.msg_decrypt(token, public_key_encoded)
|
74
74
|
error = ""
|
75
|
-
code, length, digest =
|
75
|
+
code, length, digest = ppldid.decode(public_key_encoded).unpack('CCa*')
|
76
76
|
case Multicodecs[code].name
|
77
77
|
when 'ed25519-pub'
|
78
78
|
public_key = RbNaCl::Signatures::Ed25519::VerifyKey.new(digest)
|
@@ -106,8 +106,8 @@ class Oydid
|
|
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 =
|
110
|
-
public_key =
|
109
|
+
signed_challenge = ppldid.sign(challenge, ppldid.generate_private_key(pwd).first).first
|
110
|
+
public_key = ppldid.public_key(ppldid.generate_private_key(pwd).first).first
|
111
111
|
retVal = HTTParty.post(host + "/ppldid/token",
|
112
112
|
headers: { 'Content-Type' => 'application/json' },
|
113
113
|
body: {
|
data/lib/{oydid → ppldid}/log.rb
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
class
|
4
|
+
class ppldid
|
5
5
|
# log functions -----------------------------
|
6
6
|
def self.add_hash(log)
|
7
7
|
log.map do |item|
|
@@ -79,7 +79,7 @@ class Oydid
|
|
79
79
|
if el["op"].to_i == 0
|
80
80
|
terminate_indices << i
|
81
81
|
end
|
82
|
-
log_hash <<
|
82
|
+
log_hash << ppldid.hash(ppldid.canonical(el))
|
83
83
|
dag_log << dag.add_vertex(id: i)
|
84
84
|
i += 1
|
85
85
|
end unless logs.nil?
|
data/lib/{oydid.rb → ppldid.rb}
RENAMED
@@ -14,10 +14,10 @@ require 'ppldid/basic'
|
|
14
14
|
require 'ppldid/log'
|
15
15
|
require 'ppldid/didcomm'
|
16
16
|
|
17
|
-
class
|
17
|
+
class ppldid
|
18
18
|
|
19
19
|
LOCATION_PREFIX = "@"
|
20
|
-
DEFAULT_LOCATION = "https://ppldid.
|
20
|
+
DEFAULT_LOCATION = "https://ppldid.peopledata.org.cn"
|
21
21
|
|
22
22
|
|
23
23
|
# expected DID format: did:ppld:123
|
@@ -140,7 +140,7 @@ class Oydid
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def self.simulate_did(content, did, mode, options)
|
143
|
-
user_did, didDocument, revoc_log, l1, l2, r1, privateKey, revocationKey, did_old, log_old, msg =
|
143
|
+
user_did, didDocument, revoc_log, l1, l2, r1, privateKey, revocationKey, did_old, log_old, msg = ppldid.generate_base(content, did, mode, options)
|
144
144
|
return [user_did, msg]
|
145
145
|
end
|
146
146
|
|
@@ -396,8 +396,8 @@ class Oydid
|
|
396
396
|
"did-document": didDocument,
|
397
397
|
"logs": logs
|
398
398
|
}
|
399
|
-
|
400
|
-
retVal = HTTParty.post(
|
399
|
+
ppldid_url = doc_location.to_s + "/doc"
|
400
|
+
retVal = HTTParty.post(ppldid_url,
|
401
401
|
headers: { 'Content-Type' => 'application/json' },
|
402
402
|
body: did_data.to_json )
|
403
403
|
if retVal.code != 200
|
@@ -6,34 +6,34 @@ describe "PPLDID handling" do
|
|
6
6
|
it "encodes #{input.split('/').last}" do
|
7
7
|
expected = File.read(input.sub('input', 'output'))
|
8
8
|
data = File.read(input)
|
9
|
-
expect(
|
9
|
+
expect(ppldid.encode(data)).to eq expected
|
10
10
|
end
|
11
11
|
end
|
12
12
|
Dir.glob(File.expand_path("../input/basic/*_dec.doc", __FILE__)).each do |input|
|
13
13
|
it "decodes #{input.split('/').last}" do
|
14
14
|
expected = File.read(input.sub('input', 'output'))
|
15
15
|
data = File.read(input)
|
16
|
-
expect(
|
16
|
+
expect(ppldid.decode(data)).to eq expected
|
17
17
|
end
|
18
18
|
end
|
19
19
|
Dir.glob(File.expand_path("../input/basic/*_hash.doc", __FILE__)).each do |input|
|
20
20
|
it "hashes #{input.split('/').last}" do
|
21
21
|
expected = File.read(input.sub('input', 'output'))
|
22
22
|
data = File.read(input)
|
23
|
-
expect(
|
23
|
+
expect(ppldid.hash(data)).to eq expected
|
24
24
|
end
|
25
25
|
end
|
26
26
|
Dir.glob(File.expand_path("../input/basic/*.json", __FILE__)).each do |input|
|
27
27
|
it "converts #{input.split('/').last}" do
|
28
28
|
expected = File.read(input.sub('input', 'output'))
|
29
29
|
data = JSON.parse(File.read(input))
|
30
|
-
expect(
|
30
|
+
expect(ppldid.canonical(data)).to eq expected
|
31
31
|
end
|
32
32
|
end
|
33
33
|
it "converts strings" do
|
34
34
|
expected = "\"asdf\""
|
35
35
|
data = "asdf"
|
36
|
-
expect(
|
36
|
+
expect(ppldid.canonical(data)).to eq expected
|
37
37
|
end
|
38
38
|
|
39
39
|
# key management
|
@@ -41,47 +41,47 @@ describe "PPLDID handling" do
|
|
41
41
|
it "generates #{input.split('/').last}" do
|
42
42
|
expected = File.read(input.sub('input', 'output'))
|
43
43
|
data = File.read(input)
|
44
|
-
expect(
|
44
|
+
expect(ppldid.generate_private_key(data).first).to eq expected
|
45
45
|
end
|
46
46
|
end
|
47
47
|
it "handles unknown key codec" do
|
48
48
|
expected = "unknown key codec"
|
49
|
-
expect(
|
49
|
+
expect(ppldid.generate_private_key("", "asdf").last).to eq expected
|
50
50
|
end
|
51
51
|
it "handles unsupported key codec" do
|
52
52
|
expected = "unsupported key codec"
|
53
|
-
expect(
|
53
|
+
expect(ppldid.generate_private_key("", "p256-pub").last).to eq expected
|
54
54
|
end
|
55
55
|
it "handles random key generation" do
|
56
56
|
expected_length = 48
|
57
|
-
expect(
|
57
|
+
expect(ppldid.generate_private_key("").first.length).to eq expected_length
|
58
58
|
end
|
59
59
|
Dir.glob(File.expand_path("../input/basic/*_privkey.doc", __FILE__)).each do |input|
|
60
60
|
it "public key from private key #{input.split('/').last}" do
|
61
61
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
62
62
|
data = File.read(input)
|
63
|
-
expect(
|
63
|
+
expect(ppldid.public_key(data)).to eq expected
|
64
64
|
end
|
65
65
|
end
|
66
66
|
Dir.glob(File.expand_path("../input/basic/*_sign.doc", __FILE__)).each do |input|
|
67
67
|
it "signing #{input.split('/').last}" do
|
68
68
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
69
69
|
data = JSON.parse(File.read(input))
|
70
|
-
expect(
|
70
|
+
expect(ppldid.sign(data["message"], data["key"])).to eq expected
|
71
71
|
end
|
72
72
|
end
|
73
73
|
Dir.glob(File.expand_path("../input/basic/*_verify.doc", __FILE__)).each do |input|
|
74
74
|
it "verifying #{input.split('/').last}" do
|
75
75
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
76
76
|
data = JSON.parse(File.read(input))
|
77
|
-
expect(
|
77
|
+
expect(ppldid.verify(data["message"], data["signature"], data["public_key"])).to eq expected
|
78
78
|
end
|
79
79
|
end
|
80
80
|
Dir.glob(File.expand_path("../input/basic/*_readkey.doc", __FILE__)).each do |input|
|
81
81
|
it "reading private key from file #{input.split('/').last}" do
|
82
82
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
83
83
|
data = File.read(input)
|
84
|
-
expect(
|
84
|
+
expect(ppldid.read_private_key(data)).to eq expected
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -91,10 +91,10 @@ describe "PPLDID handling" do
|
|
91
91
|
@filename = "filename"
|
92
92
|
@content = "text"
|
93
93
|
allow(File).to receive(:open).with(@filename,'w').and_yield( @buffer )
|
94
|
-
|
94
|
+
ppldid.write_private_storage(@content, @filename)
|
95
95
|
expect(@buffer.string).to eq(@content)
|
96
96
|
allow(File).to receive(:open).with(@filename, 'r').and_yield( StringIO.new(@content) )
|
97
|
-
expect(
|
97
|
+
expect(ppldid.read_private_storage(@filename)).to eq(@content)
|
98
98
|
end
|
99
99
|
|
100
100
|
# document functions
|
@@ -102,14 +102,14 @@ describe "PPLDID handling" do
|
|
102
102
|
it "get location from #{input.split('/').last}" do
|
103
103
|
expected = File.read(input.sub('input', 'output'))
|
104
104
|
data = File.read(input)
|
105
|
-
expect(
|
105
|
+
expect(ppldid.get_location(data)).to eq expected
|
106
106
|
end
|
107
107
|
end
|
108
108
|
Dir.glob(File.expand_path("../input/basic/*_retrieve_document.doc", __FILE__)).each do |input|
|
109
109
|
it "get location from #{input.split('/').last}" do
|
110
110
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
111
111
|
data = JSON.parse(File.read(input))
|
112
|
-
expect(
|
112
|
+
expect(ppldid.retrieve_document(data["doc_hash"], data["doc_file"], data["doc_location"], data["options"])).to eq expected
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -118,43 +118,43 @@ describe "PPLDID handling" do
|
|
118
118
|
it "adding hash value to log entry #{input.split('/').last}" do
|
119
119
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
120
120
|
data = JSON.parse(File.read(input))
|
121
|
-
expect(
|
121
|
+
expect(ppldid.add_hash(data)).to eq expected
|
122
122
|
end
|
123
123
|
end
|
124
124
|
Dir.glob(File.expand_path("../input/log/*_match_log.doc", __FILE__)).each do |input|
|
125
125
|
it "check log entry match #{input.split('/').last}" do
|
126
126
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
127
127
|
data = JSON.parse(File.read(input))
|
128
|
-
expect(
|
128
|
+
expect(ppldid.match_log_did?(data, data["didoc"])).to eq expected
|
129
129
|
end
|
130
130
|
end
|
131
131
|
Dir.glob(File.expand_path("../input/log/*_retrieve_log.doc", __FILE__)).each do |input|
|
132
132
|
it "retrieve log #{input.split('/').last}" do
|
133
133
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
134
134
|
data = JSON.parse(File.read(input))
|
135
|
-
expect(
|
135
|
+
expect(ppldid.retrieve_log(data["did_hash"], data["log_file"], data["log_location"], data["options"])).to eq expected
|
136
136
|
end
|
137
137
|
end
|
138
138
|
Dir.glob(File.expand_path("../input/log/*_dag_did.doc", __FILE__)).each do |input|
|
139
139
|
it "creates DAG from log #{input.split('/').last}" do
|
140
140
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
141
141
|
data = JSON.parse(File.read(input))
|
142
|
-
expect(
|
142
|
+
expect(ppldid.dag_did(data["log"], data["options"]).last(3)).to eq expected
|
143
143
|
end
|
144
144
|
end
|
145
145
|
Dir.glob(File.expand_path("../input/log/*_dag2array.doc", __FILE__)).each do |input|
|
146
146
|
it "process dag2array for #{input.split('/').last}" do
|
147
147
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
148
148
|
data = JSON.parse(File.read(input))
|
149
|
-
dag, create_index, terminate_index, msg =
|
150
|
-
expect(
|
149
|
+
dag, create_index, terminate_index, msg = ppldid.dag_did(data["log"], data["options"])
|
150
|
+
expect(ppldid.dag2array(dag, data["log"], create_index, [], data["options"])).to eq expected
|
151
151
|
end
|
152
152
|
end
|
153
153
|
# Dir.glob(File.expand_path("../input/log/*_dag_update.doc", __FILE__)).each do |input|
|
154
154
|
# it "process DAG for #{input.split('/').last}" do
|
155
155
|
# expected = JSON.parse(File.read(input.sub('input', 'output')))
|
156
156
|
# data = JSON.parse(File.read(input))
|
157
|
-
# expect(
|
157
|
+
# expect(ppldid.dag_update(data["currentDID"], data["options"])).to eq expected
|
158
158
|
# end
|
159
159
|
# end
|
160
160
|
|
@@ -163,7 +163,7 @@ describe "PPLDID handling" do
|
|
163
163
|
it "execute read for #{input.split('/').last}" do
|
164
164
|
expected = JSON.parse(File.read(input.sub('input', 'output')))
|
165
165
|
data = JSON.parse(File.read(input))
|
166
|
-
expect(
|
166
|
+
expect(ppldid.read(data["did"], data["options"])).to eq expected
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppldid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerry Zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dag
|
@@ -160,10 +160,10 @@ files:
|
|
160
160
|
- LICENSE
|
161
161
|
- README.md
|
162
162
|
- VERSION
|
163
|
-
- lib/
|
164
|
-
- lib/
|
165
|
-
- lib/
|
166
|
-
- lib/
|
163
|
+
- lib/ppldid.rb
|
164
|
+
- lib/ppldid/basic.rb
|
165
|
+
- lib/ppldid/didcomm.rb
|
166
|
+
- lib/ppldid/log.rb
|
167
167
|
- spec/input/basic/arrays.json
|
168
168
|
- spec/input/basic/french.json
|
169
169
|
- spec/input/basic/sample2_get_location.doc
|
@@ -275,7 +275,7 @@ files:
|
|
275
275
|
- spec/output/log/sample_op1_addhash.doc
|
276
276
|
- spec/output/log/sample_retrieve_log.doc
|
277
277
|
- spec/output/main/sample0_read.doc
|
278
|
-
- spec/
|
278
|
+
- spec/ppldid_spec.rb
|
279
279
|
- spec/spec_helper.rb
|
280
280
|
homepage: http://github.com/peopledata/ppldid
|
281
281
|
licenses:
|
@@ -300,13 +300,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
300
|
- !ruby/object:Gem::Version
|
301
301
|
version: '0'
|
302
302
|
requirements: []
|
303
|
-
|
303
|
+
rubyforge_project:
|
304
|
+
rubygems_version: 2.7.11
|
304
305
|
signing_key:
|
305
306
|
specification_version: 4
|
306
307
|
summary: Decentralized IDentifier for People.
|
307
308
|
test_files:
|
308
309
|
- spec/spec_helper.rb
|
309
|
-
- spec/
|
310
|
+
- spec/ppldid_spec.rb
|
310
311
|
- spec/input/basic/unicode.json
|
311
312
|
- spec/input/basic/wierd.json
|
312
313
|
- spec/input/basic/values.json
|