base58_native 0.1.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.
@@ -0,0 +1,520 @@
1
+ //! Pure-Rust Base58 codec for values that fit in 128 bits.
2
+ //!
3
+ //! Nothing in here touches Ruby. Every function is total: it never panics,
4
+ //! never indexes out of bounds and never overflows. Any input the fast path
5
+ //! does not handle produces `None`, and the Ruby layer then hands the
6
+ //! original argument to the reference implementation (`Base58Native::Fallback`).
7
+ //!
8
+ //! Alphabet and digit ordering match code-3's `lib/base58.rb` exactly: a plain
9
+ //! positional base-58 number, most significant digit first, with no special
10
+ //! treatment of leading zero bytes (zero encodes as a single "1").
11
+
12
+ pub const ALPHABET: &[u8; 58] = b"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
13
+
14
+ const INVALID: u8 = 0xFF;
15
+
16
+ /// 58^5 (< 2^30): five base-58 digits fit in a u32.
17
+ const P5: u32 = 656_356_768;
18
+ /// 58^10 (< 2^59).
19
+ const P10: u64 = (P5 as u64) * (P5 as u64);
20
+ const P10_U128: u128 = P10 as u128;
21
+ /// 58^10 = 2^10 * 29^10, so `x / 58^10 == (x >> 10) / 29^10` (nested floor
22
+ /// division). This turns the second 128-bit division into a 64-bit one.
23
+ const P10_ODD: u64 = P10 >> 10;
24
+
25
+ /// Longest base-58 encoding of a u128 (58^21 < 2^128 < 58^22).
26
+ pub const MAX_B58_LEN: usize = 22;
27
+
28
+ // Table builders run at compile time (const eval): an out-of-bounds index
29
+ // would be a build error, never a runtime panic.
30
+ #[allow(clippy::indexing_slicing)]
31
+ const fn build_b58_map() -> [u8; 256] {
32
+ let mut map = [INVALID; 256];
33
+ let mut i = 0;
34
+ while i < 58 {
35
+ map[ALPHABET[i] as usize] = i as u8;
36
+ i += 1;
37
+ }
38
+ map
39
+ }
40
+
41
+ #[allow(clippy::indexing_slicing)]
42
+ const fn build_hex_map() -> [u8; 256] {
43
+ let mut map = [INVALID; 256];
44
+ let mut i = 0u8;
45
+ while i < 10 {
46
+ map[(b'0' + i) as usize] = i;
47
+ i += 1;
48
+ }
49
+ let mut i = 0u8;
50
+ while i < 6 {
51
+ map[(b'a' + i) as usize] = 10 + i;
52
+ map[(b'A' + i) as usize] = 10 + i;
53
+ i += 1;
54
+ }
55
+ map
56
+ }
57
+
58
+ #[allow(clippy::indexing_slicing)]
59
+ const fn build_hex_pairs() -> [[u8; 2]; 256] {
60
+ const HEX: &[u8; 16] = b"0123456789abcdef";
61
+ let mut t = [[0u8; 2]; 256];
62
+ let mut i = 0;
63
+ while i < 256 {
64
+ t[i] = [HEX[i >> 4], HEX[i & 0xF]];
65
+ i += 1;
66
+ }
67
+ t
68
+ }
69
+
70
+ /// Two base-58 digits for every value < 58^2.
71
+ #[allow(clippy::indexing_slicing)]
72
+ const fn build_b58_pairs() -> [[u8; 2]; 3364] {
73
+ let mut t = [[0u8; 2]; 3364];
74
+ let mut i = 0;
75
+ while i < 3364 {
76
+ t[i] = [ALPHABET[i / 58], ALPHABET[i % 58]];
77
+ i += 1;
78
+ }
79
+ t
80
+ }
81
+
82
+ /// POW58[k] = 58^k for k in 0..=21 (58^22 does not fit in a u128).
83
+ #[allow(clippy::indexing_slicing)]
84
+ const fn build_pow58() -> [u128; 22] {
85
+ let mut t = [1u128; 22];
86
+ let mut i = 1;
87
+ while i < 22 {
88
+ t[i] = t[i - 1] * 58;
89
+ i += 1;
90
+ }
91
+ t
92
+ }
93
+
94
+ /// For a value with `b` significant bits (b in 0..=128), the number of base-58
95
+ /// digits is either DIGITS_LO[b] or DIGITS_LO[b] + 1.
96
+ #[allow(clippy::indexing_slicing)]
97
+ const fn build_digits_lo() -> [u8; 129] {
98
+ let pow = build_pow58();
99
+ let mut t = [1u8; 129];
100
+ let mut b = 1;
101
+ while b <= 128 {
102
+ // smallest value with b bits is 2^(b-1); count its digits
103
+ let min: u128 = 1u128 << (b - 1);
104
+ let mut d = 1;
105
+ while d < 22 && pow[d] <= min {
106
+ d += 1;
107
+ }
108
+ t[b] = d as u8;
109
+ b += 1;
110
+ }
111
+ t
112
+ }
113
+
114
+ static B58_PAIRS: [[u8; 2]; 3364] = build_b58_pairs();
115
+ static POW58: [u128; 22] = build_pow58();
116
+ static DIGITS_LO: [u8; 129] = build_digits_lo();
117
+ static B58_MAP: [u8; 256] = build_b58_map();
118
+ static HEX_MAP: [u8; 256] = build_hex_map();
119
+ static HEX_PAIRS: [[u8; 2]; 256] = build_hex_pairs();
120
+
121
+ // A u8 always indexes a 256-entry table; `get` keeps these panic-free by
122
+ // construction and compiles to a plain load.
123
+ #[inline(always)]
124
+ fn b58_value(b: u8) -> u8 {
125
+ B58_MAP.get(usize::from(b)).copied().unwrap_or(INVALID)
126
+ }
127
+
128
+ #[inline(always)]
129
+ fn hex_value(b: u8) -> u8 {
130
+ HEX_MAP.get(usize::from(b)).copied().unwrap_or(INVALID)
131
+ }
132
+
133
+ #[inline(always)]
134
+ fn hex_pair(b: u8) -> [u8; 2] {
135
+ HEX_PAIRS.get(usize::from(b)).copied().unwrap_or(*b"00")
136
+ }
137
+
138
+ #[inline(always)]
139
+ fn b58_char(d: u32) -> u8 {
140
+ // d < 58 at every call site (the top digit of a value < 58^5).
141
+ ALPHABET.get(d as usize).copied().unwrap_or(b'1')
142
+ }
143
+
144
+ /// Accumulate a run of hex digits onto `acc`, OR-ing table values into `bad`
145
+ /// (valid digits are 0..=15, so any high bit in `bad` means an invalid byte).
146
+ #[inline(always)]
147
+ fn hex_run(group: &[u8], acc: u64, bad: &mut u8) -> u64 {
148
+ let mut v = acc;
149
+ for &b in group {
150
+ let d = hex_value(b);
151
+ *bad |= d;
152
+ v = (v << 4) | u64::from(d & 0x0F);
153
+ }
154
+ v
155
+ }
156
+
157
+ /// Parse a strict hex string (`[0-9a-fA-F]+`), optionally skipping `-`.
158
+ /// Returns `None` for anything else, including values wider than 128 bits.
159
+ #[inline]
160
+ pub fn parse_hex(input: &[u8], skip_dashes: bool) -> Option<u128> {
161
+ let mut v: u128 = 0;
162
+ let mut digits = 0usize;
163
+ for &b in input {
164
+ if skip_dashes && b == b'-' {
165
+ continue;
166
+ }
167
+ let d = hex_value(b);
168
+ if d == INVALID || (v >> 124) != 0 {
169
+ return None;
170
+ }
171
+ v = (v << 4) | u128::from(d);
172
+ digits += 1;
173
+ }
174
+ if digits == 0 {
175
+ return None;
176
+ }
177
+ Some(v)
178
+ }
179
+
180
+ /// Parse a canonical 36-byte UUID (8-4-4-4-12, any hex case).
181
+ #[inline]
182
+ pub fn parse_canonical_uuid(input: &[u8]) -> Option<u128> {
183
+ let b: &[u8; 36] = input.try_into().ok()?;
184
+ if b[8] != b'-' || b[13] != b'-' || b[18] != b'-' || b[23] != b'-' {
185
+ return None;
186
+ }
187
+ let mut bad = 0u8;
188
+ let hi = hex_run(&b[0..8], 0, &mut bad);
189
+ let hi = hex_run(&b[9..13], hi, &mut bad);
190
+ let hi = hex_run(&b[14..18], hi, &mut bad);
191
+ let lo = hex_run(&b[19..23], 0, &mut bad);
192
+ let lo = hex_run(&b[24..36], lo, &mut bad);
193
+ if bad & 0xF0 != 0 {
194
+ return None;
195
+ }
196
+ Some((u128::from(hi) << 64) | u128::from(lo))
197
+ }
198
+
199
+ #[inline(always)]
200
+ fn b58_pair(x: u32) -> [u8; 2] {
201
+ // x < 3364 at every call site.
202
+ B58_PAIRS.get(x as usize).copied().unwrap_or(*b"11")
203
+ }
204
+
205
+ /// Five base-58 digits of `x` (< 58^5), most significant first.
206
+ #[inline(always)]
207
+ fn five_digits(x: u32) -> [u8; 5] {
208
+ let (x, lo) = (x / 3364, x % 3364);
209
+ let (d0, mid) = (x / 3364, x % 3364);
210
+ let [a, b] = b58_pair(mid);
211
+ let [c, d] = b58_pair(lo);
212
+ [b58_char(d0), a, b, c, d]
213
+ }
214
+
215
+ /// Number of base-58 digits needed for `v` (1 for zero).
216
+ #[inline(always)]
217
+ fn digit_count(v: u128) -> usize {
218
+ let bits = (128 - v.leading_zeros()) as usize;
219
+ let lo = usize::from(DIGITS_LO.get(bits).copied().unwrap_or(1));
220
+ match POW58.get(lo) {
221
+ Some(&p) if v >= p => lo + 1,
222
+ _ => lo,
223
+ }
224
+ }
225
+
226
+ /// Split a value < 58^10 into its high and low five-digit halves.
227
+ #[inline(always)]
228
+ fn split_p5(x: u64) -> (u32, u32) {
229
+ let hi = x / u64::from(P5);
230
+ let lo = x - hi * u64::from(P5);
231
+ (hi as u32, lo as u32)
232
+ }
233
+
234
+ /// Encode a u128 into `out`, returning the index where the digits start.
235
+ #[inline]
236
+ pub fn encode_u128(v: u128, out: &mut [u8; MAX_B58_LEN]) -> usize {
237
+ // v = top * 58^20 + mid * 58^10 + lo, with mid, lo < 58^10 and top < 58^2.
238
+ let q = v / P10_U128; // the only 128-bit division
239
+ let lo = (v - q * P10_U128) as u64;
240
+ // q < 2^70, so q >> 10 fits in a u64 and the next division is 64-bit.
241
+ let top = ((q >> 10) as u64) / P10_ODD;
242
+ let mid = (q - u128::from(top) * P10_U128) as u64;
243
+
244
+ // Five independent 5-digit chains keep the dependency depth short.
245
+ let (m1, m2) = split_p5(mid);
246
+ let (l1, l2) = split_p5(lo);
247
+ let [t0, t1] = b58_pair(top as u32); // top < 3364
248
+ let [a, b, c, d, e] = five_digits(m1);
249
+ let [f, g, h, i, j] = five_digits(m2);
250
+ let [k, l, m, n, o] = five_digits(l1);
251
+ let [p, q2, r, s, u] = five_digits(l2);
252
+ *out = [
253
+ t0, t1, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q2, r, s, u,
254
+ ];
255
+ MAX_B58_LEN - digit_count(v)
256
+ }
257
+
258
+ /// Value of five base-58 digit values (each < 58), most significant first.
259
+ #[inline(always)]
260
+ fn five_value(d: &[u8; 5]) -> u64 {
261
+ let [a, b, c, e, f] = d.map(u64::from);
262
+ (((a * 58 + b) * 58 + c) * 58 + e) * 58 + f
263
+ }
264
+
265
+ /// Decode a base-58 string to a u128. `None` if any byte is outside the
266
+ /// alphabet or the value needs more than 128 bits.
267
+ #[inline]
268
+ pub fn decode_u128(input: &[u8]) -> Option<u128> {
269
+ // Leading '1's are zero digits and never affect the value, so they only
270
+ // need stripping when the input is longer than any 128-bit encoding.
271
+ let digits = if input.len() > MAX_B58_LEN {
272
+ let start = input.iter().position(|&b| b != b'1').unwrap_or(input.len());
273
+ input.get(start..)?
274
+ } else {
275
+ input
276
+ };
277
+ let pad = MAX_B58_LEN.checked_sub(digits.len())?;
278
+
279
+ // Right-align digit values into a fixed 22-slot buffer (zeros on the left)
280
+ // so the arithmetic below is straight-line code.
281
+ let mut vals = [0u8; MAX_B58_LEN];
282
+ let mut bad = 0u8;
283
+ for (slot, &b) in vals.iter_mut().skip(pad).zip(digits) {
284
+ let d = b58_value(b);
285
+ bad |= d;
286
+ *slot = d;
287
+ }
288
+ // Valid digit values are < 64; INVALID (0xFF) sets the top bits.
289
+ if bad & 0xC0 != 0 {
290
+ return None;
291
+ }
292
+
293
+ let (top, rest) = vals.split_first_chunk::<2>()?;
294
+ let (g1, rest) = rest.split_first_chunk::<5>()?;
295
+ let (g2, rest) = rest.split_first_chunk::<5>()?;
296
+ let (g3, rest) = rest.split_first_chunk::<5>()?;
297
+ let g4: &[u8; 5] = rest.try_into().ok()?;
298
+
299
+ let top = u64::from(top[0]) * 58 + u64::from(top[1]);
300
+ let mid = five_value(g1) * u64::from(P5) + five_value(g2);
301
+ let lo = five_value(g3) * u64::from(P5) + five_value(g4);
302
+ let hi = u128::from(top) * P10_U128 + u128::from(mid);
303
+ hi.checked_mul(P10_U128)?.checked_add(u128::from(lo))
304
+ }
305
+
306
+ /// Format as a lowercase, dashed, zero-padded UUID.
307
+ #[inline]
308
+ pub fn format_uuid(v: u128) -> [u8; 36] {
309
+ const OFFSETS: [usize; 16] = [0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34];
310
+ let mut out = [b'-'; 36];
311
+ for (&byte, &off) in v.to_be_bytes().iter().zip(OFFSETS.iter()) {
312
+ if let Some(dst) = out.get_mut(off..off + 2) {
313
+ dst.copy_from_slice(&hex_pair(byte));
314
+ }
315
+ }
316
+ out
317
+ }
318
+
319
+ /// Format as lowercase hex without leading zeros ("0" for zero), returning
320
+ /// the buffer and start index.
321
+ #[inline]
322
+ pub fn format_hex(v: u128) -> ([u8; 32], usize) {
323
+ let mut out = [b'0'; 32];
324
+ for (dst, &byte) in out
325
+ .as_chunks_mut::<2>()
326
+ .0
327
+ .iter_mut()
328
+ .zip(v.to_be_bytes().iter())
329
+ {
330
+ *dst = hex_pair(byte);
331
+ }
332
+ let start = if v == 0 {
333
+ 31
334
+ } else {
335
+ (v.leading_zeros() / 4) as usize
336
+ };
337
+ (out, start)
338
+ }
339
+
340
+ #[cfg(test)]
341
+ #[allow(clippy::unwrap_used, clippy::indexing_slicing)]
342
+ mod tests {
343
+ use super::*;
344
+
345
+ fn enc(v: u128) -> String {
346
+ let mut buf = [0u8; MAX_B58_LEN];
347
+ let start = encode_u128(v, &mut buf);
348
+ String::from_utf8_lossy(buf.get(start..).unwrap_or(&[])).into_owned()
349
+ }
350
+
351
+ fn naive_enc(mut v: u128) -> String {
352
+ if v == 0 {
353
+ return "1".into();
354
+ }
355
+ let mut s = Vec::new();
356
+ while v > 0 {
357
+ s.push(ALPHABET[(v % 58) as usize]);
358
+ v /= 58;
359
+ }
360
+ s.reverse();
361
+ String::from_utf8(s).unwrap()
362
+ }
363
+
364
+ fn naive_dec(s: &[u8]) -> Option<u128> {
365
+ let mut v: u128 = 0;
366
+ for &c in s {
367
+ let d = ALPHABET.iter().position(|&a| a == c)? as u128;
368
+ v = v.checked_mul(58)?.checked_add(d)?;
369
+ }
370
+ Some(v)
371
+ }
372
+
373
+ #[test]
374
+ fn boundaries() {
375
+ let mut cases = vec![0u128, 1, 57, 58, 59, u128::MAX, u128::MAX - 1];
376
+ let mut p: u128 = 1;
377
+ while let Some(n) = p.checked_mul(58) {
378
+ cases.extend([p - 1, p, p + 1]);
379
+ p = n;
380
+ }
381
+ cases.extend([p - 1, p, p + 1]);
382
+ for &v in &cases {
383
+ let e = enc(v);
384
+ assert_eq!(e, naive_enc(v), "encode {v}");
385
+ assert_eq!(decode_u128(e.as_bytes()), Some(v), "decode {v}");
386
+ }
387
+ }
388
+
389
+ #[test]
390
+ fn random_roundtrip() {
391
+ let mut x: u128 = 0x9E37_79B9_7F4A_7C15_F39C_C060_5CED_C834;
392
+ for _ in 0..200_000 {
393
+ x ^= x << 13;
394
+ x ^= x >> 7;
395
+ x ^= x << 17;
396
+ let v = x >> (x as u32 % 128);
397
+ assert_eq!(enc(v), naive_enc(v));
398
+ assert_eq!(decode_u128(enc(v).as_bytes()), Some(v));
399
+ let uuid = format_uuid(v);
400
+ assert_eq!(parse_canonical_uuid(&uuid), Some(v));
401
+ assert_eq!(parse_hex(&uuid, true), Some(v));
402
+ }
403
+ }
404
+
405
+ fn check_all(v: u128) {
406
+ let e = enc(v);
407
+ assert_eq!(e, naive_enc(v), "encode {v}");
408
+ assert_eq!(decode_u128(e.as_bytes()), Some(v), "decode {v}");
409
+ assert_eq!(decode_u128(format!("1111{e}").as_bytes()), Some(v));
410
+ let hex = format!("{v:032x}");
411
+ let uuid = format!(
412
+ "{}-{}-{}-{}-{}",
413
+ &hex[0..8],
414
+ &hex[8..12],
415
+ &hex[12..16],
416
+ &hex[16..20],
417
+ &hex[20..]
418
+ );
419
+ assert_eq!(format_uuid(v).as_slice(), uuid.as_bytes());
420
+ assert_eq!(parse_canonical_uuid(uuid.as_bytes()), Some(v));
421
+ assert_eq!(
422
+ parse_canonical_uuid(uuid.to_uppercase().as_bytes()),
423
+ Some(v)
424
+ );
425
+ assert_eq!(parse_hex(uuid.as_bytes(), true), Some(v));
426
+ assert_eq!(parse_hex(format!("{v:x}").as_bytes(), false), Some(v));
427
+ let (h, start) = format_hex(v);
428
+ assert_eq!(&h[start..], format!("{v:x}").as_bytes());
429
+ }
430
+
431
+ #[test]
432
+ fn against_std_formatting() {
433
+ let mut p: u128 = 1;
434
+ loop {
435
+ for d in [0u128, 1, 2] {
436
+ check_all(p.wrapping_sub(d));
437
+ check_all(p.wrapping_add(d));
438
+ }
439
+ match p.checked_mul(58) {
440
+ Some(n) => p = n,
441
+ None => break,
442
+ }
443
+ }
444
+ for b in 0..128 {
445
+ check_all(1u128 << b);
446
+ check_all((1u128 << b) - 1);
447
+ }
448
+ check_all(u128::MAX);
449
+ let mut x: u128 = 0xDEAD_BEEF_0123_4567_89AB_CDEF_F00D_CAFE;
450
+ for _ in 0..100_000 {
451
+ x ^= x << 13;
452
+ x ^= x >> 7;
453
+ x ^= x << 17;
454
+ check_all(x >> (x as u32 % 128));
455
+ }
456
+ }
457
+
458
+ #[test]
459
+ fn invalid_bytes_everywhere() {
460
+ let good = enc(0x550e_8400_e29b_41d4_a716_4466_5544_0000);
461
+ let uuid = format_uuid(0x550e_8400_e29b_41d4_a716_4466_5544_0000);
462
+ for b in 0..=255u8 {
463
+ let valid_b58 = ALPHABET.contains(&b);
464
+ let valid_hex = b.is_ascii_hexdigit();
465
+ for pos in 0..good.len() {
466
+ let mut s = good.clone().into_bytes();
467
+ s[pos] = b;
468
+ assert_eq!(decode_u128(&s), naive_dec(&s), "b58 byte {b} at {pos}");
469
+ if !valid_b58 {
470
+ assert_eq!(decode_u128(&s), None);
471
+ }
472
+ }
473
+ for pos in 0..36 {
474
+ let mut u = uuid;
475
+ u[pos] = b;
476
+ let is_dash_slot = [8, 13, 18, 23].contains(&pos);
477
+ let ok = if is_dash_slot { b == b'-' } else { valid_hex };
478
+ assert_eq!(
479
+ parse_canonical_uuid(&u).is_some(),
480
+ ok,
481
+ "uuid byte {b} at {pos}"
482
+ );
483
+ }
484
+ }
485
+ for len in 0..40 {
486
+ let ones = vec![b'1'; len];
487
+ assert_eq!(decode_u128(&ones), Some(0));
488
+ let mut zs = vec![b'z'; len];
489
+ assert_eq!(decode_u128(&zs), naive_dec(&zs), "z*{len}");
490
+ assert_eq!(decode_u128(&zs).is_some(), len <= 21);
491
+ zs.insert(0, b'1');
492
+ assert_eq!(decode_u128(&zs), naive_dec(&zs));
493
+ }
494
+ }
495
+
496
+ #[test]
497
+ fn decode_edges() {
498
+ assert_eq!(decode_u128(b""), Some(0));
499
+ assert_eq!(decode_u128(b"1111111111111111111111111111111111"), Some(0));
500
+ assert_eq!(decode_u128(b"0"), None);
501
+ assert_eq!(decode_u128(b"zzzzzzzzzzzzzzzzzzzzzz"), None); // > 2^128
502
+ let max = enc(u128::MAX);
503
+ assert_eq!(decode_u128(format!("111{max}").as_bytes()), Some(u128::MAX));
504
+ }
505
+
506
+ #[test]
507
+ fn hex_edges() {
508
+ assert_eq!(parse_hex(b"", true), None);
509
+ assert_eq!(parse_hex(b"----", true), None);
510
+ assert_eq!(parse_hex(b"0x1", false), None);
511
+ assert_eq!(parse_hex(b"a-b", false), None);
512
+ assert_eq!(parse_hex(b"a-b", true), Some(0xab));
513
+ assert_eq!(parse_hex(&[b'f'; 32], false), Some(u128::MAX));
514
+ assert_eq!(parse_hex(&[b'f'; 33], false), None);
515
+ let mut padded = vec![b'0'; 40];
516
+ padded.push(b'1');
517
+ assert_eq!(parse_hex(&padded, false), Some(1));
518
+ assert_eq!(format_hex(0).1, 31);
519
+ }
520
+ }
@@ -0,0 +1,27 @@
1
+ [package]
2
+ name = "base58_native"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ rust-version = "1.88"
6
+ publish = false
7
+ license = "MIT"
8
+
9
+ [lib]
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ base58_codec = { path = "../base58_codec" }
14
+ magnus = { version = "0.9", features = ["bytes"] }
15
+ bytes = "1"
16
+
17
+ [lints.rust]
18
+ unsafe_code = "forbid"
19
+
20
+ [lints.clippy]
21
+ unwrap_used = "deny"
22
+ expect_used = "deny"
23
+ panic = "deny"
24
+ indexing_slicing = "deny"
25
+ unreachable = "deny"
26
+ todo = "deny"
27
+ unimplemented = "deny"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "rb_sys/mkmf"
5
+
6
+ create_rust_makefile("base58_native/base58_native")