public byte[] Decrypt(byte[] chunk, PhantasmaKeys keys)
        {
            if (keys.Address != this.Address)
            {
                throw new ChainException("decryption public address does not match");
            }

            return(CryptoExtensions.AESGCMDecrypt(chunk, keys.PrivateKey, ContentInitializationVector));
        }
        public string DecryptName(string name, PhantasmaKeys keys)
        {
            if (keys.Address != this.Address)
            {
                throw new ChainException("encryption public address does not match");
            }

            return(System.Text.Encoding.UTF8.GetString(CryptoExtensions.AESGCMDecrypt(Numerics.Base58.Decode(name), keys.PrivateKey, NameInitializationVector)));
        }
Esempio n. 3
0
        private static ExecutionState Runtime_AESDecrypt(RuntimeVM vm)
        {
            vm.ExpectStackSize(2);

            var data = vm.PopBytes("data");
            var key  = vm.PopBytes("key");

            var decryptedData = CryptoExtensions.AESGCMDecrypt(data, key);

            var result = new VMObject();

            result.SetValue(decryptedData);
            vm.Stack.Push(result);

            return(ExecutionState.Running);
        }