selfsdk 0.0.168 → 0.0.169

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/crypto.rb +21 -0
  3. data/lib/signature_graph.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffcdce1f12b74a382540ad69d30e73e9f4b89316d10831c07917d59646c24764
4
- data.tar.gz: 56c549de3f1cc8574760ded98e5ec1c790293e3555e2b3d0ac69376a124c39e9
3
+ metadata.gz: e525b40ab24f81c5e2ece5c34a8bdb312fae674074981ba8188d168a4c27644d
4
+ data.tar.gz: c97ce7cf0278006e0ef0a3fff16b5ce80f0d5564c84b0419354dc41dab35bd21
5
5
  SHA512:
6
- metadata.gz: 9f9b6c16423ead39824635414bf1de2e5efdf80878b19d234f263663e003c90b8148411fb90498fdfa1525374bfdddf838a97bd28002aa5fcd67224a3b9ab990
7
- data.tar.gz: e3143da9abc1cd2e17c0e1e0ed3253761af044a217246ca27978ed7321e542a5ae1c32499f6cf4e9f4ac380e889a096997774ee2ab95c18fedf78a3e8cc8b24a
6
+ metadata.gz: b069aaabdcc6a10a941c7ecdff18ec69d57d6773275903b9b8f9e1192ec045d1b43d361e57e8203abffd77878b184ac43ae84a2b0cd771112124a58e4860c1d4
7
+ data.tar.gz: 66d71475ac439e52ab6982e676348547a90cfd3455f80a091dbf8fb7af777185fe9aff65c341fda2d0ec406cb217557fdbdaa513a6a666326128d9dfdd370965
data/lib/crypto.rb CHANGED
@@ -90,6 +90,27 @@ module SelfSDK
90
90
 
91
91
  # 7b-ii) use the initial message to create a session for bob or carol
92
92
  session_with_bob = @account.inbound_session(m)
93
+
94
+ # 7b-iii) remove the session's prekey from the account
95
+ @account.remove_one_time_keys(session_with_bob)
96
+
97
+ current_one_time_keys = @account.otk['curve25519']
98
+
99
+ # 7b-iv) if the number of remaining prekeys is below a certain threshold, publish new keys
100
+ if current_one_time_keys.length < 10
101
+ @account.gen_otk(100)
102
+
103
+ keys = Array.new
104
+
105
+ @account.otk['curve25519'].each do |k,v|
106
+ keys.push({id: k, key: v}) if current_one_time_keys[k].nil?
107
+ end
108
+
109
+ res = @client.post("/v1/apps/#{@client.jwt.id}/devices/#{@device}/pre_keys", keys.to_json)
110
+ raise 'unable to push prekeys, please try in a few minutes' if res.code != 200
111
+ end
112
+
113
+ File.write(account_path, @account.to_pickle(@storage_key))
93
114
  end
94
115
 
95
116
  # 8) create a group session and set the identity of the account you're using
@@ -261,7 +261,7 @@ module SelfSDK
261
261
 
262
262
  sk = @keys[operation.signing_key]
263
263
 
264
- raise "operation specifies a signing key that does not exist" if k.nil?
264
+ raise "operation specifies a signing key that does not exist" if sk.nil?
265
265
 
266
266
  # if this is an account recovery, nuke all existing keys
267
267
  if sk.type == KEY_TYPE_RECOVERY
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selfsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.168
4
+ version: 0.0.169
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures