Beispiel #1
0
        /// <summary>
        /// Validates a signature for given data
        /// </summary>
        /// <returns><c>true</c>, if vertify was successful, <c>false</c> otherwise.</returns>
        /// <param name="signature">Signature.</param>
        /// <param name="data">Data.</param>
        /// <param name="publicKey">Public key.</param>
        public static bool SignVertifyDetached(byte[] signature, byte[] data, byte[] publicKey)
        {
            if (signature == null)
            {
                throw new ArgumentNullException(nameof(signature));
            }

            long length  = data.Length;
            int  success = NativeLibsodium.crypto_sign_verify_detached(signature, data, length, publicKey);

            return(success == 0);
        }
Beispiel #2
0
        public bool Verify(byte[] sig, byte[] msg)
        {
            if (keyPair == null)
            {
                Debug.LogError("Key pair not initialized");
                return(false);
            }

            if (sig == null)
            {
                Debug.LogError("sig cannot be null");
                return(false);
            }

            if (msg == null)
            {
                Debug.LogError("Msg cannot be null");
                return(false);
            }

            return(NativeLibsodium.crypto_sign_verify_detached(sig, msg, msg.Length, keyPair.vkBytes) == 0 ? true : false);
        }