コード例 #1
0
        public static unsafe byte *SigningKeyToEncryptionKey(IKeyFileService keyFileService, IKeyCapture capture)
        {
            var sk = keyFileService.GetSecretKeyPointer(capture);

            try
            {
                return(SigningKeyToEncryptionKey(sk));
            }
            finally
            {
                NativeMethods.sodium_free(sk);
            }
        }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
        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();
            }
        }