selfsdk 0.0.138 → 0.0.139
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/lib/client.rb +9 -0
- data/lib/crypto.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd7dee3974b09378a7893e93df82bf77a9e082dfcc386b61dc5def8660276233
|
4
|
+
data.tar.gz: b2cc3bec34b678a941cb13ca7f46e82851a7b29ef2f5a4c0a6d5047dfb0aa73d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 603796714f57dae9c509dd5d8bfdae2a9433f41d6bdeb653e55ec8e0aeb6c3b953799fac5651f21e83f3a9526c276e84bd55b655a489074765e13baf21924764
|
7
|
+
data.tar.gz: 3e8b669f3449d9e2335e113fbc638795fc42ac2ef3b5463f14d560460a1bd6ff5d542e453e8b8702ef19454038fcc53f95205e5f21e63965428238b4662bc9d6
|
data/lib/client.rb
CHANGED
@@ -90,6 +90,15 @@ module SelfSDK
|
|
90
90
|
sg.key_by_id(kid)
|
91
91
|
end
|
92
92
|
|
93
|
+
# Get the active public key for a device
|
94
|
+
#
|
95
|
+
# @param id [string] identity id
|
96
|
+
def device_public_key(id, did)
|
97
|
+
i = entity(id)
|
98
|
+
sg = SelfSDK::SignatureGraph.new(i[:history])
|
99
|
+
sg.key_by_device(did)
|
100
|
+
end
|
101
|
+
|
93
102
|
private
|
94
103
|
|
95
104
|
def get_identity(endpoint)
|
data/lib/crypto.rb
CHANGED
@@ -38,7 +38,7 @@ module SelfSDK
|
|
38
38
|
else
|
39
39
|
# 2b-i) if you have not previously sent or recevied a message to/from bob,
|
40
40
|
# you must get his identity key from GET /v1/identities/bob/
|
41
|
-
ed25519_identity_key = @client.
|
41
|
+
ed25519_identity_key = @client.device_public_key(recipient, recipient_device)
|
42
42
|
|
43
43
|
# 2b-ii) get a one time key for bob
|
44
44
|
res = @client.get("/v1/identities/#{recipient}/devices/#{recipient_device}/pre_keys")
|
@@ -51,7 +51,7 @@ module SelfSDK
|
|
51
51
|
one_time_key = JSON.parse(res.body)["key"]
|
52
52
|
|
53
53
|
# 2b-iii) convert bobs ed25519 identity key to a curve25519 key
|
54
|
-
curve25519_identity_key = SelfCrypto::Util.ed25519_pk_to_curve25519(ed25519_identity_key)
|
54
|
+
curve25519_identity_key = SelfCrypto::Util.ed25519_pk_to_curve25519(ed25519_identity_key.raw_public_key)
|
55
55
|
|
56
56
|
# 2b-iv) create the session with bob
|
57
57
|
session_with_bob = @account.outbound_session(curve25519_identity_key, one_time_key)
|