Beispiel #1
0
        public KeyPair(string sk)
        {
            skBytes = Helper.StringToByteArray(sk);
            vkBytes = new byte[VKEY_LEN];
            byte[] seed = new byte[SEED_LEN];
            NativeLibsodium.crypto_sign_ed25519_sk_to_seed(seed, skBytes);
            NativeLibsodium.crypto_sign_seed_keypair(vkBytes, skBytes, seed);

            // The x64 versions of the library require a 64 byte array for the sk that is the sk+vk
            byte[] temp = new byte[SKEY_LEN];
            for (int i = 0; i < 32; i++)
            {
                temp[i] = skBytes[i];
            }
            for (int i = 0; i < 32; i++)
            {
                temp[i + 32] = vkBytes[i];
            }
            skBytes = temp;

            Debug.Log($"sk: {Helper.ByteArrayToHexString(skBytes)}, vk: {Helper.ByteArrayToHexString(vkBytes)} ");
            vkString = Helper.ByteArrayToHexString(vkBytes).ToLower();
        }