ethlite 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a91770dc04d591bf88353b4783080812f1659a7f679f09636b656a1a8d9ac7b7
4
- data.tar.gz: 626dda3168008abf7743526be783722292af40633c4acbe1bea4ea649f77a602
3
+ metadata.gz: 1e11a16356a6595d0a8463c9b8709f71f03edd0c0b2c66dac3d228f4b19511fe
4
+ data.tar.gz: 2811b02e7c428864876dc3bb416080c9348d5ef120ea1f067717690f531df48c
5
5
  SHA512:
6
- metadata.gz: 31b7dce9e0b71c4ea56697272d731541ecd58fdbfac6d5a3ddc949f7d47263340fda578d37403f788ecc02b7b08152d75107fd856f4af54b256c1cbb52b55ab2
7
- data.tar.gz: 852410528fc380e40cff8fd4eafd49a2697947d2b2a4ab73b6210c88c87c45ecfdd2c44c296dd473cb7a5e5c7d175625d774e3fb6f88a45da7f3356af2b21ea6
6
+ metadata.gz: 71875ac074cc206b14fe695b96c8c32fe83ee68f162f26985fd800e2a04d1dc9637c68b2a4826bbadf831f529733d133642b2c4be7e462ccc36f524959329f55
7
+ data.tar.gz: b4111981e3ab713d120ddeb3d88e186d00e3489e13d875411e43b05b2f92c750948010df33ef86424c2f2c6f76b197a08db3c4ab42eff156ff114a9200037c89
data/Manifest.txt CHANGED
@@ -2,8 +2,6 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- lib/digest/keccak.rb
6
- lib/digest/sha3.rb
7
5
  lib/ethlite.rb
8
6
  lib/ethlite/abi/codec.rb
9
7
  lib/ethlite/abi/type.rb
data/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
  ethlite - light-weight machinery to query / call ethereum (blockchain contract) services via json-rpc (incl. tuple support)
5
5
 
6
6
 
7
- * home :: [github.com/pixelartexchange/artbase](https://github.com/pixelartexchange/artbase)
8
- * bugs :: [github.com/pixelartexchange/artbase/issues](https://github.com/pixelartexchange/artbase/issues)
7
+ * home :: [github.com/rubycocos/blockchain](https://github.com/rubycocos/blockchain)
8
+ * bugs :: [github.com/rubycocos/blockchain/issues](https://github.com/rubycocos/blockchain/issues)
9
9
  * gem :: [rubygems.org/gems/ethlite](https://rubygems.org/gems/ethlite)
10
10
  * rdoc :: [rubydoc.info/gems/ethlite](http://rubydoc.info/gems/ethlite)
11
11
 
@@ -16,10 +16,10 @@ ethlite - light-weight machinery to query / call ethereum (blockchain contract)
16
16
 
17
17
  ### Step 0: Setup JSON RPC Client
18
18
 
19
+ Let's use the simple (built-in) JSON RPC client.
20
+ Get the eth node uri via the INFURA_URI enviroment variable / key e.g. `https://mainnet.infura.io/v3/<YOUR_KEY_HERE>`:
21
+
19
22
  ```ruby
20
- ## let's use a simple JSON RPC client
21
- ## get the eth node uri via the INFURA_URI enviroment variable / key
22
- ## e.g. https://mainnet.infura.io/v3/<YOUR_KEY_HERE>
23
23
  ETH_NODE = JsonRpc.new( ENV['INFURA_URI'] )
24
24
  ```
25
25
 
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ Hoe.spec 'ethlite' do
9
9
  self.summary = "ethlite - light-weight machinery to query / call ethereum (blockchain contract) services via json-rpc (incl. tuple support)"
10
10
  self.description = summary
11
11
 
12
- self.urls = { home: 'https://github.com/pixelartexchange/artbase' }
12
+ self.urls = { home: 'https://github.com/rubycocos/blockchain' }
13
13
 
14
14
  self.author = 'Gerald Bauer'
15
15
  self.email = 'wwwmake@googlegroups.com'
@@ -20,8 +20,8 @@ Hoe.spec 'ethlite' do
20
20
 
21
21
  self.extra_deps = [
22
22
  ['cocos'],
23
- ## ['keccak'], -- try using bundled ruby version for now
24
23
  ['rlp-lite'],
24
+ ['digest-lite'],
25
25
  ]
26
26
 
27
27
  self.licenses = ['Public Domain']
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Ethlite
4
4
  MAJOR = 0
5
- MINOR = 3
6
- PATCH = 1
5
+ MINOR = 4
6
+ PATCH = 0
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
data/lib/ethlite.rb CHANGED
@@ -11,15 +11,12 @@ require 'digest'
11
11
 
12
12
  ## 3rd party gems
13
13
  require 'rlp-lite'
14
+ require 'digest-lite'
14
15
 
15
- ## bundled require 'digest/keccak' ## gem keccak - see https://rubygems.org/gems/keccak
16
- require_relative 'digest/keccak'
17
- require_relative 'digest/sha3'
18
16
 
19
17
  require_relative 'jsonrpc/jsonrpc'
20
18
 
21
19
 
22
-
23
20
  ## our own code
24
21
  require_relative 'ethlite/version' # note: let version always go first
25
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-22 00:00:00.000000000 Z
11
+ date: 2022-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: digest-lite
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rdoc
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,8 +100,6 @@ files:
86
100
  - Manifest.txt
87
101
  - README.md
88
102
  - Rakefile
89
- - lib/digest/keccak.rb
90
- - lib/digest/sha3.rb
91
103
  - lib/ethlite.rb
92
104
  - lib/ethlite/abi/codec.rb
93
105
  - lib/ethlite/abi/type.rb
@@ -96,7 +108,7 @@ files:
96
108
  - lib/ethlite/utils.rb
97
109
  - lib/ethlite/version.rb
98
110
  - lib/jsonrpc/jsonrpc.rb
99
- homepage: https://github.com/pixelartexchange/artbase
111
+ homepage: https://github.com/rubycocos/blockchain
100
112
  licenses:
101
113
  - Public Domain
102
114
  metadata: {}
data/lib/digest/keccak.rb DELETED
@@ -1,125 +0,0 @@
1
- ###
2
- # use a "vendor" bundled keccak 256 in all ruby (no c-extensions required)
3
- #
4
- # see https://github.com/evtaylor/keccak256
5
-
6
-
7
-
8
- ## require 'digest'
9
-
10
-
11
-
12
- ##
13
- # note: use KeccakLite (or KeccakZero? KeccakSHA3?) instead of Keccak
14
- # to allow usage of native w/ c-extension Keccak and "lite" version
15
-
16
-
17
-
18
- module Digest
19
- class KeccakLite < Digest::Class
20
- PILN = [10, 7, 11, 17, 18, 3, 5, 16,
21
- 8, 21, 24, 4, 15, 23, 19, 13,
22
- 12, 2, 20, 14, 22, 9, 6, 1]
23
-
24
- ROTC = [ 1, 3, 6, 10, 15, 21, 28, 36,
25
- 45, 55, 2, 14, 27, 41, 56, 8,
26
- 25, 43, 62, 18, 39, 61, 20, 44]
27
-
28
- RNDC = [0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
29
- 0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
30
- 0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
31
- 0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
32
- 0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
33
- 0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
34
- 0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
35
- 0x8000000000008080, 0x0000000080000001, 0x8000000080008008]
36
-
37
- ## note: changed initialize to use param hash_size = 512
38
- ## do NOT hard-code only 256 bit
39
- def initialize( hash_size = 512 )
40
- @size = hash_size / 8
41
- @buffer = ''
42
- end
43
-
44
- def <<( s )
45
- @buffer << s
46
- self
47
- end
48
- alias_method :update, :<<
49
-
50
- def reset
51
- @buffer.clear
52
- self
53
- end
54
-
55
- def finish
56
- s = Array.new( 25, 0 )
57
- width = 200 - @size * 2
58
-
59
- ### note: padding changed in final FIPS PUB 202 standard
60
- ## from "\x01" to "\x06"
61
- padding = "\x01"
62
-
63
- buffer = @buffer
64
- buffer << padding << "\0" * (width - buffer.size % width)
65
- buffer[-1] = (buffer[-1].ord | 0x80).chr
66
-
67
- 0.step( buffer.size - 1, width ) do |j|
68
- quads = buffer[j, width].unpack( 'Q*' )
69
- (width / 8).times do |i|
70
- s[i] ^= quads[i]
71
- end
72
-
73
- _keccak( s )
74
- end
75
-
76
- s.pack('Q*')[0, @size]
77
- end
78
-
79
- private
80
- def _keccak( s )
81
- 24.times.each_with_object( [] ) do |round, a|
82
- # Theta
83
- 5.times do |i|
84
- a[i] = s[i] ^ s[i + 5] ^ s[i + 10] ^ s[i + 15] ^ s[i + 20]
85
- end
86
-
87
- 5.times do |i|
88
- t = a[(i + 4) % 5] ^ _rotate(a[(i + 1) % 5], 1)
89
- 0.step( 24, 5 ) do |j|
90
- s[j + i] ^= t
91
- end
92
- end
93
-
94
- # Rho Pi
95
- t = s[1]
96
- 24.times do |i|
97
- j = PILN[i]
98
- a[0] = s[j]
99
- s[j] = _rotate( t, ROTC[i] )
100
- t = a[0]
101
- end
102
-
103
- # Chi
104
- 0.step( 24, 5 ) do |j|
105
- 5.times do |i|
106
- a[i] = s[j + i]
107
- end
108
-
109
- 5.times do |i|
110
- s[j + i] ^= ~a[(i + 1) % 5] & a[(i + 2) % 5]
111
- end
112
- end
113
-
114
- # Iota
115
- s[0] ^= RNDC[round]
116
- end
117
- end
118
-
119
- def _rotate( x, y )
120
- (x << y | x >> 64 - y) & (1 << 64) - 1
121
- end
122
-
123
-
124
- end # class KeccakLite
125
- end # module Digest
data/lib/digest/sha3.rb DELETED
@@ -1,118 +0,0 @@
1
- ###
2
- # use a "vendor" bundled sha3 in all ruby (no c-extensions required)
3
- #
4
- # see https://github.com/havenwood/sha3-pure-ruby/blob/master/lib/sha3-pure-ruby.rb
5
-
6
-
7
- ## require 'digest'
8
-
9
- ##
10
- # note: use SHA3Lite (or SHA3Zero? ZeroSHA3?) instead of SHA3
11
- # to allow usage of native w/ c-extension SHA3 and "lite" version
12
-
13
-
14
- module Digest
15
- class SHA3Lite < Digest::Class
16
- PILN = [10, 7, 11, 17, 18, 3, 5, 16,
17
- 8, 21, 24, 4, 15, 23, 19, 13,
18
- 12, 2, 20, 14, 22, 9, 6, 1]
19
-
20
- ROTC = [ 1, 3, 6, 10, 15, 21, 28, 36,
21
- 45, 55, 2, 14, 27, 41, 56, 8,
22
- 25, 43, 62, 18, 39, 61, 20, 44]
23
-
24
- RNDC = [0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
25
- 0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
26
- 0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
27
- 0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
28
- 0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
29
- 0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
30
- 0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
31
- 0x8000000000008080, 0x0000000080000001, 0x8000000080008008]
32
-
33
- def initialize( hash_size = 512 )
34
- @size = hash_size / 8
35
- @buffer = '' ## todo/check: make sure buffer is with encoding BINARY - why? why not?
36
- end
37
-
38
- def <<( s )
39
- @buffer << s
40
- self
41
- end
42
- alias_method :update, :<<
43
-
44
- def reset
45
- @buffer.clear
46
- self
47
- end
48
-
49
- def finish
50
- s = Array.new( 25, 0 )
51
- width = 200 - @size * 2
52
-
53
- ### note: padding changed in final FIPS PUB 202 standard
54
- ## from "\x01" to "\x06"
55
- padding = "\x06"
56
-
57
- buffer = @buffer
58
- buffer << padding << "\0" * (width - buffer.size % width)
59
- buffer[-1] = (buffer[-1].ord | 0x80).chr
60
-
61
- 0.step( buffer.size - 1, width ) do |j|
62
- quads = buffer[j, width].unpack( 'Q*' )
63
- (width / 8).times do |i|
64
- s[i] ^= quads[i]
65
- end
66
-
67
- _keccak( s )
68
- end
69
-
70
- s.pack('Q*')[0, @size]
71
- end
72
-
73
- private
74
- def _keccak( s )
75
- 24.times.each_with_object( [] ) do |round, a|
76
- # Theta
77
- 5.times do |i|
78
- a[i] = s[i] ^ s[i + 5] ^ s[i + 10] ^ s[i + 15] ^ s[i + 20]
79
- end
80
-
81
- 5.times do |i|
82
- t = a[(i + 4) % 5] ^ _rotate(a[(i + 1) % 5], 1)
83
- 0.step( 24, 5 ) do |j|
84
- s[j + i] ^= t
85
- end
86
- end
87
-
88
- # Rho Pi
89
- t = s[1]
90
- 24.times do |i|
91
- j = PILN[i]
92
- a[0] = s[j]
93
- s[j] = _rotate( t, ROTC[i] )
94
- t = a[0]
95
- end
96
-
97
- # Chi
98
- 0.step( 24, 5 ) do |j|
99
- 5.times do |i|
100
- a[i] = s[j + i]
101
- end
102
-
103
- 5.times do |i|
104
- s[j + i] ^= ~a[(i + 1) % 5] & a[(i + 2) % 5]
105
- end
106
- end
107
-
108
- # Iota
109
- s[0] ^= RNDC[round]
110
- end
111
- end
112
-
113
- def _rotate( x, y )
114
- (x << y | x >> 64 - y) & (1 << 64) - 1
115
- end
116
-
117
- end # class SHA3Lite
118
- end # module Digest