multihashes 0.1.3 → 0.2.0
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 +5 -5
- data/.travis.yml +4 -2
- data/CHANGELOG.md +35 -0
- data/README.md +55 -12
- data/lib/multihashes.rb +7 -12
- data/lib/multihashes/version.rb +1 -1
- data/multihashes.gemspec +4 -2
- metadata +28 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3919be2817c0d63b77acc535b0e12e0e6e3e81c1aa6ac36ca2cc2e7fd5242dd2
|
4
|
+
data.tar.gz: 548b5d4c5c8ec60a7434d82602c9688eba7e1964709148c84511256c95ae40fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a560cac30066514c6d30eec9c54fbe08e60059eeab76da68668aacb76b11d42ec18c5929f1c6920a9fc396ddf6eaecc6fda7ebf28317b64afb575c6e7e91aa46
|
7
|
+
data.tar.gz: 5a35dca566b7c3c840a0c56ee3ca050704eaec15915a9a86551b6174f865c8a5f3d5dd3cf46d1e9b6f07ac73c90f0a91525f79fc525f44f20f0c6bccf7760c1f
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.2.0
|
4
|
+
|
5
|
+
- Add `multicodecs` (ruby-multicodec) which adds _all_ the current multihash
|
6
|
+
codecs to this gem.
|
7
|
+
- Add a test to show the breaking changes
|
8
|
+
|
9
|
+
### Breaking changes:
|
10
|
+
|
11
|
+
The official codec table does not match the initial (`0.1.x`) multihash mapping.
|
12
|
+
|
13
|
+
`0x14` used to be named `sha3` and is now named `sha3-512`
|
14
|
+
`0x40` used to be named `blake2b` and is now not assigned
|
15
|
+
`0x41` used to be named `blake2s` and is now not assigned
|
16
|
+
|
17
|
+
`blake2b` consists of 64 output lengths that give different hashes
|
18
|
+
| name | code |
|
19
|
+
|-------------|--------|
|
20
|
+
| blake2b-8 | 0xb201 |
|
21
|
+
| blake2b-16 | 0xb202 |
|
22
|
+
| blake2b-24 | 0xb203 |
|
23
|
+
| ... | |
|
24
|
+
| blake2b-504 | 0xb23f |
|
25
|
+
| blake2b-512 | 0xb240 |
|
26
|
+
|
27
|
+
`blake2s` consists of 32 output lengths that give different hashes
|
28
|
+
| name | code |
|
29
|
+
|-------------|--------|
|
30
|
+
| blake2s-8 | 0xb241 |
|
31
|
+
| blake2s-16 | 0xb242 |
|
32
|
+
| blake2s-24 | 0xb243 |
|
33
|
+
| ... | |
|
34
|
+
| blake2s-248 | 0xb25f |
|
35
|
+
| blake2s-256 | 0xb260 |
|
data/README.md
CHANGED
@@ -44,18 +44,61 @@ out = Multihashes.decode multihash_binary_string
|
|
44
44
|
|
45
45
|
```
|
46
46
|
|
47
|
-
Hash function names (latest is [here](https://github.com/multiformats/
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
Hash function names (latest is [here](https://github.com/multiformats/multicodec/blob/master/table.csv), current `multicodec` is [here](https://github.com/SleeplessByte/ruby-multicodec/blob/master/lib/table.csv))
|
48
|
+
|
49
|
+
| code | name | comment |
|
50
|
+
|--------|----------------|---------|
|
51
|
+
| 0x00 | identity | raw binary |
|
52
|
+
| 0x11 | sha1 | |
|
53
|
+
| 0x12 | sha2-256 | |
|
54
|
+
| 0x13 | sha2-512 | |
|
55
|
+
| 0x14 | sha3-512 | |
|
56
|
+
| 0x15 | sha3-384 | |
|
57
|
+
| 0x16 | sha3-256 | |
|
58
|
+
| 0x17 | sha3-224 | |
|
59
|
+
| 0x18 | shake-128 | |
|
60
|
+
| 0x19 | shake-256 | |
|
61
|
+
| 0x1a | keccak-224 | `keccak` has variable output length. The number specifies the core length |
|
62
|
+
| 0x1b | keccak-256 | |
|
63
|
+
| 0x1c | keccak-384 | |
|
64
|
+
| 0x1d | keccak-512 | |
|
65
|
+
| 0x22 | murmur3-128 | |
|
66
|
+
| 0x23 | murmur3-32 | |
|
67
|
+
| 0x56 | dbl-sha2-256 | |
|
68
|
+
| 0xd4 | md4 | |
|
69
|
+
| 0xd4 | md5 | |
|
70
|
+
| 0xd6 | bmt | Binary Merkle Tree Hash |
|
71
|
+
| 0x1100 | x11 | |
|
72
|
+
| 0xb201 | blake2b-8 | `blake2b` consists of 64 output lengths that give different hashes |
|
73
|
+
| 0xb202 | blake2b-16 | |
|
74
|
+
| 0xb203 | blake2b-24 | |
|
75
|
+
| ... | | |
|
76
|
+
| 0xb23f | blake2b-504 | |
|
77
|
+
| 0xb240 | blake2b-512 | |
|
78
|
+
| 0xb241 | blake2s-8 | `blake2s` consists of 32 output lengths that give different hashes |
|
79
|
+
| 0xb242 | blake2s-16 | |
|
80
|
+
| 0xb243 | blake2s-24 | |
|
81
|
+
| ... | | |
|
82
|
+
| 0xb25f | blake2s-248 | |
|
83
|
+
| 0xb260 | blake2s-256 | |
|
84
|
+
| 0xb301 | skein256-8 | `skein256` consists of 32 output lengths that give different hashes |
|
85
|
+
| 0xb302 | skein256-16 | |
|
86
|
+
| 0xb303 | skein256-24 | |
|
87
|
+
| ... | | |
|
88
|
+
| 0xb31f | skein256-248 | |
|
89
|
+
| 0xb320 | skein256-256 | |
|
90
|
+
| 0xb321 | skein512-8 | `skein256` consists of 32 output lengths that give different hashes |
|
91
|
+
| 0xb322 | skein512-16 | |
|
92
|
+
| 0xb323 | skein512-24 | |
|
93
|
+
| ... | | |
|
94
|
+
| 0xb35f | skein512-504 | |
|
95
|
+
| 0xb360 | skein512-512 | |
|
96
|
+
| 0xb361 | skein1024-8 | `skein1024` consists of 128 output lengths that give different hashes |
|
97
|
+
| 0xb362 | skein1024-16 | |
|
98
|
+
| 0xb363 | skein1024-24 | |
|
99
|
+
| ... | | |
|
100
|
+
| 0xb3df | skein1024-1016 | |
|
101
|
+
| 0xb3e0 | skein1024-1024 | |
|
59
102
|
|
60
103
|
## Development
|
61
104
|
|
data/lib/multihashes.rb
CHANGED
@@ -1,29 +1,24 @@
|
|
1
1
|
require 'multihashes/version'
|
2
|
+
require 'multicodecs'
|
2
3
|
|
3
4
|
module Multihashes
|
4
5
|
class HashFunctionNotImplemented < StandardError; end
|
5
6
|
class DigestLengthError < StandardError; end
|
6
7
|
|
7
|
-
# https://github.com/
|
8
|
-
TABLE =
|
9
|
-
|
10
|
-
|
11
|
-
0x12 => 'sha2-256',
|
12
|
-
0x13 => 'sha2-512',
|
13
|
-
0x14 => 'sha3',
|
14
|
-
0x40 => 'blake2b',
|
15
|
-
0x41 => 'blake2s'
|
16
|
-
}
|
8
|
+
# https://github.com/multiformats/multicodec/blob/master/table.csv
|
9
|
+
TABLE = Multicodecs.where(tag: 'multihash')
|
10
|
+
.map { |codec| [codec.code, codec.name] }
|
11
|
+
.to_h
|
17
12
|
|
18
13
|
def self.encode(digest, hash_function)
|
19
14
|
length = digest.bytesize
|
20
15
|
key = TABLE.key hash_function
|
21
16
|
raise HashFunctionNotImplemented, 'unknown hash function code' if key.nil?
|
22
|
-
[TABLE.key(hash_function), length, digest].pack("
|
17
|
+
[TABLE.key(hash_function), length, digest].pack("CCa#{length}")
|
23
18
|
end
|
24
19
|
|
25
20
|
def self.decode(multihash)
|
26
|
-
integer, length, digest = multihash.unpack('
|
21
|
+
integer, length, digest = multihash.unpack('CCa*')
|
27
22
|
|
28
23
|
if length != digest.bytesize
|
29
24
|
raise DigestLengthError, 'digest did not match expected multihash length'
|
data/lib/multihashes/version.rb
CHANGED
data/multihashes.gemspec
CHANGED
@@ -19,7 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler", "~>
|
23
|
-
spec.add_development_dependency "rake", "~>
|
22
|
+
spec.add_development_dependency "bundler", "~> 2"
|
23
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
24
24
|
spec.add_development_dependency "minitest"
|
25
|
+
|
26
|
+
spec.add_dependency "multicodecs", ">= 0.2.0", "< 1"
|
25
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multihashes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Drake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,26 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: multicodecs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.2.0
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '1'
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.2.0
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1'
|
55
75
|
description: A simple, low-level multihash (https://github.com/jbenet/multihash) implementation
|
56
76
|
for ruby.
|
57
77
|
email:
|
@@ -62,6 +82,7 @@ extra_rdoc_files: []
|
|
62
82
|
files:
|
63
83
|
- ".gitignore"
|
64
84
|
- ".travis.yml"
|
85
|
+
- CHANGELOG.md
|
65
86
|
- Gemfile
|
66
87
|
- LICENSE.txt
|
67
88
|
- README.md
|
@@ -90,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
111
|
- !ruby/object:Gem::Version
|
91
112
|
version: '0'
|
92
113
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.6.11
|
114
|
+
rubygems_version: 3.0.3
|
95
115
|
signing_key:
|
96
116
|
specification_version: 4
|
97
117
|
summary: A simple multihash (https://github.com/jbenet/multihash) implementation for
|