sygna 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sygna/config.rb +23 -0
- data/lib/sygna/crypt.rb +194 -0
- data/lib/sygna/private_info.rb +26 -0
- data/lib/sygna/signature.rb +29 -0
- data/lib/sygna/version.rb +3 -0
- data/lib/sygna.rb +23 -0
- data/sygna.gemspec +42 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 91869e76d9647d23dc4a187dd8afb3c62f5224da4c9e08b41a9f6b21ce8d8b6e
|
4
|
+
data.tar.gz: 3083b0dc21a7bd59f6bffaf0d06eea801468c0764c68ba9be0fc1ead416e9230
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42ee7fcada7af5573a607045973d018230d1c65c9cf347dc892b37696946332ab41fc08e41bbbbc3e8a29cf59784bc3a5081d75b724fb19b1396b703ea53edc9
|
7
|
+
data.tar.gz: 75754c3411b8e26903f054a7591e8ecfe0804ff5b952533b3b5ba41f8caf1e211c7b70eea6b24a6569ac92af51bcfffd4e93fc1b424a4f3bea7c65938ff9b226
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/niclin/ecies
|
3
|
+
revision: 8b1c1af0c5444fc715a0f110ea3fcba535789fcd
|
4
|
+
branch: master
|
5
|
+
specs:
|
6
|
+
ecies (0.3.0)
|
7
|
+
|
8
|
+
PATH
|
9
|
+
remote: .
|
10
|
+
specs:
|
11
|
+
sygna (0.1.0)
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
diff-lcs (1.3)
|
17
|
+
ffi (1.12.2)
|
18
|
+
rake (12.3.3)
|
19
|
+
rspec (3.9.0)
|
20
|
+
rspec-core (~> 3.9.0)
|
21
|
+
rspec-expectations (~> 3.9.0)
|
22
|
+
rspec-mocks (~> 3.9.0)
|
23
|
+
rspec-core (3.9.1)
|
24
|
+
rspec-support (~> 3.9.1)
|
25
|
+
rspec-expectations (3.9.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.9.0)
|
28
|
+
rspec-mocks (3.9.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-support (3.9.2)
|
32
|
+
secp256k1-ruby (0.4.1)
|
33
|
+
ffi (>= 1.9.10)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (~> 1.17)
|
40
|
+
ecies!
|
41
|
+
rake (~> 12)
|
42
|
+
rspec (~> 3.7)
|
43
|
+
secp256k1-ruby
|
44
|
+
sygna!
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Nic
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Sygna
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sygna`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sygna'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sygna
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sygna.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sygna"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/sygna/config.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Sygna
|
2
|
+
class Config
|
3
|
+
class << self
|
4
|
+
attr_writer :instance
|
5
|
+
|
6
|
+
def instance
|
7
|
+
@instance ||= new
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_accessor :api_key
|
12
|
+
attr_accessor :private_key
|
13
|
+
|
14
|
+
def initialize(config = {})
|
15
|
+
self.api_key = config[:api_key]
|
16
|
+
self.private_key = config[:private_key]
|
17
|
+
end
|
18
|
+
|
19
|
+
def valid?
|
20
|
+
!self.api_key.empty? && !self.private_key.empty? rescue false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/sygna/crypt.rb
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
# reference: https://github.com/jamoes/ecies/blob/master/lib/ecies/crypt.rb
|
2
|
+
|
3
|
+
module Sygna
|
4
|
+
# Provides functionality for encrypting and decrypting messages using ECIES.
|
5
|
+
# Encapsulates the configuration parameters chosen for ECIES.
|
6
|
+
class Crypt
|
7
|
+
|
8
|
+
# The allowed digest algorithms for ECIES.
|
9
|
+
DIGESTS = %w{SHA1 SHA224 SHA256 SHA384 SHA512}
|
10
|
+
|
11
|
+
# The allowed cipher algorithms for ECIES.
|
12
|
+
CIPHERS = %w{AES-128-CBC AES-192-CBC AES-256-CBC AES-128-CTR AES-192-CTR AES-256-CTR}
|
13
|
+
|
14
|
+
# The initialization vector used in ECIES. Quoting from sec1-v2:
|
15
|
+
# "When using ECIES, some exception are made. For the CBC and CTR modes, the
|
16
|
+
# initial value or initial counter are set to be zero and are omitted from
|
17
|
+
# the ciphertext. In general this practice is not advisable, but in the case
|
18
|
+
# of ECIES it is acceptable because the definition of ECIES implies the
|
19
|
+
# symmetric block cipher key is only to be used once.
|
20
|
+
IV = ("\x00" * 16).force_encoding(Encoding::BINARY)
|
21
|
+
|
22
|
+
# Creates a new instance of {Crypt}.
|
23
|
+
#
|
24
|
+
# @param cipher [String] The cipher algorithm to use. Must be one of
|
25
|
+
# {CIPHERS}.
|
26
|
+
# @param digest [String,OpenSSL::Digest] The digest algorithm to use for
|
27
|
+
# HMAC and KDF. Must be one of {DIGESTS}.
|
28
|
+
# @param mac_length [:half,:full] The length of the mac. If :half, the mac
|
29
|
+
# length will be equal to half the mac_digest's digest_legnth. If
|
30
|
+
# :full, the mac length will be equal to the mac_digest's
|
31
|
+
# digest_length.
|
32
|
+
# @param kdf_digest [String,OpenSSL::Digest,nil] The digest algorithm to
|
33
|
+
# use for KDF. If not specified, the `digest` argument will be used.
|
34
|
+
# @param mac_digest [String,OpenSSL::Digest,nil] The digest algorithm to
|
35
|
+
# use for HMAC. If not specified, the `digest` argument will be used.
|
36
|
+
# @param kdf_shared_info [String] Optional. A string containing the shared
|
37
|
+
# info used for KDF, also known as SharedInfo1.
|
38
|
+
# @param mac_shared_info [String] Optional. A string containing the shared
|
39
|
+
# info used for MAC, also known as SharedInfo2.
|
40
|
+
def initialize(cipher: 'AES-256-CTR', digest: 'SHA256', mac_length: :half, kdf_digest: nil, mac_digest: nil, kdf_shared_info: '', mac_shared_info: '')
|
41
|
+
@cipher = OpenSSL::Cipher.new(cipher)
|
42
|
+
@mac_digest = OpenSSL::Digest.new(mac_digest || digest)
|
43
|
+
@kdf_digest = OpenSSL::Digest.new(kdf_digest || digest)
|
44
|
+
@kdf_shared_info = kdf_shared_info
|
45
|
+
@mac_shared_info = mac_shared_info
|
46
|
+
|
47
|
+
CIPHERS.include?(@cipher.name) or raise "Cipher must be one of #{CIPHERS}"
|
48
|
+
DIGESTS.include?(@mac_digest.name) or raise "Digest must be one of #{DIGESTS}"
|
49
|
+
DIGESTS.include?(@kdf_digest.name) or raise "Digest must be one of #{DIGESTS}"
|
50
|
+
[:half, :full].include?(mac_length) or raise "mac_length must be :half or :full"
|
51
|
+
|
52
|
+
@mac_length = @mac_digest.digest_length
|
53
|
+
@mac_length /= 2 if mac_length == :half
|
54
|
+
end
|
55
|
+
|
56
|
+
# Encrypts a message to a public key using ECIES.
|
57
|
+
#
|
58
|
+
# @param key [OpenSSL::EC:PKey] The public key.
|
59
|
+
# @param message [String] The plain-text message.
|
60
|
+
# @return [String] The octet string of the encrypted message.
|
61
|
+
def encrypt(key, message)
|
62
|
+
key.public_key? or raise "Must have public key to encrypt"
|
63
|
+
@cipher.reset
|
64
|
+
|
65
|
+
group_copy = OpenSSL::PKey::EC::Group.new(key.group)
|
66
|
+
group_copy.point_conversion_form = :compressed
|
67
|
+
ephemeral_key = OpenSSL::PKey::EC.new(group_copy).generate_key
|
68
|
+
ephemeral_public_key_octet = ephemeral_key.public_key.to_bn.to_s(2)
|
69
|
+
|
70
|
+
shared_secret = ephemeral_key.dh_compute_key(key.public_key)
|
71
|
+
|
72
|
+
key_pair = kdf(shared_secret, @cipher.key_len + @mac_length, ephemeral_public_key_octet)
|
73
|
+
cipher_key = key_pair.byteslice(0, @cipher.key_len)
|
74
|
+
hmac_key = key_pair.byteslice(-@mac_length, @mac_length)
|
75
|
+
|
76
|
+
@cipher.encrypt
|
77
|
+
@cipher.iv = IV
|
78
|
+
@cipher.key = cipher_key
|
79
|
+
ciphertext = @cipher.update(message) + @cipher.final
|
80
|
+
|
81
|
+
mac = OpenSSL::HMAC.digest(@mac_digest, hmac_key, ciphertext + @mac_shared_info).byteslice(0, @mac_length)
|
82
|
+
|
83
|
+
ephemeral_public_key_octet + ciphertext + mac
|
84
|
+
end
|
85
|
+
|
86
|
+
# Decrypts a message with a private key using ECIES.
|
87
|
+
#
|
88
|
+
# @param key [OpenSSL::EC:PKey] The private key.
|
89
|
+
# @param encrypted_message [String] Octet string of the encrypted message.
|
90
|
+
# @return [String] The plain-text message.
|
91
|
+
def decrypt(key, encrypted_message)
|
92
|
+
key.private_key? or raise "Must have private key to decrypt"
|
93
|
+
@cipher.reset
|
94
|
+
|
95
|
+
group_copy = OpenSSL::PKey::EC::Group.new(key.group)
|
96
|
+
group_copy.point_conversion_form = :compressed
|
97
|
+
|
98
|
+
ephemeral_public_key_length = group_copy.generator.to_bn.to_s(2).bytesize
|
99
|
+
ciphertext_length = encrypted_message.bytesize - ephemeral_public_key_length - @mac_length
|
100
|
+
ciphertext_length > 0 or raise OpenSSL::PKey::ECError, "Encrypted message too short"
|
101
|
+
|
102
|
+
ephemeral_public_key_octet = encrypted_message.byteslice(0, ephemeral_public_key_length)
|
103
|
+
ciphertext = encrypted_message.byteslice(ephemeral_public_key_length, ciphertext_length)
|
104
|
+
mac = encrypted_message.byteslice(-@mac_length, @mac_length)
|
105
|
+
|
106
|
+
ephemeral_public_key = OpenSSL::PKey::EC::Point.new(group_copy, OpenSSL::BN.new(ephemeral_public_key_octet, 2))
|
107
|
+
|
108
|
+
shared_secret = key.dh_compute_key(ephemeral_public_key)
|
109
|
+
|
110
|
+
key_pair = kdf(shared_secret, @cipher.key_len + @mac_length, ephemeral_public_key_octet)
|
111
|
+
cipher_key = key_pair.byteslice(0, @cipher.key_len)
|
112
|
+
hmac_key = key_pair.byteslice(-@mac_length, @mac_length)
|
113
|
+
|
114
|
+
computed_mac = OpenSSL::HMAC.digest(@mac_digest, hmac_key, ciphertext + @mac_shared_info).byteslice(0, @mac_length)
|
115
|
+
computed_mac == mac or raise OpenSSL::PKey::ECError, "Invalid Message Authenticaton Code"
|
116
|
+
|
117
|
+
@cipher.decrypt
|
118
|
+
@cipher.iv = IV
|
119
|
+
@cipher.key = cipher_key
|
120
|
+
|
121
|
+
@cipher.update(ciphertext) + @cipher.final
|
122
|
+
end
|
123
|
+
|
124
|
+
# Key-derivation function, compatible with ANSI-X9.63-KDF
|
125
|
+
#
|
126
|
+
# @param shared_secret [String] The shared secret from which the key will
|
127
|
+
# be derived.
|
128
|
+
# @param length [Integer] The length of the key to generate.
|
129
|
+
# @param shared_info_suffix [String] The suffix to append to the
|
130
|
+
# shared_info.
|
131
|
+
# @return [String] Octet string of the derived key.
|
132
|
+
def kdf(shared_secret, length, shared_info_suffix)
|
133
|
+
length >=0 or raise "length cannot be negative"
|
134
|
+
return "" if length == 0
|
135
|
+
|
136
|
+
if length / @kdf_digest.digest_length >= 0xFF_FF_FF_FF
|
137
|
+
raise "length too large"
|
138
|
+
end
|
139
|
+
|
140
|
+
io = StringIO.new(String.new)
|
141
|
+
counter = 0
|
142
|
+
|
143
|
+
loop do
|
144
|
+
counter += 1
|
145
|
+
counter_bytes = [counter].pack('N')
|
146
|
+
|
147
|
+
io << @kdf_digest.digest(shared_secret + counter_bytes + @kdf_shared_info + shared_info_suffix)
|
148
|
+
if io.pos >= length
|
149
|
+
return io.string.byteslice(0, length)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# @return [String] A string representing this Crypt's parameters.
|
155
|
+
def to_s
|
156
|
+
"KDF-#{@kdf_digest.name}_" +
|
157
|
+
"HMAC-SHA-#{@mac_digest.digest_length * 8}-#{@mac_length * 8}_" +
|
158
|
+
@cipher.name
|
159
|
+
end
|
160
|
+
|
161
|
+
# Converts a hex-encoded public key to an `OpenSSL::PKey::EC`.
|
162
|
+
#
|
163
|
+
# @param hex_string [String] The hex-encoded public key.
|
164
|
+
# @param ec_group [OpenSSL::PKey::EC::Group,String] The elliptical curve
|
165
|
+
# group for this public key.
|
166
|
+
# @return [OpenSSL::PKey::EC] The public key.
|
167
|
+
# @raise [OpenSSL::PKey::EC::Point::Error] If the public key is invalid.
|
168
|
+
def self.public_key_from_hex(hex_string, ec_group = 'secp256k1')
|
169
|
+
ec_group = OpenSSL::PKey::EC::Group.new(ec_group) if ec_group.is_a?(String)
|
170
|
+
key = OpenSSL::PKey::EC.new(ec_group)
|
171
|
+
key.public_key = OpenSSL::PKey::EC::Point.new(ec_group, OpenSSL::BN.new(hex_string, 16))
|
172
|
+
key
|
173
|
+
end
|
174
|
+
|
175
|
+
# Converts a hex-encoded private key to an `OpenSSL::PKey::EC`.
|
176
|
+
#
|
177
|
+
# @param hex_string [String] The hex-encoded private key.
|
178
|
+
# @param ec_group [OpenSSL::PKey::EC::Group,String] The elliptical curve
|
179
|
+
# group for this private key.
|
180
|
+
# @return [OpenSSL::PKey::EC] The private key.
|
181
|
+
# @note The returned key only contains the private component. In order to
|
182
|
+
# populate the public component of the key, you must compute it as
|
183
|
+
# follows: `key.public_key = key.group.generator.mul(key.private_key)`.
|
184
|
+
# @raise [OpenSSL::PKey::ECError] If the private key is invalid.
|
185
|
+
def self.private_key_from_hex(hex_string, ec_group = 'secp256k1')
|
186
|
+
ec_group = OpenSSL::PKey::EC::Group.new(ec_group) if ec_group.is_a?(String)
|
187
|
+
key = OpenSSL::PKey::EC.new(ec_group)
|
188
|
+
key.private_key = OpenSSL::BN.new(hex_string, 16)
|
189
|
+
key.private_key < ec_group.order or raise OpenSSL::PKey::ECError, "Private key greater than group's order"
|
190
|
+
key.private_key > 1 or raise OpenSSL::PKey::ECError, "Private key too small"
|
191
|
+
key
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Sygna
|
2
|
+
module PrivateInfo
|
3
|
+
def self.encode(data, public_key_hex)
|
4
|
+
group = OpenSSL::PKey::EC::Group.new('secp256k1')
|
5
|
+
key = OpenSSL::PKey::EC.new(group)
|
6
|
+
public_key_bn = OpenSSL::BN.new(public_key_hex, 16)
|
7
|
+
public_key = OpenSSL::PKey::EC::Point.new(group, public_key_bn)
|
8
|
+
key.public_key = public_key
|
9
|
+
|
10
|
+
crypt.encrypt(key, data.to_json).unpack('H*').first
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.decode(data)
|
14
|
+
config = Sygna::Config.instance
|
15
|
+
private_key = OpenSSL::PKey::EC.new(config.private_key)
|
16
|
+
|
17
|
+
crypt.decrypt(private_key, [data].pack("H*"))
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.crypt
|
21
|
+
Crypt.new(cipher: "AES-256-CBC", digest: "SHA512", mac_digest: "SHA1")
|
22
|
+
end
|
23
|
+
|
24
|
+
private_class_method :crypt
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Sygna
|
2
|
+
class Signature
|
3
|
+
def initialize(obj)
|
4
|
+
@obj = obj
|
5
|
+
end
|
6
|
+
|
7
|
+
def sign
|
8
|
+
object_string = @obj.merge(empty_signature).to_json
|
9
|
+
|
10
|
+
privkey = Secp256k1::PrivateKey.new(privkey: private_key_binary)
|
11
|
+
|
12
|
+
Secp256k1::Utils.encode_hex(privkey.ecdsa_serialize_compact(privkey.ecdsa_sign(object_string)))
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def private_key_binary
|
18
|
+
config = Sygna::Config.instance
|
19
|
+
|
20
|
+
OpenSSL::PKey::EC.new(config.private_key).private_key.to_s(2)
|
21
|
+
end
|
22
|
+
|
23
|
+
def empty_signature
|
24
|
+
{
|
25
|
+
signature: ""
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/sygna.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "json"
|
2
|
+
require "openssl"
|
3
|
+
require "secp256k1"
|
4
|
+
|
5
|
+
require "sygna/version"
|
6
|
+
require "sygna/config"
|
7
|
+
require "sygna/crypt"
|
8
|
+
require "sygna/private_info"
|
9
|
+
require "sygna/signature"
|
10
|
+
|
11
|
+
module Sygna
|
12
|
+
class Error < StandardError; end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def configure
|
16
|
+
yield config = Sygna::Config.instance
|
17
|
+
end
|
18
|
+
|
19
|
+
def configured?
|
20
|
+
Sygna::Config.instance.valid?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/sygna.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "sygna/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sygna"
|
8
|
+
spec.version = Sygna::VERSION
|
9
|
+
spec.authors = ["Nic"]
|
10
|
+
spec.email = ["niclin0226@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "This is a Ruby library to help you build servers/services within Sygna Bridge Ecosystem."
|
13
|
+
spec.description = "This is a Ruby library to help you build servers/services within Sygna Bridge Ecosystem."
|
14
|
+
spec.homepage = "https://github.com/niclin/sygna"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/niclin/sygna"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/niclin/sygna"
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
38
|
+
spec.add_development_dependency "rake", "~> 12"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.7"
|
40
|
+
|
41
|
+
spec.add_runtime_dependency "secp256k1-ruby"
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sygna
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nic
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: secp256k1-ruby
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: This is a Ruby library to help you build servers/services within Sygna
|
70
|
+
Bridge Ecosystem.
|
71
|
+
email:
|
72
|
+
- niclin0226@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/sygna.rb
|
88
|
+
- lib/sygna/config.rb
|
89
|
+
- lib/sygna/crypt.rb
|
90
|
+
- lib/sygna/private_info.rb
|
91
|
+
- lib/sygna/signature.rb
|
92
|
+
- lib/sygna/version.rb
|
93
|
+
- sygna.gemspec
|
94
|
+
homepage: https://github.com/niclin/sygna
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata:
|
98
|
+
homepage_uri: https://github.com/niclin/sygna
|
99
|
+
source_code_uri: https://github.com/niclin/sygna
|
100
|
+
changelog_uri: https://github.com/niclin/sygna
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.7.8
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: This is a Ruby library to help you build servers/services within Sygna Bridge
|
121
|
+
Ecosystem.
|
122
|
+
test_files: []
|