public static unsafe byte *SigningKeyToEncryptionKey(IKeyFileService keyFileService, IKeyCapture capture) { var sk = keyFileService.GetSecretKeyPointer(capture); try { return(SigningKeyToEncryptionKey(sk)); } finally { NativeMethods.sodium_free(sk); } }
public static byte[] SigningPublicKeyFromSigningKey(IKeyFileService keyFileService, IKeyCapture capture) { unsafe { var sk = keyFileService.GetSecretKeyPointer(capture); try { var ed25519PublicKey = new byte[PublicKeyBytes]; SigningPublicKeyFromSigningKey(sk, ed25519PublicKey); return(ed25519PublicKey); } finally { NativeMethods.sodium_free(sk); } } }
public void Sign(IKeyFileService keyFileService, IKeyCapture capture, ulong formatVersion = LogSerializeContext.FormatVersion) { unsafe { var sk = keyFileService.GetSecretKeyPointer(capture); var message = GetMessage(formatVersion); var signature = new byte[Crypto.SecretKeyBytes].AsSpan(); var signatureLength = Crypto.SignDetached(message, sk, signature); if (signatureLength < (ulong)signature.Length) { signature = signature.Slice(0, (int)signatureLength); } Signature = signature.ToArray(); } }