diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib.zig b/src/lib.zig index 05922bd..23f0e05 100644 --- a/src/lib.zig +++ b/src/lib.zig | |||
@@ -116,6 +116,13 @@ pub const SeedKeyPair = struct { | |||
116 | return Self{ .role = role, .kp = try Ed25519.KeyPair.create(raw_seed) }; | 116 | return Self{ .role = role, .kp = try Ed25519.KeyPair.create(raw_seed) }; |
117 | } | 117 | } |
118 | 118 | ||
119 | pub fn generateWithCustomEntropy(role: Role, reader: anytype) !Self { | ||
120 | var raw_seed: [Ed25519.seed_length]u8 = undefined; | ||
121 | try reader.readNoEof(&raw_seed); | ||
122 | defer wipeBytes(&raw_seed); | ||
123 | return Self{ .role = role, .kp = try Ed25519.KeyPair.create(raw_seed) }; | ||
124 | } | ||
125 | |||
119 | pub fn fromTextSeed(text: *const text_seed) SeedDecodeError!Self { | 126 | pub fn fromTextSeed(text: *const text_seed) SeedDecodeError!Self { |
120 | var decoded = try decode(2, Ed25519.seed_length, text); | 127 | var decoded = try decode(2, Ed25519.seed_length, text); |
121 | defer decoded.wipe(); // gets copied | 128 | defer decoded.wipe(); // gets copied |
@@ -455,7 +462,7 @@ fn wipeBytes(bs: []u8) void { | |||
455 | for (bs) |*b| b.* = 0; | 462 | for (bs) |*b| b.* = 0; |
456 | } | 463 | } |
457 | 464 | ||
458 | test "reference all delcarations" { | 465 | test "reference all declarations" { |
459 | testing.refAllDecls(@This()); | 466 | testing.refAllDecls(@This()); |
460 | testing.refAllDecls(Role); | 467 | testing.refAllDecls(Role); |
461 | testing.refAllDecls(SeedKeyPair); | 468 | testing.refAllDecls(SeedKeyPair); |