trezor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,392 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf'
7
+
8
+
9
+ ##
10
+ # Imports
11
+ #
12
+ require 'google/protobuf/descriptor.pb'
13
+
14
+ module Trezor
15
+ module Protobuf
16
+ ::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
17
+
18
+ ##
19
+ # Enum Classes
20
+ #
21
+ class FailureType < ::Protobuf::Enum
22
+ define :Failure_UnexpectedMessage, 1
23
+ define :Failure_ButtonExpected, 2
24
+ define :Failure_DataError, 3
25
+ define :Failure_ActionCancelled, 4
26
+ define :Failure_PinExpected, 5
27
+ define :Failure_PinCancelled, 6
28
+ define :Failure_PinInvalid, 7
29
+ define :Failure_InvalidSignature, 8
30
+ define :Failure_ProcessError, 9
31
+ define :Failure_NotEnoughFunds, 10
32
+ define :Failure_NotInitialized, 11
33
+ define :Failure_PinMismatch, 12
34
+ define :Failure_FirmwareError, 99
35
+ end
36
+
37
+ class OutputScriptType < ::Protobuf::Enum
38
+ define :PAYTOADDRESS, 0
39
+ define :PAYTOSCRIPTHASH, 1
40
+ define :PAYTOMULTISIG, 2
41
+ define :PAYTOOPRETURN, 3
42
+ define :PAYTOWITNESS, 4
43
+ define :PAYTOP2SHWITNESS, 5
44
+ end
45
+
46
+ class InputScriptType < ::Protobuf::Enum
47
+ define :SPENDADDRESS, 0
48
+ define :SPENDMULTISIG, 1
49
+ define :EXTERNAL, 2
50
+ define :SPENDWITNESS, 3
51
+ define :SPENDP2SHWITNESS, 4
52
+ end
53
+
54
+ class RequestType < ::Protobuf::Enum
55
+ define :TXINPUT, 0
56
+ define :TXOUTPUT, 1
57
+ define :TXMETA, 2
58
+ define :TXFINISHED, 3
59
+ define :TXEXTRADATA, 4
60
+ end
61
+
62
+ class ButtonRequestType < ::Protobuf::Enum
63
+ define :ButtonRequest_Other, 1
64
+ define :ButtonRequest_FeeOverThreshold, 2
65
+ define :ButtonRequest_ConfirmOutput, 3
66
+ define :ButtonRequest_ResetDevice, 4
67
+ define :ButtonRequest_ConfirmWord, 5
68
+ define :ButtonRequest_WipeDevice, 6
69
+ define :ButtonRequest_ProtectCall, 7
70
+ define :ButtonRequest_SignTx, 8
71
+ define :ButtonRequest_FirmwareCheck, 9
72
+ define :ButtonRequest_Address, 10
73
+ define :ButtonRequest_PublicKey, 11
74
+ define :ButtonRequest_MnemonicWordCount, 12
75
+ define :ButtonRequest_MnemonicInput, 13
76
+ define :ButtonRequest_PassphraseType, 14
77
+ end
78
+
79
+ class PinMatrixRequestType < ::Protobuf::Enum
80
+ define :PinMatrixRequestType_Current, 1
81
+ define :PinMatrixRequestType_NewFirst, 2
82
+ define :PinMatrixRequestType_NewSecond, 3
83
+ end
84
+
85
+ class RecoveryDeviceType < ::Protobuf::Enum
86
+ define :RecoveryDeviceType_ScrambledWords, 0
87
+ define :RecoveryDeviceType_Matrix, 1
88
+ end
89
+
90
+ class WordRequestType < ::Protobuf::Enum
91
+ define :WordRequestType_Plain, 0
92
+ define :WordRequestType_Matrix9, 1
93
+ define :WordRequestType_Matrix6, 2
94
+ end
95
+
96
+ class PassphraseSourceType < ::Protobuf::Enum
97
+ define :ASK, 0
98
+ define :DEVICE, 1
99
+ define :HOST, 2
100
+ end
101
+
102
+ class NEMMosaicLevy < ::Protobuf::Enum
103
+ define :MosaicLevy_Absolute, 1
104
+ define :MosaicLevy_Percentile, 2
105
+ end
106
+
107
+ class NEMSupplyChangeType < ::Protobuf::Enum
108
+ define :SupplyChange_Increase, 1
109
+ define :SupplyChange_Decrease, 2
110
+ end
111
+
112
+ class NEMModificationType < ::Protobuf::Enum
113
+ define :CosignatoryModification_Add, 1
114
+ define :CosignatoryModification_Delete, 2
115
+ end
116
+
117
+ class NEMImportanceTransferMode < ::Protobuf::Enum
118
+ define :ImportanceTransfer_Activate, 1
119
+ define :ImportanceTransfer_Deactivate, 2
120
+ end
121
+
122
+ class LiskTransactionType < ::Protobuf::Enum
123
+ define :Transfer, 0
124
+ define :RegisterSecondPassphrase, 1
125
+ define :RegisterDelegate, 2
126
+ define :CastVotes, 3
127
+ define :RegisterMultisignatureAccount, 4
128
+ define :CreateDapp, 5
129
+ define :TransferIntoDapp, 6
130
+ define :TransferOutOfDapp, 7
131
+ end
132
+
133
+
134
+ ##
135
+ # Message Classes
136
+ #
137
+ class HDNodeType < ::Protobuf::Message; end
138
+ class HDNodePathType < ::Protobuf::Message; end
139
+ class MultisigRedeemScriptType < ::Protobuf::Message; end
140
+ class TxInputType < ::Protobuf::Message; end
141
+ class TxOutputType < ::Protobuf::Message; end
142
+ class TxOutputBinType < ::Protobuf::Message; end
143
+ class TransactionType < ::Protobuf::Message; end
144
+ class TxRequestDetailsType < ::Protobuf::Message; end
145
+ class TxRequestSerializedType < ::Protobuf::Message; end
146
+ class IdentityType < ::Protobuf::Message; end
147
+ class NEMTransactionCommon < ::Protobuf::Message; end
148
+ class NEMTransfer < ::Protobuf::Message; end
149
+ class NEMMosaic < ::Protobuf::Message; end
150
+ class NEMProvisionNamespace < ::Protobuf::Message; end
151
+ class NEMMosaicCreation < ::Protobuf::Message; end
152
+ class NEMMosaicDefinition < ::Protobuf::Message; end
153
+ class NEMMosaicSupplyChange < ::Protobuf::Message; end
154
+ class NEMAggregateModification < ::Protobuf::Message; end
155
+ class NEMCosignatoryModification < ::Protobuf::Message; end
156
+ class NEMImportanceTransfer < ::Protobuf::Message; end
157
+ class StellarAssetType < ::Protobuf::Message; end
158
+ class LiskTransactionCommon < ::Protobuf::Message; end
159
+ class LiskTransactionAsset < ::Protobuf::Message; end
160
+ class LiskSignatureType < ::Protobuf::Message; end
161
+ class LiskDelegateType < ::Protobuf::Message; end
162
+ class LiskMultisignatureType < ::Protobuf::Message; end
163
+
164
+
165
+ ##
166
+ # File Options
167
+ #
168
+ set_option :java_package, "com.satoshilabs.trezor.lib.protobuf"
169
+ set_option :java_outer_classname, "TrezorType"
170
+
171
+
172
+ ##
173
+ # Message Fields
174
+ #
175
+ class HDNodeType
176
+ required :uint32, :depth, 1
177
+ required :uint32, :fingerprint, 2
178
+ required :uint32, :child_num, 3
179
+ required :bytes, :chain_code, 4
180
+ optional :bytes, :private_key, 5
181
+ optional :bytes, :public_key, 6
182
+ end
183
+
184
+ class HDNodePathType
185
+ required ::Trezor::Protobuf::HDNodeType, :node, 1
186
+ repeated :uint32, :address_n, 2
187
+ end
188
+
189
+ class MultisigRedeemScriptType
190
+ repeated ::Trezor::Protobuf::HDNodePathType, :pubkeys, 1
191
+ repeated :bytes, :signatures, 2
192
+ optional :uint32, :m, 3
193
+ end
194
+
195
+ class TxInputType
196
+ repeated :uint32, :address_n, 1
197
+ required :bytes, :prev_hash, 2
198
+ required :uint32, :prev_index, 3
199
+ optional :bytes, :script_sig, 4
200
+ optional :uint32, :sequence, 5, :default => 4294967295
201
+ optional ::Trezor::Protobuf::InputScriptType, :script_type, 6, :default => ::Trezor::Protobuf::InputScriptType::SPENDADDRESS
202
+ optional ::Trezor::Protobuf::MultisigRedeemScriptType, :multisig, 7
203
+ optional :uint64, :amount, 8
204
+ optional :uint32, :decred_tree, 9
205
+ optional :uint32, :decred_script_version, 10
206
+ end
207
+
208
+ class TxOutputType
209
+ optional :string, :address, 1
210
+ repeated :uint32, :address_n, 2
211
+ required :uint64, :amount, 3
212
+ required ::Trezor::Protobuf::OutputScriptType, :script_type, 4
213
+ optional ::Trezor::Protobuf::MultisigRedeemScriptType, :multisig, 5
214
+ optional :bytes, :op_return_data, 6
215
+ optional :uint32, :decred_script_version, 7
216
+ end
217
+
218
+ class TxOutputBinType
219
+ required :uint64, :amount, 1
220
+ required :bytes, :script_pubkey, 2
221
+ optional :uint32, :decred_script_version, 3
222
+ end
223
+
224
+ class TransactionType
225
+ optional :uint32, :version, 1
226
+ repeated ::Trezor::Protobuf::TxInputType, :inputs, 2
227
+ repeated ::Trezor::Protobuf::TxOutputBinType, :bin_outputs, 3
228
+ repeated ::Trezor::Protobuf::TxOutputType, :outputs, 5
229
+ optional :uint32, :lock_time, 4
230
+ optional :uint32, :inputs_cnt, 6
231
+ optional :uint32, :outputs_cnt, 7
232
+ optional :bytes, :extra_data, 8
233
+ optional :uint32, :extra_data_len, 9
234
+ optional :uint32, :decred_expiry, 10
235
+ optional :bool, :overwintered, 11
236
+ end
237
+
238
+ class TxRequestDetailsType
239
+ optional :uint32, :request_index, 1
240
+ optional :bytes, :tx_hash, 2
241
+ optional :uint32, :extra_data_len, 3
242
+ optional :uint32, :extra_data_offset, 4
243
+ end
244
+
245
+ class TxRequestSerializedType
246
+ optional :uint32, :signature_index, 1
247
+ optional :bytes, :signature, 2
248
+ optional :bytes, :serialized_tx, 3
249
+ end
250
+
251
+ class IdentityType
252
+ optional :string, :proto, 1
253
+ optional :string, :user, 2
254
+ optional :string, :host, 3
255
+ optional :string, :port, 4
256
+ optional :string, :path, 5
257
+ optional :uint32, :index, 6, :default => 0
258
+ end
259
+
260
+ class NEMTransactionCommon
261
+ repeated :uint32, :address_n, 1
262
+ optional :uint32, :network, 2
263
+ optional :uint32, :timestamp, 3
264
+ optional :uint64, :fee, 4
265
+ optional :uint32, :deadline, 5
266
+ optional :bytes, :signer, 6
267
+ end
268
+
269
+ class NEMTransfer
270
+ optional :string, :recipient, 1
271
+ optional :uint64, :amount, 2
272
+ optional :bytes, :payload, 3
273
+ optional :bytes, :public_key, 4
274
+ repeated ::Trezor::Protobuf::NEMMosaic, :mosaics, 5
275
+ end
276
+
277
+ class NEMMosaic
278
+ optional :string, :namespace, 1
279
+ optional :string, :mosaic, 2
280
+ optional :uint64, :quantity, 3
281
+ end
282
+
283
+ class NEMProvisionNamespace
284
+ optional :string, :namespace, 1
285
+ optional :string, :parent, 2
286
+ optional :string, :sink, 3
287
+ optional :uint64, :fee, 4
288
+ end
289
+
290
+ class NEMMosaicCreation
291
+ optional ::Trezor::Protobuf::NEMMosaicDefinition, :definition, 1
292
+ optional :string, :sink, 2
293
+ optional :uint64, :fee, 3
294
+ end
295
+
296
+ class NEMMosaicDefinition
297
+ optional :string, :name, 1
298
+ optional :string, :ticker, 2
299
+ optional :string, :namespace, 3
300
+ optional :string, :mosaic, 4
301
+ optional :uint32, :divisibility, 5
302
+ optional ::Trezor::Protobuf::NEMMosaicLevy, :levy, 6
303
+ optional :uint64, :fee, 7
304
+ optional :string, :levy_address, 8
305
+ optional :string, :levy_namespace, 9
306
+ optional :string, :levy_mosaic, 10
307
+ optional :uint64, :supply, 11
308
+ optional :bool, :mutable_supply, 12
309
+ optional :bool, :transferable, 13
310
+ optional :string, :description, 14
311
+ repeated :uint32, :networks, 15
312
+ end
313
+
314
+ class NEMMosaicSupplyChange
315
+ optional :string, :namespace, 1
316
+ optional :string, :mosaic, 2
317
+ optional ::Trezor::Protobuf::NEMSupplyChangeType, :type, 3
318
+ optional :uint64, :delta, 4
319
+ end
320
+
321
+ class NEMAggregateModification
322
+ repeated ::Trezor::Protobuf::NEMCosignatoryModification, :modifications, 1
323
+ optional :sint32, :relative_change, 2
324
+ end
325
+
326
+ class NEMCosignatoryModification
327
+ optional ::Trezor::Protobuf::NEMModificationType, :type, 1
328
+ optional :bytes, :public_key, 2
329
+ end
330
+
331
+ class NEMImportanceTransfer
332
+ optional ::Trezor::Protobuf::NEMImportanceTransferMode, :mode, 1
333
+ optional :bytes, :public_key, 2
334
+ end
335
+
336
+ class StellarAssetType
337
+ optional :uint32, :type, 1
338
+ optional :string, :code, 2
339
+ optional :bytes, :issuer, 3
340
+ end
341
+
342
+ class LiskTransactionCommon
343
+ optional ::Trezor::Protobuf::LiskTransactionType, :type, 1
344
+ optional :uint64, :amount, 2, :default => 0
345
+ optional :uint64, :fee, 3
346
+ optional :string, :recipient_id, 4
347
+ optional :bytes, :sender_public_key, 5
348
+ optional :bytes, :requester_public_key, 6
349
+ optional :bytes, :signature, 7
350
+ optional :uint32, :timestamp, 8
351
+ optional ::Trezor::Protobuf::LiskTransactionAsset, :asset, 9
352
+ end
353
+
354
+ class LiskTransactionAsset
355
+ optional ::Trezor::Protobuf::LiskSignatureType, :signature, 1
356
+ optional ::Trezor::Protobuf::LiskDelegateType, :delegate, 2
357
+ repeated :string, :votes, 3
358
+ optional ::Trezor::Protobuf::LiskMultisignatureType, :multisignature, 4
359
+ optional :string, :data, 5
360
+ end
361
+
362
+ class LiskSignatureType
363
+ optional :bytes, :public_key, 1
364
+ end
365
+
366
+ class LiskDelegateType
367
+ optional :string, :username, 1
368
+ end
369
+
370
+ class LiskMultisignatureType
371
+ optional :uint32, :min, 1
372
+ optional :uint32, :life_time, 2
373
+ repeated :string, :keys_group, 3
374
+ end
375
+
376
+
377
+ ##
378
+ # Extended Message Fields
379
+ #
380
+ class ::Google::Protobuf::EnumValueOptions < ::Protobuf::Message
381
+ optional :bool, :".trezor.protobuf.wire_in", 50002, :extension => true
382
+ optional :bool, :".trezor.protobuf.wire_out", 50003, :extension => true
383
+ optional :bool, :".trezor.protobuf.wire_debug_in", 50004, :extension => true
384
+ optional :bool, :".trezor.protobuf.wire_debug_out", 50005, :extension => true
385
+ optional :bool, :".trezor.protobuf.wire_tiny", 50006, :extension => true
386
+ optional :bool, :".trezor.protobuf.wire_bootloader", 50007, :extension => true
387
+ end
388
+
389
+ end
390
+
391
+ end
392
+
@@ -0,0 +1,6 @@
1
+ require 'trezor/utils/buffer'
2
+
3
+ module Trezor
4
+ module Utils
5
+ end
6
+ end
@@ -0,0 +1,39 @@
1
+ require 'net/ssh/buffer'
2
+
3
+ module Trezor
4
+ module Utils
5
+ class Buffer < Net::SSH::Buffer
6
+ # Writes each argument to the buffer as a network-byte-order-encoded
7
+ # short (2-byte) integer. Does not alter the read position. Returns the
8
+ # buffer object.
9
+ def write_short(*n)
10
+ @content << n.pack('n*')
11
+ self
12
+ end
13
+
14
+ # Return the next two bytes as a short integer (in network byte order).
15
+ # Returns nil if there are less than 2 bytes remaining to be read in the
16
+ # buffer.
17
+ def read_short
18
+ b = read(2) or return nil
19
+ b.unpack('n').first
20
+ end
21
+
22
+ # Writes each argument to the buffer as binary data (hex to binary)
23
+ # Does not alter the read position. Returns the
24
+ # buffer object.
25
+ def write_htb(*blobs)
26
+ @content << blobs.pack('H*')
27
+ self
28
+ end
29
+
30
+ # Writes each argument to the buffer as hex data (binary to hex)
31
+ # Does not alter the read position. Returns the
32
+ # buffer object.
33
+ def write_bth(*blobs)
34
+ blobs.each { |b| @content << b.unpack('H*').first }
35
+ self
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module Trezor
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/trezor.gemspec ADDED
@@ -0,0 +1,36 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "trezor/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trezor"
8
+ spec.version = Trezor::VERSION
9
+ spec.authors = ["Tomás Rojas"]
10
+ spec.email = ["tmsrjs@gmail.com"]
11
+
12
+ spec.summary = %q{Trezor}
13
+ #spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = 'https://github.com/tmsrjs/trezor-ruby'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency 'bcrypt_pbkdf', '~> 1.0', '< 2.0'
24
+ spec.add_dependency 'ecdsa'
25
+ spec.add_dependency 'ed25519', '~> 1.2', '< 2.0'
26
+ spec.add_dependency 'http'
27
+ spec.add_dependency 'net-ssh', '~> 5.0', '>= 5.0.1'
28
+ spec.add_dependency 'openssl', '~> 2.1'
29
+ spec.add_dependency 'protobuf'
30
+ spec.add_dependency 'trollop'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.16'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ spec.add_development_dependency 'byebug', '~> 10.0'
36
+ end