aboutsummaryrefslogtreecommitdiffstats
path: root/src/znk.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/znk.zig')
-rw-r--r--src/znk.zig24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/znk.zig b/src/znk.zig
index 5a5ab5e..7cb16c6 100644
--- a/src/znk.zig
+++ b/src/znk.zig
@@ -147,12 +147,12 @@ pub fn cmdGen(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !voi
147 147
148 try PrefixKeyGenerator.init(arena, ty.?, capitalized_prefix).generate(); 148 try PrefixKeyGenerator.init(arena, ty.?, capitalized_prefix).generate();
149 } else { 149 } else {
150 var kp = nkeys.SeedKeyPair.generate(ty.?); 150 var kp = try nkeys.SeedKeyPair.generate(ty.?);
151 defer kp.wipe(); 151 defer kp.wipe();
152 try stdout.writeAll(&kp.seed); 152 try stdout.writeAll(&kp.asTextSeed());
153 try stdout.writeAll("\n"); 153 try stdout.writeAll("\n");
154 154
155 var public_key = kp.publicKey() catch |e| fatal("could not generate public key: {e}", .{e}); 155 var public_key = kp.asTextPublicKey();
156 if (pub_out) { 156 if (pub_out) {
157 try stdout.writeAll(&public_key); 157 try stdout.writeAll(&public_key);
158 try stdout.writeAll("\n"); 158 try stdout.writeAll("\n");
@@ -377,18 +377,18 @@ const PrefixKeyGenerator = struct {
377 }; 377 };
378 } 378 }
379 379
380 fn generatePrivate(self: *Self) void { 380 fn generatePrivate(self: *Self) !void {
381 while (true) { 381 while (true) {
382 if (self.done.load(.SeqCst)) return; 382 if (self.done.load(.SeqCst)) return;
383 383
384 var kp = nkeys.SeedKeyPair.generate(self.ty); 384 var kp = try nkeys.SeedKeyPair.generate(self.ty);
385 defer kp.wipe(); 385 defer kp.wipe();
386 var public_key = kp.publicKey() catch |e| fatal("could not generate public key: {e}", .{e}); 386 var public_key = kp.asTextPublicKey();
387 if (!mem.startsWith(u8, public_key[1..], self.prefix)) continue; 387 if (!mem.startsWith(u8, public_key[1..], self.prefix)) continue;
388 388
389 if (self.done.xchg(true, .SeqCst)) return; // another thread is already done 389 if (self.done.xchg(true, .SeqCst)) return; // another thread is already done
390 390
391 info("{s}", .{kp.seed}); 391 info("{s}", .{kp.asTextSeed()});
392 info("{s}", .{public_key}); 392 info("{s}", .{public_key});
393 393
394 return; 394 return;
@@ -432,16 +432,16 @@ pub const Nkey = union(enum) {
432 432
433 const Self = @This(); 433 const Self = @This();
434 434
435 pub fn publicKey(self: *const Self) !nkeys.text_public { 435 pub fn publicKey(self: *const Self) nkeys.text_public {
436 return switch (self.*) { 436 return switch (self.*) {
437 .seed_key_pair => |*kp| try kp.publicKey(), 437 .seed_key_pair => |*kp| kp.asTextPublicKey(),
438 .public_key => |*pk| pk.publicKey(), 438 .public_key => |*pk| pk.asTextPublicKey(),
439 }; 439 };
440 } 440 }
441 441
442 pub fn intoPublicKey(self: *const Self) !nkeys.PublicKey { 442 pub fn intoPublicKey(self: *const Self) nkeys.PublicKey {
443 return switch (self.*) { 443 return switch (self.*) {
444 .seed_key_pair => |*kp| try kp.intoPublicKey(), 444 .seed_key_pair => |*kp| kp.asPublicKey(),
445 .public_key => |pk| pk, 445 .public_key => |pk| pk,
446 }; 446 };
447 } 447 }