oydid 0.3.5 → 0.4.1
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/didcomm.rb +50 -0
- data/lib/oydid.rb +7 -3
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '080c68f559573f4402ed202c539848c9bdc72e173697061b8e8005c06b64d06b'
|
4
|
+
data.tar.gz: 5614b9dc152ff70f3f1e951f0db39a41a46dddaa17aa4088652e1d3c17cd8115
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d594168b9e609882afff27e8b92e9740acb5500a328ecf9599a3c8ee848a4917921744117810263957585f6f3b8d742c5a00362d516b871ffe3f2dd73d4f494
|
7
|
+
data.tar.gz: '0571905fda5580900ecaea886909e951da2fe1636cb001e8984f95837733a4ce453aaae928525cf6521e8c50b9428afc7941aed1bd02855fd20e3a61e16d10d8'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.1
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
class Oydid
|
5
|
+
|
6
|
+
# DIDComm Plain Message ---------------------
|
7
|
+
def self.dcpm(payload, options)
|
8
|
+
dcDoc = {}
|
9
|
+
dcDoc["id"] = SecureRandom.random_number(10e14).to_i
|
10
|
+
dcDoc["type"] = options[:didcomm_type]
|
11
|
+
if !options[:didcomm_from_did].nil?
|
12
|
+
dcDoc["from"] = options[:didcomm_from_did]
|
13
|
+
end
|
14
|
+
dcDoc["to"] = [options[:didcomm_to_did]]
|
15
|
+
dcDoc["created_time"] = Time.now.utc.to_i
|
16
|
+
dcDoc["body"] = payload
|
17
|
+
return [dcDoc, ""]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
# signing -----------------------------------
|
22
|
+
def self.msg_encrypt(payload, private_key_encoded)
|
23
|
+
error = ""
|
24
|
+
code, length, digest = decode(private_key_encoded).unpack('SCa*')
|
25
|
+
case Multicodecs[code].name
|
26
|
+
when 'ed25519-priv'
|
27
|
+
private_key = RbNaCl::Signatures::Ed25519::SigningKey.new(digest)
|
28
|
+
token = JWT.encode payload, private_key, 'ED25519'
|
29
|
+
else
|
30
|
+
token = nil
|
31
|
+
error = "unsupported key codec"
|
32
|
+
end
|
33
|
+
return [token, error]
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.msg_decrypt(token, public_key_encoded)
|
37
|
+
error = ""
|
38
|
+
code, length, digest = Oydid.decode(public_key_encoded).unpack('CCa*')
|
39
|
+
case Multicodecs[code].name
|
40
|
+
when 'ed25519-pub'
|
41
|
+
public_key = RbNaCl::Signatures::Ed25519::VerifyKey.new(digest)
|
42
|
+
payload = JWT.decode token.to_s, public_key, true, { algorithm: 'ED25519' }
|
43
|
+
else
|
44
|
+
payload = nil
|
45
|
+
error = "unsupported key codec"
|
46
|
+
end
|
47
|
+
return [payload, error]
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/lib/oydid.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'dag'
|
5
|
+
require 'jwt'
|
5
6
|
require 'rbnacl'
|
6
7
|
require 'ed25519'
|
7
8
|
require 'httparty'
|
@@ -11,6 +12,7 @@ require 'multicodecs'
|
|
11
12
|
require 'json/canonicalization'
|
12
13
|
require 'oydid/basic'
|
13
14
|
require 'oydid/log'
|
15
|
+
require 'oydid/didcomm'
|
14
16
|
|
15
17
|
class Oydid
|
16
18
|
|
@@ -670,17 +672,17 @@ class Oydid
|
|
670
672
|
wd = {}
|
671
673
|
wd["@context"] = "https://www.w3.org/ns/did/v1"
|
672
674
|
wd["id"] = did
|
673
|
-
wd["
|
675
|
+
wd["assertionMethod"] = [{
|
674
676
|
"id": did,
|
675
677
|
"type": "Ed25519VerificationKey2020",
|
676
678
|
"controller": did,
|
677
|
-
"
|
679
|
+
"publicKeyMultibase": pubDocKey
|
678
680
|
}]
|
679
681
|
wd["keyAgreement"] = [{
|
680
682
|
"id": did,
|
681
683
|
"type": "Ed25519VerificationKey2020",
|
682
684
|
"controller": did,
|
683
|
-
"
|
685
|
+
"publicKeyMultibase": pubRevKey
|
684
686
|
}]
|
685
687
|
|
686
688
|
if didDoc["@context"].to_s == "https://www.w3.org/ns/did/v1"
|
@@ -711,6 +713,8 @@ class Oydid
|
|
711
713
|
else
|
712
714
|
newDidDoc = didDoc["service"]
|
713
715
|
end
|
716
|
+
else
|
717
|
+
newDidDoc = didDoc
|
714
718
|
end
|
715
719
|
else
|
716
720
|
newDidDoc = didDoc
|
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.4.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-
|
11
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dag
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.9
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jwt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.4.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.4.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rbnacl
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,6 +162,7 @@ files:
|
|
148
162
|
- VERSION
|
149
163
|
- lib/oydid.rb
|
150
164
|
- lib/oydid/basic.rb
|
165
|
+
- lib/oydid/didcomm.rb
|
151
166
|
- lib/oydid/log.rb
|
152
167
|
- spec/input/basic/arrays.json
|
153
168
|
- spec/input/basic/french.json
|