substrate_common.rb 0.1.6 → 0.1.7

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: 4bc5dff23465573f86fa0e27fc876e762ebe99f26ecaec2b3049b948060527aa
4
- data.tar.gz: 1cb977d2013ebf8f6752b4129113dabe72967518b3b0fe6978df93654ba84970
3
+ metadata.gz: 77e342b5c29c8b35a2c0ea6ffc912e9c9cc177a874b85d2c1321e14a8d618490
4
+ data.tar.gz: 9d3f0fa6f0625ddf97311ff2b851f42b570c2dad0c211d434088fd6fe5d12106
5
5
  SHA512:
6
- metadata.gz: c4c61d14e1612f1222a8f874145003823a22e8cb90461c1653852383dbfa0c23d1babc4bd7d6e86bf5f56056498370240741ecdb1add76a7e6f1b90d31a189eb
7
- data.tar.gz: 564bcd315d02d273764bb15c5728a09e4a0d8260a998e57fee3ec00c0ed7935ecd29a18bb5d35b65cfd5c751f8c401514fbc4cb67301258d44b0541631d0b0a5
6
+ metadata.gz: 58a5ed6f4778b6f788e3d6dde905e9ac457685946bb5ef323c7027c97ea68d96e13ab3a085855726c92de599676b7b619def26b40b45971ebe2e43cff96424c8
7
+ data.tar.gz: aa5042d6382aa94102215fbf97ccb494f580442b3423a4931faa66d2473bafc73a69c39e54ff9f6de3b810d8a39f65054e6dcaa14be81e5f6ecb09693d906074
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- substrate_common.rb (0.1.6)
4
+ substrate_common.rb (0.1.7)
5
5
  base58
6
6
  blake2b
7
7
  xxhash
@@ -45,7 +45,17 @@ class String
45
45
  end
46
46
 
47
47
  module Crypto
48
- def self.xxhash_128(data)
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)
49
59
  bytes = []
50
60
  2.times do |i|
51
61
  result = XXhash.xxh64 data, i
@@ -54,8 +64,23 @@ module Crypto
54
64
  bytes.bytes_to_hex[2..]
55
65
  end
56
66
 
57
- def self.black2_256(data)
58
- # data = hex.hex_to_bytes.bytes_to_utf8
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.black2_128(bytes)
73
+ data = bytes.bytes_to_utf8
74
+ Blake2b.hex data, Blake2b::Key.none, 16
75
+ end
76
+
77
+ def self.black2_256(bytes)
78
+ data = bytes.bytes_to_utf8
59
79
  Blake2b.hex data, Blake2b::Key.none, 32
60
80
  end
81
+
82
+ def self.blake2_128_concat(bytes)
83
+ data = bytes.bytes_to_utf8
84
+ black2_128(data) + bytes.bytes_to_hex[2..]
85
+ end
61
86
  end
@@ -1,3 +1,3 @@
1
1
  module SubstrateCommon
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
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.6
4
+ version: 0.1.7
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-17 00:00:00.000000000 Z
11
+ date: 2020-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blake2b