public byte[] SignMessage(byte[] hash)
    {
        byte[] buffer       = new byte[hash.Length + 64];
        long   bufferLength = hash.Length + 64;

        NativeLibsodium.crypto_sign(buffer, ref bufferLength, hash, hash.Length, Convert.FromBase64String(ChaChaSigPrivateKey));
        return(buffer);
    }
Exemple #2
0
        public static byte[] SignByte(byte[] toSign, KeyPair signKeyPair)
        {
            byte[] signed       = new byte[toSign.Length + CRYPTO_SIGN_BYTES];
            long   length       = signed.Length;
            long   toSingLength = toSign.Length;

            NativeLibsodium.crypto_sign(signed, ref length, toSign, toSingLength, signKeyPair.secretKey);
            return(signed);
        }
    public byte[] SignMessage(byte[] hash)
    {
        byte[] buffer       = new byte[100000];
        long   bufferLength = 0;

        NativeLibsodium.crypto_sign(buffer, ref bufferLength, hash, hash.Length, Convert.FromBase64String(encryptionConfig.ChaChaSigPrivateKey));
        Array.Resize(ref buffer, (int)bufferLength);
        return(buffer);
    }
Exemple #4
0
    public byte[] SignMessage(byte[] hash)
    {
        long bufferSize = hash.Length + 64;

        byte[] buffer = new byte[bufferSize];

        NativeLibsodium.crypto_sign(buffer, ref bufferSize, hash, hash.Length, ChaChaSigPrivateKey);
        return(buffer);
    }
    public byte[] SignMessage(byte[] signedVar)
    {
        byte[] value       = new byte[signedVar.Length + 64];
        long   valueLength = value.Length;

        NativeLibsodium.crypto_sign(value, ref valueLength, signedVar, signedVar.Length,
                                    System.Convert.FromBase64String(ChaChaSigPrivateKey));

        return(value);
    }
        public byte[] SignMessage(byte[] message)
        {
            long bufferLength = -1;

            NativeLibsodium.crypto_sign(buffer, ref bufferLength, message, message.Length, _privateKey);
            var result = new byte[bufferLength];

            Array.Copy(buffer, result, bufferLength);
            return(result);
        }
Exemple #7
0
        public byte[] SignMessage(byte[] hash)
        {
            byte[] key    = Convert.FromBase64String(ChaChaSigPrivateKey);
            byte[] buffer = new byte[hash.Length + 64];

            long bufferLength = 0;

            int ret = NativeLibsodium.crypto_sign(buffer, ref bufferLength, hash, hash.Length, key);

            if (ret == 0)
            {
                return(buffer);
            }
            return(null);
        }
    public byte[] SignMessage(byte[] hash)
    {
        byte[] buffer       = new byte[2048];
        long   bufferLength = 2048;

        if (NativeLibsodium.crypto_sign(buffer, ref bufferLength, hash, hash.Length, ChaChaSigPrivateKey) == 0)
        {
            Array.Resize(ref buffer, (int)bufferLength);
            return(buffer);
        }
        else
        {
            Debug.LogError("Incorrect Signature");
            return(null);
        }
    }
    public byte[] SignMessage(byte[] msg)
    {
        long bufLength = crypto_sign_BYTES + msg.Length;

        byte[] signedMsg = new byte[bufLength];

        int rc = NativeLibsodium.crypto_sign(signedMsg, ref bufLength, msg, msg.Length, _ChaChaSigPrivateKey);

        if (rc != 0)
        {
            throw new Exception("Error encrypting message.");
        }

        Debug.Log("signed" + signedMsg);
        return(signedMsg);
    }
Exemple #10
0
        public static void Test()
        {
            KeyPair signKeyPair = NewSingKeypair();

            byte[] toSign       = Encoding.UTF8.GetBytes("test!");
            byte[] signed       = new byte[toSign.Length + CRYPTO_SIGN_BYTES];
            long   length       = signed.Length;
            long   toSingLength = toSign.Length;

            NativeLibsodium.crypto_sign(signed, ref length, toSign, toSingLength, signKeyPair.secretKey);

            byte[] checkedData      = new byte[signed.Length - CRYPTO_SIGN_BYTES];
            long   clength          = checkedData.Length;
            long   toValidateLength = signed.Length;

            NativeLibsodium.crypto_sign_open(checkedData, ref clength, signed, toValidateLength, signKeyPair.publicKey);
        }
    public byte[] SignMessage(byte[] unsigned)
    {
        if (NativeLibsodium.crypto_sign_keypair(Convert.FromBase64String(ChaChaSigPublicKey), Convert.FromBase64String(ChaChaSigPrivateKey)) != 0)
        {
            throw new Exception("Wrong Key pair");
        }

        byte[] buffer       = new byte[unsigned.LongLength + 64];
        long   bufferLength = buffer.LongLength;
        int    ret          = NativeLibsodium.crypto_sign(buffer, ref bufferLength, unsigned, unsigned.LongLength,
                                                          Convert.FromBase64String(ChaChaSigPrivateKey));

        if (ret != 0)
        {
            throw new Exception("Error signing message.");
        }

        return(buffer);
    }