blake3ruby 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b557aeaacfec5d4f45874dd7549de7a5ccf6b549738636e7288353451feaf9f7
4
- data.tar.gz: 685492fae6050a4c0742a6cd56d66b88e1b6a9f7698a739c77bee387193574fb
3
+ metadata.gz: 446ad17adfad2f4096491ae74ff7f4a986f7bf4e1534248408435862ae2b5037
4
+ data.tar.gz: 85878e5c2e3e09bfc4b0412c05f62a428cd40b7c0f31906293dfede7ce7408d4
5
5
  SHA512:
6
- metadata.gz: 31514a49570361b158dece950616e4c4b3f3ff24fdfb83e46585009366a2cbb732c12638b1bbd193309723a6899c4e37a610c52efc4b5f949082472a72537ae2
7
- data.tar.gz: 4815f135a982a0e747ffb020d44252c2162d2f6c19c27d8bd34af007959f3c686151afee98e810bb34ab60b31dc66e11c6085af08b9bcb0a78086b4d100c8ca4
6
+ metadata.gz: 96a54200ac5a1c584e73960130818c1428b698349053bf3f7c8ca5368fe54b29b824177d5d48cfa52177b9c0dd8ae7976ea78d5ff0e2f3d6e2f03c16e0f7f98d
7
+ data.tar.gz: 29a7a9a19dd9edc7083a57ac79a9f66b0b454f2414a5f26b7897bf4773615b68fe5d50d7cedd200b6eaa5bba987be5ab4f2d9d4067ab4c3c9cff0e51860c23a2
data/.rubocop.yml CHANGED
@@ -1,4 +1,9 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-rake
4
+
1
5
  AllCops:
6
+ NewCops: enable
2
7
  TargetRubyVersion: 3.0
3
8
 
4
9
  Style/StringLiterals:
data/Cargo.lock CHANGED
@@ -45,9 +45,9 @@ dependencies = [
45
45
 
46
46
  [[package]]
47
47
  name = "bitflags"
48
- version = "2.5.0"
48
+ version = "2.6.0"
49
49
  source = "registry+https://github.com/rust-lang/crates.io-index"
50
- checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
50
+ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
51
51
 
52
52
  [[package]]
53
53
  name = "blake3"
@@ -64,7 +64,7 @@ dependencies = [
64
64
 
65
65
  [[package]]
66
66
  name = "blake3ruby"
67
- version = "0.1.1"
67
+ version = "0.2.0"
68
68
  dependencies = [
69
69
  "blake3",
70
70
  "hex",
@@ -73,9 +73,9 @@ dependencies = [
73
73
 
74
74
  [[package]]
75
75
  name = "cc"
76
- version = "1.0.96"
76
+ version = "1.0.104"
77
77
  source = "registry+https://github.com/rust-lang/crates.io-index"
78
- checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd"
78
+ checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490"
79
79
 
80
80
  [[package]]
81
81
  name = "cexpr"
@@ -94,9 +94,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
94
94
 
95
95
  [[package]]
96
96
  name = "clang-sys"
97
- version = "1.7.0"
97
+ version = "1.8.1"
98
98
  source = "registry+https://github.com/rust-lang/crates.io-index"
99
- checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1"
99
+ checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
100
100
  dependencies = [
101
101
  "glob",
102
102
  "libc",
@@ -111,9 +111,9 @@ checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
111
111
 
112
112
  [[package]]
113
113
  name = "either"
114
- version = "1.11.0"
114
+ version = "1.13.0"
115
115
  source = "registry+https://github.com/rust-lang/crates.io-index"
116
- checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
116
+ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
117
117
 
118
118
  [[package]]
119
119
  name = "glob"
@@ -138,9 +138,9 @@ dependencies = [
138
138
 
139
139
  [[package]]
140
140
  name = "lazy_static"
141
- version = "1.4.0"
141
+ version = "1.5.0"
142
142
  source = "registry+https://github.com/rust-lang/crates.io-index"
143
- checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
143
+ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
144
144
 
145
145
  [[package]]
146
146
  name = "lazycell"
@@ -150,15 +150,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
150
150
 
151
151
  [[package]]
152
152
  name = "libc"
153
- version = "0.2.154"
153
+ version = "0.2.155"
154
154
  source = "registry+https://github.com/rust-lang/crates.io-index"
155
- checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
155
+ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
156
156
 
157
157
  [[package]]
158
158
  name = "libloading"
159
- version = "0.8.3"
159
+ version = "0.8.4"
160
160
  source = "registry+https://github.com/rust-lang/crates.io-index"
161
- checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
161
+ checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d"
162
162
  dependencies = [
163
163
  "cfg-if",
164
164
  "windows-targets",
@@ -166,9 +166,9 @@ dependencies = [
166
166
 
167
167
  [[package]]
168
168
  name = "magnus"
169
- version = "0.6.4"
169
+ version = "0.7.1"
170
170
  source = "registry+https://github.com/rust-lang/crates.io-index"
171
- checksum = "b1597ef40aa8c36be098249e82c9a20cf7199278ac1c1a1a995eeead6a184479"
171
+ checksum = "3d87ae53030f3a22e83879e666cb94e58a7bdf31706878a0ba48752994146dab"
172
172
  dependencies = [
173
173
  "magnus-macros",
174
174
  "rb-sys",
@@ -189,9 +189,9 @@ dependencies = [
189
189
 
190
190
  [[package]]
191
191
  name = "memchr"
192
- version = "2.7.2"
192
+ version = "2.7.4"
193
193
  source = "registry+https://github.com/rust-lang/crates.io-index"
194
- checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
194
+ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
195
195
 
196
196
  [[package]]
197
197
  name = "minimal-lexical"
@@ -211,9 +211,9 @@ dependencies = [
211
211
 
212
212
  [[package]]
213
213
  name = "proc-macro2"
214
- version = "1.0.81"
214
+ version = "1.0.86"
215
215
  source = "registry+https://github.com/rust-lang/crates.io-index"
216
- checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
216
+ checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
217
217
  dependencies = [
218
218
  "unicode-ident",
219
219
  ]
@@ -259,9 +259,9 @@ checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
259
259
 
260
260
  [[package]]
261
261
  name = "regex"
262
- version = "1.10.4"
262
+ version = "1.10.5"
263
263
  source = "registry+https://github.com/rust-lang/crates.io-index"
264
- checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
264
+ checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
265
265
  dependencies = [
266
266
  "aho-corasick",
267
267
  "memchr",
@@ -271,9 +271,9 @@ dependencies = [
271
271
 
272
272
  [[package]]
273
273
  name = "regex-automata"
274
- version = "0.4.6"
274
+ version = "0.4.7"
275
275
  source = "registry+https://github.com/rust-lang/crates.io-index"
276
- checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
276
+ checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
277
277
  dependencies = [
278
278
  "aho-corasick",
279
279
  "memchr",
@@ -282,9 +282,9 @@ dependencies = [
282
282
 
283
283
  [[package]]
284
284
  name = "regex-syntax"
285
- version = "0.8.3"
285
+ version = "0.8.4"
286
286
  source = "registry+https://github.com/rust-lang/crates.io-index"
287
- checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
287
+ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
288
288
 
289
289
  [[package]]
290
290
  name = "rustc-hash"
@@ -312,9 +312,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
312
312
 
313
313
  [[package]]
314
314
  name = "syn"
315
- version = "2.0.60"
315
+ version = "2.0.68"
316
316
  source = "registry+https://github.com/rust-lang/crates.io-index"
317
- checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
317
+ checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9"
318
318
  dependencies = [
319
319
  "proc-macro2",
320
320
  "quote",
data/Gemfile CHANGED
@@ -5,11 +5,16 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in blake3ruby.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rake-compiler"
11
8
  gem "rb_sys"
12
9
 
13
- gem "rspec", "~> 3.0"
10
+ group :development do
11
+ gem "rake", "~> 13.0"
12
+ gem "rake-compiler"
13
+ end
14
14
 
15
- gem "rubocop", "~> 1.21"
15
+ group :test do
16
+ gem "rspec", "~> 3.0"
17
+ gem "rubocop", "~> 1.21"
18
+ gem "rubocop-rake", require: false
19
+ gem "rubocop-rspec", require: false
20
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blake3ruby (0.1.1)
4
+ blake3ruby (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -49,12 +49,23 @@ GEM
49
49
  unicode-display_width (>= 2.4.0, < 3.0)
50
50
  rubocop-ast (1.31.3)
51
51
  parser (>= 3.3.1.0)
52
+ rubocop-rake (0.6.0)
53
+ rubocop (~> 1.0)
54
+ rubocop-rspec (3.0.1)
55
+ rubocop (~> 1.61)
52
56
  ruby-progressbar (1.13.0)
53
57
  strscan (3.1.0)
54
58
  unicode-display_width (2.5.0)
55
59
 
56
60
  PLATFORMS
57
- x86_64-darwin-21
61
+ aarch64-linux
62
+ aarch64-linux-musl
63
+ arm-linux
64
+ arm64-darwin
65
+ ruby
66
+ x86_64-darwin
67
+ x86_64-linux
68
+ x86_64-linux-musl
58
69
 
59
70
  DEPENDENCIES
60
71
  blake3ruby!
@@ -63,6 +74,8 @@ DEPENDENCIES
63
74
  rb_sys
64
75
  rspec (~> 3.0)
65
76
  rubocop (~> 1.21)
77
+ rubocop-rake
78
+ rubocop-rspec
66
79
 
67
80
  BUNDLED WITH
68
81
  2.5.13
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  This is a Ruby wrapper for the [BLAKE3](https://github.com/BLAKE3-team/BLAKE3) hash function written in Rust.
6
6
 
7
7
  ## Requirements
8
- Tested on Ruby 3.1 and 3.2.
8
+ Tested on Ruby 3.1, 3.2 and 3.3.
9
9
  You will need to have Rust installed on your system, and the `cargo` command available in your path.
10
10
  See [here](https://www.rust-lang.org/tools/install) for instructions on how to install Rust.
11
11
  Rust is only required to build the gem, not to use it.
@@ -36,7 +36,7 @@ Basic usage is similar to the `Digest` class in the Ruby standard library:
36
36
  ```ruby
37
37
  require 'blake3ruby'
38
38
 
39
- Blake3ruby.hexdigest("Hello, world!") # => "ede5c0b10f2ec4979c69b52f61e42ff5b413519ce09be0f14d098dcfe5f6f98d"
39
+ Digest::Blake3.hexdigest("Hello, world!") # => "ede5c0b10f2ec4979c69b52f61e42ff5b413519ce09be0f14d098dcfe5f6f98d"
40
40
  ```
41
41
 
42
42
  If you want to use the streaming interface, you can use the `Blake3ruby::Hasher` class:
@@ -44,8 +44,8 @@ If you want to use the streaming interface, you can use the `Blake3ruby::Hasher`
44
44
  ```ruby
45
45
  require 'blake3ruby'
46
46
 
47
- hasher = Blake3ruby::Hasher.new
48
- hasher.update("Hello, ") # => #<Blake3ruby::Hasher:0x00007f9b0a0b0e00> - returns self
47
+ hasher = Digest::Blake3::Hasher.new
48
+ hasher.update("Hello, ") # => #<Digest::Blake3::Hasher:0x00000001066f59a8> - returns self
49
49
  hasher.update("world!")
50
50
  hasher.finalize # => "ede5c0b10f2ec4979c69b52f61e42ff5b413519ce09be0f14d098dcfe5f6f98d"
51
51
  ```
@@ -60,9 +60,13 @@ The derive_key mode takes a context string and some key material (not a password
60
60
  ```ruby
61
61
  require 'blake3ruby'
62
62
 
63
- Blake3ruby.derive_key("context", "input_key_material") # => "3eaa9796d6d3db5cd5de00d44e4888fccbf4f8c878dd6ccd0c374bded6c26405"
63
+ Digest::Blake3.derive_key("context", "input_key_material") # => "3eaa9796d6d3db5cd5de00d44e4888fccbf4f8c878dd6ccd0c374bded6c26405"
64
64
  ```
65
65
 
66
+ ## Breaking Changes in Version 0.2.0
67
+
68
+ In versions 0.1.0 and 0.1.1, the Blake3ruby namespace was available. Starting from version 0.2.0, the Blake3 crypto digest has been moved to the Digest namespace where all standard Ruby digests are available. This change ensures consistency and better integration with the Ruby standard library.
69
+
66
70
  ## Performance
67
71
 
68
72
  The performance of this gem is comparable to the performance of the [blake3](https://github.com/BLAKE3-team/BLAKE3)
@@ -70,14 +74,53 @@ crate, which is written in Rust.
70
74
 
71
75
  The following benchmark was run on a 2015 MacBook Pro with a 2.5 GHz 4-Core Intel Core i7 processor and 16 GB of RAM.
72
76
  ```
73
- user system total real
74
- MD5: 6.376103 0.028610 6.404713 ( 6.492484)
75
- SHA1: 5.701825 0.014154 5.715979 ( 5.721241)
76
- SHA3-256: 6.081136 0.014625 6.095761 ( 6.102179)
77
- SHA3-384: 6.757476 0.013765 6.771241 ( 6.778101)
78
- SHA3-512: 6.890564 0.014625 6.905189 ( 6.909914)
79
- RMD160: 6.196825 0.031562 6.228387 ( 6.293669)
80
- blake3: 2.527779 0.006833 2.534612 ( 2.536978)
77
+ MD5 (13 chars): 6.141045 0.086745 6.227790 ( 6.263524)
78
+ SHA1 (13 chars): 6.230957 0.080145 6.311102 ( 6.333384)
79
+ SHA3-256 (13 chars): 6.364485 0.093261 6.457746 ( 6.491053)
80
+ SHA3-384 (13 chars): 7.068870 0.151501 7.220371 ( 7.246571)
81
+ SHA3-512 (13 chars): 7.265794 0.152058 7.417852 ( 7.443591)
82
+ RMD160 (13 chars): 5.547123 0.075290 5.622413 ( 5.642165)
83
+ blake3 (13 chars): 2.747356 0.014433 2.761789 ( 2.772582)
84
+
85
+ For message length 13 chars:
86
+ Fastest: blake3 with 2.7725820001214743 seconds
87
+ Slowest: SHA3-512 with 7.44359099981375 seconds
88
+ user system total real
89
+ MD5 (44 chars): 5.861548 0.074899 5.936447 ( 5.959032)
90
+ SHA1 (44 chars): 5.944156 0.072394 6.016550 ( 6.038251)
91
+ SHA3-256 (44 chars): 6.446754 0.096381 6.543135 ( 6.570512)
92
+ SHA3-384 (44 chars): 7.083944 0.156259 7.240203 ( 7.268630)
93
+ SHA3-512 (44 chars): 7.213243 0.154452 7.367695 ( 7.396536)
94
+ RMD160 (44 chars): 5.589189 0.075830 5.665019 ( 5.689458)
95
+ blake3 (44 chars): 2.754475 0.014872 2.769347 ( 2.780263)
96
+
97
+ For message length 44 chars:
98
+ Fastest: blake3 with 2.7802629999350756 seconds
99
+ Slowest: SHA3-512 with 7.396536000072956 seconds
100
+ user system total real
101
+ MD5 (199 chars): 8.079411 0.088239 8.167650 ( 8.201427)
102
+ SHA1 (199 chars): 7.792639 0.082953 7.875592 ( 7.904909)
103
+ SHA3-256 (199 chars): 9.508372 0.106791 9.615163 ( 9.648153)
104
+ SHA3-384 (199 chars): 8.291785 0.160924 8.452709 ( 8.483978)
105
+ SHA3-512 (199 chars): 8.396180 0.160054 8.556234 ( 8.590455)
106
+ RMD160 (199 chars): 8.910650 0.087215 8.997865 ( 9.028016)
107
+ blake3 (199 chars): 3.796439 0.018845 3.815284 ( 3.829479)
108
+
109
+ For message length 199 chars:
110
+ Fastest: blake3 with 3.8294790000654757 seconds
111
+ Slowest: SHA3-256 with 9.648153000045568 seconds
112
+ user system total real
113
+ MD5 (1024 chars): 15.504161 0.114951 15.619112 ( 15.671606)
114
+ SHA1 (1024 chars): 13.007605 0.105566 13.113171 ( 13.163242)
115
+ SHA3-256 (1024 chars): 20.968764 0.162367 21.131131 ( 21.212766)
116
+ SHA3-384 (1024 chars): 17.255475 0.300950 17.556425 ( 17.728562)
117
+ SHA3-512 (1024 chars): 17.697881 0.400774 18.098655 ( 18.404827)
118
+ RMD160 (1024 chars): 23.639904 0.458113 24.098017 ( 24.535302)
119
+ blake3 (1024 chars): 8.123303 0.178863 8.302166 ( 8.499843)
120
+
121
+ For message length 1024 chars:
122
+ Fastest: blake3 with 8.499842999968678 seconds
123
+ Slowest: RMD160 with 24.535302000120282 seconds
81
124
  ```
82
125
 
83
126
  Another benchmark was run on a 2022 MacBook Pro with a Apple M1 processor and 16 GB of RAM.
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ RuboCop::RakeTask.new
11
11
 
12
12
  require "rake/extensiontask"
13
13
 
14
+ desc "Compile the Rust source code for the Blake3ruby extension"
14
15
  task build: :compile
15
16
 
16
17
  Rake::ExtensionTask.new("blake3ruby") do |ext|
data/blake3ruby.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/Nightforge/blake3ruby"
20
+ spec.metadata["rubygems_mfa_required"] = "true"
20
21
 
21
22
  # Specify which files should be added to the gem when it is released.
22
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "blake3ruby"
3
- version = "0.1.1"
3
+ version = "0.2.0"
4
4
  edition = "2021"
5
5
  authors = ["Nightforge <modo00@gmail.com>"]
6
6
  publish = false
@@ -9,7 +9,7 @@ publish = false
9
9
  crate-type = ["cdylib"]
10
10
 
11
11
  [dependencies]
12
- magnus = { version = "0.6.4" }
12
+ magnus = { version = "0.7.1" }
13
13
  hex = { version = "0.4.3" }
14
14
  blake3 = { version = "1.5.1" }
15
15
 
@@ -1,8 +1,8 @@
1
- use magnus::{define_module, define_class, class, function, method, prelude::*, Error};
1
+ use magnus::{define_module, class, function, method, prelude::*, Error};
2
2
 
3
3
  fn hexdigest(subject: String) -> String {
4
4
  let hash = blake3::hash(subject.as_bytes());
5
- return hash.to_string()
5
+ return hash.to_string();
6
6
  }
7
7
 
8
8
  fn derive_key(context: String, key: String) -> String {
@@ -15,7 +15,7 @@ struct Hasher {
15
15
  hasher: blake3::Hasher,
16
16
  }
17
17
 
18
- #[magnus::wrap(class = "Hasher")]
18
+ #[magnus::wrap(class = "Digest::Blake3::Hasher")]
19
19
  struct MutHasher(std::cell::RefCell<Hasher>);
20
20
 
21
21
  impl MutHasher {
@@ -28,26 +28,27 @@ impl MutHasher {
28
28
 
29
29
  fn update(&self, subject: String) -> Self {
30
30
  self.0.borrow_mut().hasher.update(subject.as_bytes());
31
- return Self(self.0.clone())
31
+ return Self(self.0.clone());
32
32
  }
33
33
 
34
34
  fn finalize(&self) -> String {
35
35
  let hash = self.0.borrow().hasher.finalize();
36
- return hash.to_string()
36
+ return hash.to_string();
37
37
  }
38
38
  }
39
39
 
40
40
  #[magnus::init]
41
41
  fn init() -> Result<(), Error> {
42
- let blake3ruby = define_module("Blake3ruby")?;
43
- blake3ruby.define_singleton_method("hexdigest", function!(hexdigest, 1))?;
44
- blake3ruby.define_singleton_method("derive_key", function!(derive_key, 2))?;
42
+ let digest = define_module("Digest")?;
43
+ let blake3 = digest.define_module("Blake3")?;
44
+
45
+ blake3.define_singleton_method("hexdigest", function!(hexdigest, 1))?;
46
+ blake3.define_singleton_method("derive_key", function!(derive_key, 2))?;
45
47
 
46
- let class = define_class("Hasher", class::object())?;
48
+ let class = blake3.define_class("Hasher", class::object())?;
47
49
  class.define_singleton_method("new", function!(MutHasher::new, 0))?;
48
50
  class.define_method("update", method!(MutHasher::update, 1))?;
49
51
  class.define_method("finalize", method!(MutHasher::finalize, 0))?;
50
52
 
51
- blake3ruby.define_class("Hasher", class)?;
52
53
  Ok(())
53
54
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blake3ruby
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
data/sig/blake3ruby.rbs CHANGED
@@ -1,4 +1,16 @@
1
1
  module Blake3ruby
2
2
  VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
3
+ end
4
+
5
+ module Digest
6
+ module Blake3
7
+ def self.hexdigest(subject: String) -> String
8
+ def self.derive_key(context: String, key: String) -> String
9
+
10
+ class Hasher
11
+ def self.new: () -> Digest::Blake3::Hasher
12
+ def update: (subject: String) -> Digest::Blake3::Hasher
13
+ def finalize: () -> String
14
+ end
15
+ end
4
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blake3ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nightforge
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-30 00:00:00.000000000 Z
11
+ date: 2024-07-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby bindings for the blake3 hash function using the Rust implementation
14
14
  email:
@@ -42,6 +42,7 @@ licenses:
42
42
  metadata:
43
43
  homepage_uri: https://github.com/Nightforge/blake3ruby
44
44
  source_code_uri: https://github.com/Nightforge/blake3ruby
45
+ rubygems_mfa_required: 'true'
45
46
  post_install_message:
46
47
  rdoc_options: []
47
48
  require_paths: