From 9f49daddbb87920e64439650a2256eb4e94b58dd Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Tue, 1 Nov 2022 15:21:46 +0100 Subject: Make compatible with Zig dev This library can be compiled again, now that ziglang/zig#13378 has been closed by ziglang/zig#13386. --- src/main.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.zig b/src/main.zig index 6c6e7c8..6f68295 100644 --- a/src/main.zig +++ b/src/main.zig @@ -16,7 +16,7 @@ pub const NoNkeySeedFoundError = error{NoNkeySeedFound}; pub const NoNkeyUserSeedFoundError = error{NoNkeyUserSeedFound}; pub const DecodeError = InvalidPrefixByteError || base32.DecodeError || crc16.InvalidChecksumError || crypto.errors.NonCanonicalError; pub const SeedDecodeError = DecodeError || InvalidSeedError || crypto.errors.IdentityElementError; -pub const PrivateKeyDecodeError = DecodeError || InvalidPrivateKeyError || crypto.errors.EncodingError; +pub const PrivateKeyDecodeError = DecodeError || InvalidPrivateKeyError || crypto.errors.EncodingError || crypto.errors.NonCanonicalError || crypto.errors.IdentityElementError; pub const SignError = crypto.errors.IdentityElementError || crypto.errors.NonCanonicalError || crypto.errors.KeyMismatchError || crypto.errors.WeakPublicKeyError; pub const prefix_byte_account = 0; // A @@ -133,10 +133,8 @@ pub const SeedKeyPair = struct { if (key_ty_prefix != prefix_byte_seed) return error.InvalidSeed; - return Self{ - .role = Role.fromPublicPrefixByte(role_prefix) orelse return error.InvalidPrefixByte, - .kp = try Ed25519.KeyPair.create(decoded.data), - }; + const role = Role.fromPublicPrefixByte(role_prefix) orelse return error.InvalidPrefixByte; + return fromRawSeed(role, &decoded.data); } pub fn fromRawSeed( @@ -235,10 +233,12 @@ pub const PrivateKey = struct { return error.InvalidPrivateKey; var secret_key = Ed25519.SecretKey.fromBytes(decoded.data) catch unreachable; - return Self{ .kp = try Ed25519.KeyPair.fromSecretKey(secret_key) }; + return fromRawPrivateKey(&secret_key); } - pub fn fromRawPrivateKey(raw_key: *const Ed25519.SecretKey) InvalidEncodingError!Self { + pub fn fromRawPrivateKey( + raw_key: *const Ed25519.SecretKey, + ) (crypto.errors.NonCanonicalError || crypto.errors.EncodingError || crypto.errors.IdentityElementError)!Self { return .{ .kp = try Ed25519.KeyPair.fromSecretKey(raw_key.*) }; } -- cgit v1.2.3