tezos_client 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/tezos_client/crypto.rb +20 -0
- data/lib/tezos_client/exceptions.rb +3 -0
- data/lib/tezos_client/version.rb +1 -1
- 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: 1edfdfe5f7332ebbe4ecafd4baa3f03998e02204e33f854d9f394ba84cbf98c3
|
4
|
+
data.tar.gz: 7544eba6b1a6d602b24025a5c2831c1e803f53f92ae5f0925daa05a0b2ef3167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4e3ddacd06478d21821ce1e38ac5d731f2602d6cbca55e2440828de46c5933aaa8b77df00d3d989295ee325318ff53284725dc91d165ed32918cd2b3de9d8a
|
7
|
+
data.tar.gz: 980264f44b9761e4f7e716675a5775d1b2f3cbfd6de5d09024154c53000a1a95cc3c168efe259c1fd7b78d9a877d23a6c0fa4feea8a8bda942b753122cf73bc7
|
data/Gemfile.lock
CHANGED
data/lib/tezos_client/crypto.rb
CHANGED
@@ -165,6 +165,22 @@ class TezosClient
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
+
# payload must be bytes
|
169
|
+
def check_signature(public_key:, signature:, payload:)
|
170
|
+
verify_key = RbNaCl::VerifyKey.new(decode_tz(public_key).to_bin)
|
171
|
+
|
172
|
+
bin_sig = decode_tz(signature).to_bin
|
173
|
+
payload_hash = RbNaCl::Hash::Blake2b.digest(ignore_0x(payload).to_bin, digest_size: 32)
|
174
|
+
|
175
|
+
verify_key.verify(bin_sig, payload_hash)
|
176
|
+
rescue RbNaCl::BadSignatureError
|
177
|
+
false
|
178
|
+
end
|
179
|
+
|
180
|
+
def check_signature!(public_key:, signature:, payload:)
|
181
|
+
check_signature(public_key: public_key, signature: signature, payload: payload) || raise(BadSignatureError)
|
182
|
+
end
|
183
|
+
|
168
184
|
def operation_id(signed_operation_hex)
|
169
185
|
hash = RbNaCl::Hash::Blake2b.digest(
|
170
186
|
signed_operation_hex.to_bin,
|
@@ -220,5 +236,9 @@ class TezosClient
|
|
220
236
|
RbNaCl::SigningKey.generate
|
221
237
|
end
|
222
238
|
end
|
239
|
+
|
240
|
+
def ignore_0x(payload)
|
241
|
+
payload.starts_with?("0x") ? payload[2..-1] : payload
|
242
|
+
end
|
223
243
|
end
|
224
244
|
end
|
data/lib/tezos_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tezos_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Michard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|