aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2024-04-27 02:25:17 +0200
committerLibravatar Rutger Broekhoff2024-04-27 02:25:17 +0200
commit66e0e65fd17d50d857ce5e4f3e8d56b3a795845c (patch)
treef437a03e561074f43438e6ea0d07f55e150cdce7
parenta50016c7481b4c8613e03af136d93309c6b30400 (diff)
downloadzig-nkeys-66e0e65fd17d50d857ce5e4f3e8d56b3a795845c.tar.gz
zig-nkeys-66e0e65fd17d50d857ce5e4f3e8d56b3a795845c.zip
Minor updates for Zig 0.12.0HEAD0.6.0main
-rw-r--r--build.zig16
-rw-r--r--tool/znk.zig4
2 files changed, 8 insertions, 12 deletions
diff --git a/build.zig b/build.zig
index de48e91..626bf25 100644
--- a/build.zig
+++ b/build.zig
@@ -1,6 +1,6 @@
1const std = @import("std"); 1const std = @import("std");
2 2
3pub fn build(b: *std.build.Builder) !void { 3pub fn build(b: *std.Build) !void {
4 const target = b.standardTargetOptions(.{}); 4 const target = b.standardTargetOptions(.{});
5 const optimize = b.standardOptimizeOption(.{}); 5 const optimize = b.standardOptimizeOption(.{});
6 6
@@ -14,15 +14,11 @@ pub fn build(b: *std.build.Builder) !void {
14 const test_step = b.step("test", "Run library tests"); 14 const test_step = b.step("test", "Run library tests");
15 test_step.dependOn(&run_lib_tests.step); 15 test_step.dependOn(&run_lib_tests.step);
16 16
17 const znk_version = "0.2.1"; 17 const znk_version = "0.2.2";
18 18
19 const znk_options = b.addOptions(); 19 const znk_options = b.addOptions();
20 znk_options.addOption([]const u8, "version", znk_version); 20 znk_options.addOption([]const u8, "version", znk_version);
21 21
22 const nkeys_module = b.addModule("nkeys", .{
23 .source_file = .{ .path = "src/main.zig" },
24 });
25
26 const lib = b.addStaticLibrary(.{ 22 const lib = b.addStaticLibrary(.{
27 .name = "nkeys", 23 .name = "nkeys",
28 .root_source_file = .{ .path = "src/main.zig" }, 24 .root_source_file = .{ .path = "src/main.zig" },
@@ -37,8 +33,8 @@ pub fn build(b: *std.build.Builder) !void {
37 .target = target, 33 .target = target,
38 .optimize = optimize, 34 .optimize = optimize,
39 }); 35 });
40 znk_tests.addModule("nkeys", nkeys_module); 36 znk_tests.root_module.addImport("nkeys", &lib.root_module);
41 znk_tests.addOptions("build_options", znk_options); 37 znk_tests.root_module.addOptions("build_options", znk_options);
42 const run_znk_tests = b.addRunArtifact(znk_tests); 38 const run_znk_tests = b.addRunArtifact(znk_tests);
43 39
44 const znk_test_step = b.step("test-znk", "Run znk tests"); 40 const znk_test_step = b.step("test-znk", "Run znk tests");
@@ -50,8 +46,8 @@ pub fn build(b: *std.build.Builder) !void {
50 .target = target, 46 .target = target,
51 .optimize = optimize, 47 .optimize = optimize,
52 }); 48 });
53 znk.addModule("nkeys", nkeys_module); 49 znk.root_module.addImport("nkeys", &lib.root_module);
54 znk.addOptions("build_options", znk_options); 50 znk.root_module.addOptions("build_options", znk_options);
55 51
56 b.installArtifact(znk); 52 b.installArtifact(znk);
57 53
diff --git a/tool/znk.zig b/tool/znk.zig
index af8f757..c50edae 100644
--- a/tool/znk.zig
+++ b/tool/znk.zig
@@ -438,7 +438,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type {
438 fn generatePrivate(self: *Self) !void { 438 fn generatePrivate(self: *Self) !void {
439 var rr = RandomReader.init(&std.crypto.random); 439 var rr = RandomReader.init(&std.crypto.random);
440 var brr = io.BufferedReader(1024 * 4096, @TypeOf(rr.reader())){ .unbuffered_reader = rr.reader() }; 440 var brr = io.BufferedReader(1024 * 4096, @TypeOf(rr.reader())){ .unbuffered_reader = rr.reader() };
441 while (!self.done.load(.SeqCst)) { 441 while (!self.done.load(.seq_cst)) {
442 const gen_result = if (self.entropy) |entropy| 442 const gen_result = if (self.entropy) |entropy|
443 nkeys.SeedKeyPair.generateWithCustomEntropy(self.role, entropy) 443 nkeys.SeedKeyPair.generateWithCustomEntropy(self.role, entropy)
444 else 444 else
@@ -447,7 +447,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type {
447 447
448 var public_key = kp.publicKeyText(); 448 var public_key = kp.publicKeyText();
449 if (mem.startsWith(u8, public_key[1..], self.prefix)) { 449 if (mem.startsWith(u8, public_key[1..], self.prefix)) {
450 if (self.done.swap(true, .SeqCst)) return; // another thread is already done 450 if (self.done.swap(true, .seq_cst)) return; // another thread is already done
451 451
452 info("{s}", .{kp.seedText()}); 452 info("{s}", .{kp.seedText()});
453 info("{s}", .{public_key}); 453 info("{s}", .{public_key});