virgil-sdk 4.2.3

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.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +15 -0
  4. data/Gemfile +4 -0
  5. data/README.md +134 -0
  6. data/Rakefile +9 -0
  7. data/bin/console +16 -0
  8. data/bin/setup +8 -0
  9. data/dockefiles/Dockerfile-200 +25 -0
  10. data/dockefiles/Dockerfile-2110 +36 -0
  11. data/dockefiles/Dockerfile-220 +26 -0
  12. data/dockefiles/Dockerfile-226 +25 -0
  13. data/dockefiles/Dockerfile-233 +25 -0
  14. data/dockefiles/Dockerfile-240 +26 -0
  15. data/docker-compose.yml +107 -0
  16. data/lib/virgil/sdk.rb +10 -0
  17. data/lib/virgil/sdk/client.rb +47 -0
  18. data/lib/virgil/sdk/client/card.rb +142 -0
  19. data/lib/virgil/sdk/client/card_validator.rb +104 -0
  20. data/lib/virgil/sdk/client/http.rb +45 -0
  21. data/lib/virgil/sdk/client/http/base_connection.rb +112 -0
  22. data/lib/virgil/sdk/client/http/cards_service_connection.rb +113 -0
  23. data/lib/virgil/sdk/client/http/request.rb +63 -0
  24. data/lib/virgil/sdk/client/request_signer.rb +90 -0
  25. data/lib/virgil/sdk/client/requests.rb +50 -0
  26. data/lib/virgil/sdk/client/requests/confirm_identity_request.rb +67 -0
  27. data/lib/virgil/sdk/client/requests/create_card_request.rb +105 -0
  28. data/lib/virgil/sdk/client/requests/revoke_card_request.rb +85 -0
  29. data/lib/virgil/sdk/client/requests/signable_request.rb +142 -0
  30. data/lib/virgil/sdk/client/requests/verify_identity_request.rb +60 -0
  31. data/lib/virgil/sdk/client/search_criteria.rb +79 -0
  32. data/lib/virgil/sdk/client/signatures_base64.rb +25 -0
  33. data/lib/virgil/sdk/client/virgil_client.rb +425 -0
  34. data/lib/virgil/sdk/cryptography.rb +42 -0
  35. data/lib/virgil/sdk/cryptography/hashes.rb +44 -0
  36. data/lib/virgil/sdk/cryptography/hashes/fingerprint.rb +79 -0
  37. data/lib/virgil/sdk/cryptography/hashes/hash_algorithm.rb +91 -0
  38. data/lib/virgil/sdk/cryptography/keys.rb +48 -0
  39. data/lib/virgil/sdk/cryptography/keys/key_pair.rb +46 -0
  40. data/lib/virgil/sdk/cryptography/keys/key_pair_type.rb +108 -0
  41. data/lib/virgil/sdk/cryptography/keys/key_storage.rb +177 -0
  42. data/lib/virgil/sdk/cryptography/keys/private_key.rb +44 -0
  43. data/lib/virgil/sdk/cryptography/keys/public_key.rb +44 -0
  44. data/lib/virgil/sdk/cryptography/keys/storage_item.rb +63 -0
  45. data/lib/virgil/sdk/cryptography/virgil_crypto.rb +411 -0
  46. data/lib/virgil/sdk/high_level.rb +21 -0
  47. data/lib/virgil/sdk/high_level/virgil_api.rb +71 -0
  48. data/lib/virgil/sdk/high_level/virgil_app_credentials.rb +54 -0
  49. data/lib/virgil/sdk/high_level/virgil_buffer.rb +161 -0
  50. data/lib/virgil/sdk/high_level/virgil_card.rb +204 -0
  51. data/lib/virgil/sdk/high_level/virgil_card_manager.rb +294 -0
  52. data/lib/virgil/sdk/high_level/virgil_card_verifier_info.rb +49 -0
  53. data/lib/virgil/sdk/high_level/virgil_context.rb +69 -0
  54. data/lib/virgil/sdk/high_level/virgil_identity.rb +17 -0
  55. data/lib/virgil/sdk/high_level/virgil_identity/email_confirmation.rb +60 -0
  56. data/lib/virgil/sdk/high_level/virgil_identity/validation_token.rb +49 -0
  57. data/lib/virgil/sdk/high_level/virgil_identity/verification_attempt.rb +69 -0
  58. data/lib/virgil/sdk/high_level/virgil_identity/verification_options.rb +56 -0
  59. data/lib/virgil/sdk/high_level/virgil_key.rb +168 -0
  60. data/lib/virgil/sdk/high_level/virgil_key_manager.rb +97 -0
  61. data/lib/virgil/sdk/version.rb +5 -0
  62. data/virgil-sdk.gemspec +31 -0
  63. metadata +203 -0
@@ -0,0 +1,21 @@
1
+ module Virgil
2
+ module SDK
3
+ module HighLevel
4
+ autoload :VirgilApi, 'virgil/sdk/high_level/virgil_api'
5
+ autoload :VirgilIdentity, 'virgil/sdk/high_level/virgil_identity'
6
+ autoload :Card, 'virgil/sdk/client/card'
7
+ autoload :VirgilCard, 'virgil/sdk/high_level/virgil_card'
8
+ autoload :VirgilKey, 'virgil/sdk/high_level/virgil_key'
9
+ autoload :VirgilContext, 'virgil/sdk/high_level/virgil_context'
10
+ autoload :VirgilKeyManager, 'virgil/sdk/high_level/virgil_key_manager'
11
+ autoload :VirgilCardManager, 'virgil/sdk/high_level/virgil_card_manager'
12
+ autoload :VirgilAppCredentials, 'virgil/sdk/high_level/virgil_app_credentials'
13
+ autoload :IdentityAttempt, 'virgil/sdk/high_level/identity_attempt'
14
+ autoload :VirgilBuffer, 'virgil/sdk/high_level/virgil_buffer'
15
+ autoload :VirgilStringEncoding, 'virgil/sdk/high_level/virgil_buffer'
16
+ autoload :VirgilCardVerifierInfo, 'virgil/sdk/high_level/virgil_card_verifier_info'
17
+
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,71 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ class VirgilApi
38
+ attr_accessor :context, :keys, :cards
39
+
40
+ class VirgilApiException < StandardError
41
+
42
+ end
43
+
44
+ class VirgilApiAccessTokenException < VirgilApiException
45
+
46
+ def to_s
47
+ "Access tokens are not equal"
48
+ end
49
+
50
+ end
51
+
52
+ def initialize(access_token: nil, context: nil)
53
+
54
+ if (access_token && context)
55
+ raise VirgilApiAccessTokenException.new unless access_token == context.access_token
56
+ end
57
+
58
+
59
+ if context
60
+ self.context = context
61
+ else
62
+ self.context = Virgil::SDK::HighLevel::VirgilContext.new(access_token: access_token)
63
+ end
64
+
65
+ self.keys = VirgilKeyManager.new(self.context)
66
+ self.cards = VirgilCardManager.new(self.context)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,54 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ class VirgilAppCredentials
38
+ attr_reader :app_id, :app_key_data, :app_key_password
39
+
40
+ def initialize(app_id:, app_key_data:, app_key_password:)
41
+ @app_id = app_id
42
+ @app_key_data = app_key_data
43
+ @app_key_password = app_key_password
44
+ end
45
+
46
+ def app_key(crypto)
47
+ crypto.import_private_key(app_key_data.bytes, app_key_password)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+
@@ -0,0 +1,161 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ require 'base64'
35
+ require 'json'
36
+
37
+ module Virgil
38
+ module SDK
39
+ module HighLevel
40
+
41
+ # This class provides a list of methods that simplify the work with an array of bytes.
42
+ VirgilBuffer = Struct.new(:bytes) do
43
+
44
+ def initialize(bytes)
45
+
46
+ self.class.validate_bytes_param(bytes)
47
+
48
+ super
49
+ end
50
+
51
+
52
+ def self.from_bytes(bytes)
53
+
54
+ self.validate_bytes_param(bytes)
55
+
56
+ new(bytes)
57
+
58
+ end
59
+
60
+
61
+ def self.from_string(str, encoding=VirgilStringEncoding::UTF8)
62
+
63
+ case encoding
64
+ when VirgilStringEncoding::BASE64
65
+ return self.from_base64(str)
66
+ when VirgilStringEncoding::HEX
67
+ return self.from_hex(str)
68
+ when VirgilStringEncoding::UTF8
69
+ return self.from_utf8(str)
70
+ else
71
+ ArgumentError.new("encoding is undefined")
72
+ end
73
+
74
+ end
75
+
76
+
77
+ def to_string(encoding=VirgilStringEncoding::UTF8)
78
+ case encoding
79
+ when VirgilStringEncoding::BASE64
80
+ return self.to_base64
81
+ when VirgilStringEncoding::HEX
82
+ return self.to_hex
83
+ when VirgilStringEncoding::UTF8
84
+ return to_s
85
+ else
86
+ ArgumentError.new("encoding is undefined")
87
+ end
88
+ end
89
+
90
+
91
+ def to_s
92
+ bytes.pack('c*')
93
+ end
94
+
95
+ # Initializes a new buffer from file.
96
+ def self.from_file(key_file_path)
97
+ ArgumentError.new("file_path is not valide") unless (File.exist?(key_file_path) && File.readable?(key_file_path))
98
+ str = File.read(key_file_path)
99
+ from_string(str)
100
+ end
101
+
102
+
103
+ # Initializes a new buffer from specified string, which encodes binary data as base-64 digits.
104
+ def self.from_base64(str)
105
+ new(Base64.decode64(str).bytes)
106
+ end
107
+
108
+
109
+ #Initializes a new buffer from specified string, which encodes binary data as utf-8.
110
+ def self.from_utf8(str)
111
+ new(str.bytes)
112
+ end
113
+
114
+
115
+ # Initializes a new buffer from specified string, which encodes binary data as hexadecimal digits.
116
+ def self.from_hex(str)
117
+ new(str.scan(/../).map { |x| x.hex })
118
+ end
119
+
120
+
121
+ # Converts all the bytes in current buffer to its equivalent string representation that
122
+ # is encoded with base-64 digits.
123
+ def to_base64
124
+ Base64.strict_encode64(to_s)
125
+ end
126
+
127
+
128
+ # Decodes all the bytes in current buffer into a string.
129
+ def to_utf8
130
+ to_s
131
+ end
132
+
133
+
134
+ # Converts the numeric value of each element of a current buffer bytes to its
135
+ # equivalent hexadecimal string representation.
136
+ def to_hex
137
+ to_s.each_byte.map { |b| b.to_s(16) }.join
138
+ end
139
+
140
+
141
+ def self.validate_buffer_param(param, param_name="buffer")
142
+ raise ArgumentError.new("#{param_name} is not valid") unless (param.is_a?(VirgilBuffer) || param.is_a?(String))
143
+ end
144
+
145
+ private
146
+
147
+ def self.validate_bytes_param(param)
148
+ raise ArgumentError.new("bytes is not valid") if (!param.is_a?(Array) || param.empty?)
149
+ end
150
+
151
+ end
152
+
153
+ module VirgilStringEncoding
154
+ BASE64 = 1
155
+ HEX = 2
156
+ UTF8 = 3
157
+ end
158
+
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,204 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ # A Virgil Card is the main entity of the Virgil Security services, it includes an information
38
+ # about the user and his public key. The Virgil Card identifies the user by one of his available
39
+ # types, such as an email, a phone number, etc.
40
+ class VirgilCard
41
+ attr_reader :context, :card
42
+ protected :context, :card
43
+
44
+ def initialize(context:, card:)
45
+ @context = context
46
+ @card = card
47
+ end
48
+
49
+
50
+ class AppCredentialsException < StandardError
51
+
52
+ def to_s
53
+ "For this operation we need app_id and app_key"
54
+ end
55
+
56
+ end
57
+
58
+
59
+ def id
60
+ card.id
61
+ end
62
+
63
+
64
+ def identity
65
+ card.identity
66
+ end
67
+
68
+
69
+ def identity_type
70
+ card.identity_type
71
+ end
72
+
73
+
74
+ def data
75
+ card.data
76
+ end
77
+
78
+
79
+ def scope
80
+ card.scope
81
+ end
82
+
83
+ def public_key
84
+ context.crypto.import_public_key(card.public_key)
85
+ end
86
+
87
+
88
+ def device
89
+ card.device
90
+ end
91
+
92
+
93
+ def device_name
94
+ card.device_name
95
+ end
96
+
97
+
98
+ # Exports card's snapshot.
99
+ #
100
+ # Returns:
101
+ # base64-encoded json representation of card's content_snapshot and meta.
102
+ def export
103
+ card.export
104
+ end
105
+
106
+
107
+ # Publish synchronously the card into application Virgil Services scope
108
+ # Raises:
109
+ # Virgil::SDK::Client::HTTP::BaseConnection::ApiError if access_token is invalid or
110
+ # Virgil Card with the same fingerprint already exists in Virgil Security services
111
+ # AppCredentialsException: For this operation we need app_id and app_key
112
+ # if application credentials is missing
113
+ def publish
114
+
115
+ raise NotImplementedError.new("Current card isn't local!") unless @card.scope == Client::Card::APPLICATION
116
+ validate_app_credentials
117
+
118
+ @card = context.client.sign_and_publish_card(
119
+ card,
120
+ context.credentials.app_id,
121
+ context.credentials.app_key(context.crypto))
122
+ end
123
+
124
+
125
+ # Publish synchronously the global card into application Virgil Services scope
126
+ # Raises:
127
+ # Virgil Card with the same fingerprint already exists in Virgil Security services
128
+ def publish_as_global(validation_token)
129
+
130
+ raise NotImplementedError.new("Current card isn't global!") unless @card.scope == Client::Card::GLOBAL
131
+
132
+ @card.validation_token = validation_token
133
+ @card = context.client.publish_as_global_card(card)
134
+ @card.validation_token = validation_token
135
+ end
136
+
137
+
138
+ # Encrypts the specified data for current Virgil card recipient
139
+ #
140
+ # Args:
141
+ # buffer: The data to be encrypted.
142
+ #
143
+ # Returns:
144
+ # Encrypted data for current Virgil card recipient
145
+ #
146
+ # Raises:
147
+ # ArgumentError: buffer is not valid if buffer doesn't have type VirgilBuffer or String
148
+ def encrypt(buffer)
149
+
150
+ VirgilBuffer.validate_buffer_param(buffer)
151
+
152
+ VirgilBuffer.new(context.crypto.encrypt(buffer.bytes, public_key))
153
+ end
154
+
155
+
156
+ # Initiates an identity verification process for current Card indentity type. It is only working for
157
+ # Global identity types like Email.
158
+ #
159
+ # Args:
160
+ # identity_options: The data to be encrypted.
161
+ #
162
+ # Returns:
163
+ # An instance of VirgilIdentity::VerificationAttempt that contains
164
+ # information about operation etc
165
+ def check_identity(identity_options = nil)
166
+ action_id = context.client.verify_identity(identity, identity_type)
167
+ VirgilIdentity::VerificationAttempt.new(context: context, action_id: action_id,
168
+ identity: identity, identity_type: identity_type,
169
+ additional_options: identity_options)
170
+ end
171
+
172
+
173
+ # Verifies the specified buffer and signature with current VirgilCard recipient
174
+ #
175
+ # Args:
176
+ # buffer: The data to be verified.
177
+ # signature: The signature used to verify the data integrity.
178
+ #
179
+ # Returns:
180
+ # true if signature is valid, false otherwise.
181
+ #
182
+ # Raises:
183
+ # ArgumentError: buffer is not valid if buffer doesn't have type VirgilBuffer or String
184
+ # ArgumentError: buffer is not valid if signature doesn't have type VirgilBuffer or String
185
+ def verify(buffer, signature)
186
+ VirgilBuffer.validate_buffer_param(buffer)
187
+ VirgilBuffer.validate_buffer_param(signature, "signature")
188
+ context.crypto.verify(buffer.bytes, signature.bytes, public_key)
189
+ end
190
+
191
+ private
192
+
193
+ def validate_app_credentials
194
+
195
+ if !(context.credentials && context.credentials.app_id && context.credentials.app_key(context.crypto))
196
+ raise AppCredentialsException
197
+ end
198
+
199
+ end
200
+ end
201
+
202
+ end
203
+ end
204
+ end