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

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

            return(Numerics.Base58.Encode(CryptoExtensions.AESGCMEncrypt(System.Text.Encoding.UTF8.GetBytes(name), keys.PrivateKey, NameInitializationVector)));
        }
Exemplo n.º 3
0
        private static ExecutionState Runtime_AESEncrypt(RuntimeVM vm)
        {
            vm.ExpectStackSize(2);

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

            var encryptedData = CryptoExtensions.AESGCMEncrypt(data, key);

            var result = new VMObject();

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

            return(ExecutionState.Running);
        }