substrate_common.rb 0.1.4 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b498c9f38624f9dec4a75c5be6dcf7300d4eac30f4e102b0b3c5e7df8ce6c179
4
- data.tar.gz: ce75f39461e45e2326b251052abe3cb8446a0e5259d75c1e90699920e0cb48a4
3
+ metadata.gz: c2c77000375fd10703962cc0e070f32a35e71514fda4fc421eaac4099fcc6ad1
4
+ data.tar.gz: 839fff0d1889ab5f66975222f69fc58fc539213ba9c08fd19b40ff4a74aee295
5
5
  SHA512:
6
- metadata.gz: 8da3cff9f56dd5e806fb7fb28ee97a299db47c6033ad9165857c9a8dbf881b1b0d475aac3bdbd37599c0c76fa84d5563394f6ead1d66319f7579e50d8827fba3
7
- data.tar.gz: a3f072e090d242a1216a7b9f34f8613b5cde6f597ddf3f367c6bfdece33be20e68da8dc9d1710a4a7edbed3df4146b2856dc35d434e6f25b642656e458f9e1c3
6
+ metadata.gz: f4616a5678a531430a120489770173f69f94f050e7cc7a2d877d8a64e297c7d5717d046ebcd16a8d827ed0f3a7c40abee77f8b2dd75f84ade1807dbe344c2aa3
7
+ data.tar.gz: 49615b88fa20020011e91e8a504e85d8d52cf0695b11a12a877fd65662881a54e0dd8cdacfacabf4a14aee950ae4caef8d4aa8a91a98a4866dbd6e12cbe7445e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- substrate_common.rb (0.1.4)
4
+ substrate_common.rb (0.1.9)
5
5
  base58
6
6
  blake2b
7
7
  xxhash
@@ -44,11 +44,42 @@ class String
44
44
  end
45
45
  end
46
46
 
47
- def xxhash128(data)
48
- bytes = []
49
- 2.times do |i|
50
- result = XXhash.xxh64 data, i
51
- bytes = bytes + result.to_s(16).rjust(16, '0').hex_to_bytes.reverse
47
+ module Crypto
48
+ def self.identity(data)
49
+ data
50
+ end
51
+
52
+ def self.twox64(data)
53
+ result = XXhash.xxh64 data, 0
54
+ bytes = result.to_s(16).rjust(16, '0').hex_to_bytes.reverse
55
+ bytes.bytes_to_hex[2..]
56
+ end
57
+
58
+ def self.twox128(data)
59
+ bytes = []
60
+ 2.times do |i|
61
+ result = XXhash.xxh64 data, i
62
+ bytes = bytes + result.to_s(16).rjust(16, '0').hex_to_bytes.reverse
63
+ end
64
+ bytes.bytes_to_hex[2..]
65
+ end
66
+
67
+ def self.twox64_concat(bytes)
68
+ data = bytes.bytes_to_utf8
69
+ twox64(data) + bytes.bytes_to_hex[2..]
70
+ end
71
+
72
+ def self.blake2_128(bytes)
73
+ data = bytes.bytes_to_utf8
74
+ Blake2b.hex data, Blake2b::Key.none, 16
75
+ end
76
+
77
+ def self.blake2_256(bytes)
78
+ data = bytes.bytes_to_utf8
79
+ Blake2b.hex data, Blake2b::Key.none, 32
80
+ end
81
+
82
+ def self.blake2_128_concat(bytes)
83
+ blake2_128(bytes) + bytes.bytes_to_hex[2..]
52
84
  end
53
- bytes.bytes_to_hex
54
85
  end
@@ -1,3 +1,3 @@
1
1
  module SubstrateCommon
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: substrate_common.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wu Minzhe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2020-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blake2b