diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 14 | 
1 files changed, 7 insertions, 7 deletions
| 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}; | |||
| 16 | pub const NoNkeyUserSeedFoundError = error{NoNkeyUserSeedFound}; | 16 | pub const NoNkeyUserSeedFoundError = error{NoNkeyUserSeedFound}; | 
| 17 | pub const DecodeError = InvalidPrefixByteError || base32.DecodeError || crc16.InvalidChecksumError || crypto.errors.NonCanonicalError; | 17 | pub const DecodeError = InvalidPrefixByteError || base32.DecodeError || crc16.InvalidChecksumError || crypto.errors.NonCanonicalError; | 
| 18 | pub const SeedDecodeError = DecodeError || InvalidSeedError || crypto.errors.IdentityElementError; | 18 | pub const SeedDecodeError = DecodeError || InvalidSeedError || crypto.errors.IdentityElementError; | 
| 19 | pub const PrivateKeyDecodeError = DecodeError || InvalidPrivateKeyError || crypto.errors.EncodingError; | 19 | pub const PrivateKeyDecodeError = DecodeError || InvalidPrivateKeyError || crypto.errors.EncodingError || crypto.errors.NonCanonicalError || crypto.errors.IdentityElementError; | 
| 20 | pub const SignError = crypto.errors.IdentityElementError || crypto.errors.NonCanonicalError || crypto.errors.KeyMismatchError || crypto.errors.WeakPublicKeyError; | 20 | pub const SignError = crypto.errors.IdentityElementError || crypto.errors.NonCanonicalError || crypto.errors.KeyMismatchError || crypto.errors.WeakPublicKeyError; | 
| 21 | 21 | ||
| 22 | pub const prefix_byte_account = 0; // A | 22 | pub const prefix_byte_account = 0; // A | 
| @@ -133,10 +133,8 @@ pub const SeedKeyPair = struct { | |||
| 133 | if (key_ty_prefix != prefix_byte_seed) | 133 | if (key_ty_prefix != prefix_byte_seed) | 
| 134 | return error.InvalidSeed; | 134 | return error.InvalidSeed; | 
| 135 | 135 | ||
| 136 | return Self{ | 136 | const role = Role.fromPublicPrefixByte(role_prefix) orelse return error.InvalidPrefixByte; | 
| 137 | .role = Role.fromPublicPrefixByte(role_prefix) orelse return error.InvalidPrefixByte, | 137 | return fromRawSeed(role, &decoded.data); | 
| 138 | .kp = try Ed25519.KeyPair.create(decoded.data), | ||
| 139 | }; | ||
| 140 | } | 138 | } | 
| 141 | 139 | ||
| 142 | pub fn fromRawSeed( | 140 | pub fn fromRawSeed( | 
| @@ -235,10 +233,12 @@ pub const PrivateKey = struct { | |||
| 235 | return error.InvalidPrivateKey; | 233 | return error.InvalidPrivateKey; | 
| 236 | 234 | ||
| 237 | var secret_key = Ed25519.SecretKey.fromBytes(decoded.data) catch unreachable; | 235 | var secret_key = Ed25519.SecretKey.fromBytes(decoded.data) catch unreachable; | 
| 238 | return Self{ .kp = try Ed25519.KeyPair.fromSecretKey(secret_key) }; | 236 | return fromRawPrivateKey(&secret_key); | 
| 239 | } | 237 | } | 
| 240 | 238 | ||
| 241 | pub fn fromRawPrivateKey(raw_key: *const Ed25519.SecretKey) InvalidEncodingError!Self { | 239 | pub fn fromRawPrivateKey( | 
| 240 | raw_key: *const Ed25519.SecretKey, | ||
| 241 | ) (crypto.errors.NonCanonicalError || crypto.errors.EncodingError || crypto.errors.IdentityElementError)!Self { | ||
| 242 | return .{ .kp = try Ed25519.KeyPair.fromSecretKey(raw_key.*) }; | 242 | return .{ .kp = try Ed25519.KeyPair.fromSecretKey(raw_key.*) }; | 
| 243 | } | 243 | } | 
| 244 | 244 | ||