tencent_trustsql 0.1.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fc09dcdcea01db0f714f71b1a7ebfa6d54c9e4e2960c7befb9ad7f457ba4309d
4
+ data.tar.gz: cdc195d8680ecd696f7eb73f4335ce5a2003cf3dd870323340025de11dabc571
5
+ SHA512:
6
+ metadata.gz: 147ae820056f83ffe940147bb084827c30fd03aac7313bfe8ab562dbd9cf675a8a1eb94bbd0e35dd2632537a02645b33499eae339144bb1aebc9e38bb8aba997
7
+ data.tar.gz: 75cbfa885e849b48dacc9a0713817bacc51b5c3c0d57a23fd5f857c359bc3917466931221eb67c5f25b57e6a6dcdee6617f345457f2f848c31486e71a355b6f1
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.idea/
10
+ test.rb
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at qinshenyong@socialdatamax.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://gems.ruby-china.com"
2
+
3
+ # Specify your gem's dependencies in tencent_trustsql.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tencent_trustsql (0.1.0)
5
+ ecdsa (~> 1.2)
6
+ http (~> 2.2)
7
+
8
+ GEM
9
+ remote: https://gems.ruby-china.com/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ domain_name (0.5.20190701)
14
+ unf (>= 0.0.5, < 1.0.0)
15
+ ecdsa (1.2.0)
16
+ http (2.2.2)
17
+ addressable (~> 2.3)
18
+ http-cookie (~> 1.0)
19
+ http-form_data (~> 1.0.1)
20
+ http_parser.rb (~> 0.6.0)
21
+ http-cookie (1.0.3)
22
+ domain_name (~> 0.5)
23
+ http-form_data (1.0.3)
24
+ http_parser.rb (0.6.0)
25
+ public_suffix (4.0.1)
26
+ rake (10.5.0)
27
+ unf (0.1.4)
28
+ unf_ext
29
+ unf_ext (0.0.7.6)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bundler (~> 2.0)
36
+ rake (~> 10.0)
37
+ tencent_trustsql!
38
+
39
+ BUNDLED WITH
40
+ 2.0.1
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # TencentTrustsql
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/tencent_trustsql`. 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 'tencent_trustsql'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tencent_trustsql
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ private_key = TencentTrustsql.user_private_key
27
+ user_id = uid(database user id)
28
+ config/initialize/tencent_trustsql.rb
29
+ TencentTrustsql.configure do |c|
30
+ c.mch_private_key = private_key_from_baas
31
+ c.mch_id = mch_id
32
+ end
33
+ client = TencentTrustsql::Client.new
34
+ client.test_idm_user_register(private_key, user_id)
35
+ ```
36
+ ## 资产发行申请接口
37
+ ```ruby
38
+ client = TencentTrustsql::Client.new
39
+ client.apply(options)
40
+ ```
41
+ ## 资产直接转让提交
42
+ ```ruby
43
+ require 'tencent_trustsql'
44
+ TencentTrustsql.configure do |c|
45
+ c.mch_private_key = ''
46
+ c.mch_id = ''
47
+ end
48
+ client = TencentTrustsql::Client.new
49
+ # 待替换为 资产直接转让申请 返回结果
50
+ sign_str_list = [
51
+ {
52
+ "account": "1LpqkE1FrCrumjV4aLLn4kL5P5NbyZ1PYD",
53
+ "sign_str": "5bdbc32055c4da8ea784783c41e9bd1b87b2280c1c714a3876e557ca0d4594fc",
54
+ "id": 1,
55
+ }
56
+ ]
57
+ transaction_id = "asset_transfer_submit_1"
58
+ client.asset_transfer_submit transaction_id, sign_str_list
59
+ ```
60
+
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
65
+
66
+ 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).
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tencent_trustsql. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
71
+
72
+ ## Code of Conduct
73
+
74
+ Everyone interacting in the TencentTrustsql project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tencent_trustsql/blob/master/CODE_OF_CONDUCT.md).
75
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tencent_trustsql"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ 算法相关放这里
@@ -0,0 +1,11 @@
1
+ module TencentTrustsql
2
+ module Algorithm
3
+ class Sha256
4
+
5
+ def self.encode(data) #algorithm="SHA256"
6
+ Digest::SHA256.digest data #hexdigest
7
+ end
8
+
9
+ end
10
+ end
11
+ end
File without changes
@@ -0,0 +1,54 @@
1
+ module TencentTrustsql
2
+ module Api
3
+ module AssetIssue
4
+
5
+ def asset_apply(node_ip, node_port, options={})
6
+ asset_apply_base __method__, node_ip, node_port, options
7
+ end
8
+
9
+ def commit(node_ip, node_port, options={})
10
+ asset_commit_base __method__, node_ip, node_port, options
11
+ end
12
+
13
+ # 资产转让申请
14
+ def asset_transfer_apply(node_ip, node_port, options={})
15
+ asset_apply_base __method__, node_ip, node_port, options
16
+ end
17
+
18
+ # 资产直接转让提交
19
+ def asset_transfer_submit(node_ip, node_port, options={})
20
+ asset_commit_base __method__, node_ip, node_port, options
21
+ end
22
+
23
+ def asset_apply_base name, *args
24
+ url_map = {
25
+ asset_apply: 'asset_issue_apply',
26
+ asset_transfer_apply: 'asset_transfer_apply'
27
+ }
28
+ tencent_api = url_map[name]
29
+
30
+ url = "http://#{args[0]}:#{args[1]}/#{tencent_api}"
31
+ params = asset_base_params.merge(args[2])
32
+ http_post(url,params)
33
+ end
34
+
35
+ def asset_commit_base name, *args
36
+ url_map = {
37
+ commit: 'asset_issue_submit',
38
+ asset_transfer_submit: 'asset_transfer_submit'
39
+ }
40
+ tencent_api = url_map[name]
41
+
42
+ url = "http://#{args[0]}:#{args[1]}/#{tencent_api}"
43
+ params = asset_base_params.merge(args[2])
44
+ user_private_key = params.delete(:user_private_key)
45
+ params[:sign_list] = sign_list_sign user_private_key,params[:sign_list]
46
+
47
+ http_post(url,params)
48
+ end
49
+
50
+
51
+ end
52
+ end
53
+ end
54
+
@@ -0,0 +1 @@
1
+ 封装的接口放这里
@@ -0,0 +1,40 @@
1
+ module TencentTrustsql
2
+ module Api
3
+ module Tpki
4
+
5
+ def user_apply(private_key_out, options={})
6
+ url = URL_BASE + 'UserApply'
7
+ public_key_out = TencentTrustsql.encoded_public_key private_key_out
8
+
9
+ params = {user_pub_key: public_key_out, **tpki_base_params, **options}
10
+
11
+ http_post url, params
12
+ end
13
+
14
+ def user_get(options={})
15
+ url = URL_BASE + 'UserGet'
16
+ params = tpki_base_params.merge(options)
17
+
18
+ http_post url, params
19
+ end
20
+
21
+ def account_apply(private_key_out, options={})
22
+ url = URL_BASE + 'AccountApply'
23
+ public_key_out = TencentTrustsql.encoded_public_key private_key_out
24
+ # params = tpki_base_params.merge!({ acc_pub_key: public_key_out })
25
+ params = {acc_pub_key: public_key_out, **tpki_base_params, **options}
26
+
27
+ http_post url, params
28
+ end
29
+
30
+ def account_get_list(private_key_out, options={})
31
+ url = URL_BASE + 'AccountGetList'
32
+ public_key_out = TencentTrustsql.encoded_public_key private_key_out
33
+ # params = tpki_base_params.merge!({ acc_pub_key: public_key_out })
34
+ params = {acc_pub_key: public_key_out, **tpki_base_params, **options}
35
+
36
+ http_post url, params
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,44 @@
1
+ Dir["#{File.dirname(__FILE__)}/api/*.rb"].each do |path|
2
+ require path
3
+ end
4
+ module TencentTrustsql
5
+ module Api
6
+
7
+ module AssetIssue
8
+ URL_BASE = "http://123.207.249.116:15910"
9
+
10
+ def asset_base_params
11
+ {
12
+ version: '2.0',
13
+ sign_type: 'ECDSA',
14
+ mch_id: mch_id,
15
+ timestamp: Time.now.to_i,
16
+ mch_pubkey: mch_public_key_out
17
+ }
18
+ end
19
+
20
+ end
21
+
22
+ module Iss
23
+ BASE_PARAMS = {}
24
+ end
25
+
26
+ module CgiBin
27
+ BASE_PARAMS = {}
28
+ end
29
+
30
+ module Tpki
31
+ URL_BASE = "https://baas.qq.com/tpki/tpki.TpkiSrv."
32
+
33
+ def tpki_base_params
34
+ {
35
+ version: '1.0',
36
+ sign_type: 'ECDSA',
37
+ mch_id: mch_id,
38
+ timestamp: Time.now.to_i
39
+ }
40
+ end
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,53 @@
1
+ module TencentTrustsql
2
+ class Client
3
+
4
+ include Api::AssetIssue
5
+ include Api::Tpki
6
+
7
+ attr_accessor :mch_private_key, :mch_id, :mch_public_key_out
8
+
9
+ def initialize
10
+ @mch_private_key = TencentTrustsql.mch_private_key_local
11
+ @mch_id = TencentTrustsql.mch_id
12
+ @mch_public_key_out = TencentTrustsql.encoded_public_key @mch_private_key
13
+ end
14
+
15
+
16
+ def sign_list_sign user_private_key, sign_list
17
+ signed_list = []
18
+ p "count ------ #{sign_list.count}"
19
+ sign_list.each do |obj|
20
+ signed_obj = {}
21
+ p "obj --------- #{obj}"
22
+ p obj.keys
23
+ [:account, :sign_str, :id].each do |key|
24
+ signed_obj["#{key.to_s}"] = obj[key] || obj[key.to_sym]
25
+ end
26
+ p signed_obj['sign_str']
27
+ p user_private_key
28
+ sign = TencentTrustsql.trans_sign user_private_key, signed_obj['sign_str']
29
+ p a = TencentTrustsql.output_formatter.out_sign(sign)
30
+ signed_obj['sign'] = a#TencentTrustsql.output_formatter.out_sign sign
31
+ signed_list.push signed_obj
32
+ end
33
+ p 'sign_list signed'
34
+ p signed_list
35
+ signed_list
36
+ end
37
+
38
+ def http_post url, params
39
+ # sign
40
+ query = TencentTrustsql.params_to_string(params).gsub(':', '').gsub('=>', ':').gsub(' ', '')
41
+ mch_sign = TencentTrustsql.output_formatter.out_sign(TencentTrustsql.sign(mch_private_key, query))
42
+
43
+ params.merge!(mch_sign: mch_sign)
44
+
45
+ p params
46
+ p url
47
+
48
+ response =HTTP.post(url, json: params)
49
+ JSON.parse(response.body) rescue nil
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,36 @@
1
+ module TencentTrustsql
2
+
3
+ class << self
4
+
5
+ attr_accessor :config
6
+
7
+ def configure
8
+ yield self.config ||= Config.new
9
+
10
+
11
+ # generate reader for config
12
+ # TencentTrustsql.config.mch_private_key == TencentTrustsql.mch_private_key
13
+ config.mch_private_key_local = input_formatter.localize_private_key(config.mch_private_key)
14
+ config.instance_variables.each do |var_sym|
15
+ p "define reader for #{var_sym}"
16
+ singleton_class.define_method var_sym.to_s.gsub(/^@/, '').to_sym do
17
+ config.instance_variable_get var_sym
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+
24
+ end
25
+
26
+ class Config
27
+ attr_accessor :mch_private_key, :mch_private_key_local, :mch_id
28
+ # config/initialize/tencent_trustsql.rb
29
+ # TencentTrustsql.configure do |config|
30
+ # config.mch_private_key = private_key from baas
31
+ # end
32
+ end
33
+
34
+
35
+
36
+ end
@@ -0,0 +1,22 @@
1
+ module TencentTrustsql
2
+ module IOFormatter
3
+ class Input
4
+
5
+ def localize_public_key hex_public_key
6
+ ECDSA::Format::PointOctetString.decode(Base64.decode64(hex_public_key). TencentTrustsql::CURVE)
7
+ end
8
+
9
+ def localize_private_key hex_private_key
10
+ return nil if !hex_private_key
11
+ Base64.decode64(hex_private_key).unpack('H*').first.hex
12
+ end
13
+
14
+ def localize_sign der_sign
15
+ der_signature = Base64.decode(der_sign)
16
+ # signature =
17
+ end
18
+
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ module TencentTrustsql
2
+ module IOFormatter
3
+ class Output
4
+
5
+ def out_public_key public_key
6
+ public_key_string = ECDSA::Format::PointOctetString.encode(public_key, compression: true)
7
+ Base64.encode64(public_key_string).gsub(/[\n]/, '')
8
+ end
9
+
10
+ def out_private_key private_key
11
+ hex = private_key.to_s(16)
12
+ hex_string = [].push(hex).pack('H*')
13
+ Base64.encode64(hex_string).gsub(/[\n]/, '')
14
+ end
15
+
16
+ def out_sign signature
17
+ signature_der_string = ECDSA::Format::SignatureDerString.encode(signature)
18
+ Base64.encode64(signature_der_string).gsub(/[\n]/, '')
19
+ end
20
+
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ baas 使用 base(hexstring(data))格式数据
2
+ ecdca gem 使用 data 格式数据
3
+ 这里提供转换逻辑
4
+ 对于module TencentTrustsql 封装了2个实例变量 input_formatter output_formatter
5
+
6
+ hex: 'abcdefffffffff'
7
+ hex_string: '0xab/ox11/oxoo'
@@ -0,0 +1,25 @@
1
+ require 'tencent_trustsql/i_o_formatter/input'
2
+ require 'tencent_trustsql/i_o_formatter/output'
3
+
4
+ module TencentTrustsql
5
+ module IOFormatter
6
+ class << self
7
+ attr_reader :input_formatter, :output_formatter
8
+
9
+ def included base
10
+ # 初始化转换器
11
+ instance_variable_set '@input_formatter', instance_variable_get('@input_formatter') || Input.new
12
+ instance_variable_set '@output_formatter', instance_variable_get('@output_formatter') || Output.new
13
+
14
+
15
+ # mixing类转换器指向已初始化的转换器并提供读方法
16
+ base.instance_variable_set '@input_formatter', input_formatter
17
+ base.instance_variable_set '@output_formatter', output_formatter
18
+ base.singleton_class.class_eval do
19
+ attr_reader :input_formatter, :output_formatter
20
+ end
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ Dir["#{File.dirname(__FILE__)}/tools/*.rb"].each do |path|
2
+ require path
3
+ end
@@ -0,0 +1,47 @@
1
+ module TencentTrustsql
2
+ module Tools
3
+ module KeyGenerator
4
+
5
+ # include IOFormatter
6
+
7
+ def self.included base
8
+ base.class_eval do
9
+ extend ClassMethods
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+
15
+ # 新建用户私钥
16
+ def user_private_key
17
+ p private_key = 1 + SecureRandom.random_number(CURVE.order - 1)
18
+ output_formatter.out_private_key private_key
19
+ end
20
+
21
+ # 获取公钥
22
+ # @private_key base64 encoded hex string or integer
23
+ def public_key(p_key)
24
+ if p_key.respond_to? :length
25
+ p p_key = input_formatter.localize_private_key(p_key)
26
+ end
27
+
28
+ public_key = CURVE.generator.multiply_by_scalar(p_key)
29
+ # ECDSA::Format::PointOctetString.encode(public_key, compression: true)
30
+ end
31
+
32
+ # 获取公钥字符串
33
+ def encoded_public_key private_key
34
+ pub_key = public_key(private_key)
35
+ output_formatter.out_public_key pub_key
36
+ # public_key_string = ECDSA::Format::PointOctetString.encode(pub_pair, compression: true).force_encoding('utf-8')
37
+ # Base64.encode64(public_key_string).gsub(/[\n]/, '')
38
+ end
39
+
40
+
41
+
42
+
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1 @@
1
+ 工具类
@@ -0,0 +1,40 @@
1
+ require 'tencent_trustsql/algorithm/sha256'
2
+ module TencentTrustsql
3
+ module Tools
4
+ module SignGenerator
5
+
6
+ def self.included base
7
+ base.class_eval do
8
+ extend ClassMethods
9
+ end
10
+ end
11
+
12
+ module ClassMethods
13
+
14
+ def params_to_string items
15
+ query = items.sort.map do |k, v|
16
+ "#{k}=#{v}" if v.to_s != ''
17
+ end.compact.join('&')
18
+ p query
19
+ end
20
+
21
+ def sign private_key, data
22
+ private_key = private_key.to_i
23
+ # digest =TencentTrustsql::BaseAlgorithm.encode(data)
24
+ digest = Algorithm::Sha256.encode(data)
25
+ temp_key = 1 + SecureRandom.random_number(TencentTrustsql::CURVE.order - 1)
26
+ signature = ECDSA.sign(TencentTrustsql::CURVE, private_key, digest, temp_key)
27
+ end
28
+
29
+ def trans_sign private_key, data
30
+ private_key = private_key.to_i
31
+ digest = [].push(data).pack('H*')
32
+ temp_key = 1 + SecureRandom.random_number(TencentTrustsql::CURVE.order - 1)
33
+ signature = ECDSA.sign(TencentTrustsql::CURVE, private_key, digest, temp_key)
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module TencentTrustsql
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,26 @@
1
+
2
+ require 'ecdsa'
3
+ require 'securerandom'
4
+ require 'json'
5
+ require "http"
6
+ require 'tencent_trustsql/i_o_formatter'
7
+ require 'tencent_trustsql/tool'
8
+ require 'tencent_trustsql/base_algorithm'
9
+ require 'tencent_trustsql/ecdsa_algorithm'
10
+ require 'tencent_trustsql/config'
11
+ require 'tencent_trustsql/api'
12
+ require 'tencent_trustsql/client'
13
+
14
+ module TencentTrustsql
15
+
16
+ include Tools::KeyGenerator
17
+ include Tools::SignGenerator
18
+ include IOFormatter
19
+
20
+ CURVE = ECDSA::Group::Secp256k1
21
+ end
22
+
23
+
24
+ module TencentTrustsql
25
+ class Error < StandardError; end
26
+ end
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "tencent_trustsql/version"
5
+
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "tencent_trustsql"
9
+ spec.version = TencentTrustsql::VERSION
10
+ spec.authors = ["jack"]
11
+ spec.email = ["qinshenyong@socialdatamax.com"]
12
+
13
+ spec.summary = "Tencent trustsql support tencent Baas rest api request"
14
+ spec.description = "Tencent trustsql support tencent Baas rest api request"
15
+ spec.homepage = "https://trustsql.qq.com"
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["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/cs-cj/tencent_trustsql"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_dependency 'http', '~> 2.2'
39
+ spec.add_dependency 'ecdsa', '~> 1.2'
40
+
41
+ spec.add_development_dependency "bundler", "~> 2.0"
42
+ spec.add_development_dependency "rake", "~> 10.0"
43
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tencent_trustsql
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - jack
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ecdsa
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Tencent trustsql support tencent Baas rest api request
70
+ email:
71
+ - qinshenyong@socialdatamax.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - CODE_OF_CONDUCT.md
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - lib/tencent_trustsql.rb
85
+ - lib/tencent_trustsql/algorithm.rb
86
+ - lib/tencent_trustsql/algorithm/readme
87
+ - lib/tencent_trustsql/algorithm/sha256.rb
88
+ - lib/tencent_trustsql/api.rb
89
+ - lib/tencent_trustsql/api/asset_issue.rb
90
+ - lib/tencent_trustsql/api/readme
91
+ - lib/tencent_trustsql/api/tpki.rb
92
+ - lib/tencent_trustsql/client.rb
93
+ - lib/tencent_trustsql/config.rb
94
+ - lib/tencent_trustsql/i_o_formatter.rb
95
+ - lib/tencent_trustsql/i_o_formatter/input.rb
96
+ - lib/tencent_trustsql/i_o_formatter/output.rb
97
+ - lib/tencent_trustsql/i_o_formatter/readme
98
+ - lib/tencent_trustsql/tool.rb
99
+ - lib/tencent_trustsql/tools/key_generator.rb
100
+ - lib/tencent_trustsql/tools/readme
101
+ - lib/tencent_trustsql/tools/sign_generator.rb
102
+ - lib/tencent_trustsql/version.rb
103
+ - tencent_trustsql.gemspec
104
+ homepage: https://trustsql.qq.com
105
+ licenses: []
106
+ metadata:
107
+ allowed_push_host: https://rubygems.org
108
+ homepage_uri: https://trustsql.qq.com
109
+ source_code_uri: https://github.com/cs-cj/tencent_trustsql
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubygems_version: 3.0.3
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Tencent trustsql support tencent Baas rest api request
129
+ test_files: []