示例#1
0
 public override bool VerifyMessage(byte[] data, byte[] signature, byte[] publicKey)
 {
     return(TezosSigner.Verify(
                data: data,
                signature: signature,
                publicKey: publicKey));
 }
示例#2
0
        public byte[] SignMessage(byte[] data)
        {
            using var scopedPrivateKey = _privateKey.ToUnsecuredBytes();

            return(TezosSigner.Sign(
                       data: data,
                       privateKey: scopedPrivateKey));
        }
示例#3
0
        public byte[] SignHash(byte[] hash)
        {
            using var scopedPrivateKey = _privateKey.ToUnsecuredBytes();

            return(TezosSigner.Sign(
                       data: hash,
                       privateKey: scopedPrivateKey));
        }
示例#4
0
        public bool VerifyMessage(byte[] data, byte[] signature)
        {
            using var scopedPublicKey = _publicKey.ToUnsecuredBytes();

            return(TezosSigner.Verify(
                       data: data,
                       signature: signature,
                       publicKey: scopedPublicKey));
        }
示例#5
0
        public bool VerifyHash(byte[] hash, byte[] signature)
        {
            using var scopedPublicKey = _publicKey.ToUnsecuredBytes();

            return(TezosSigner.Verify(
                       data: hash,
                       signature: signature,
                       publicKey: scopedPublicKey));
        }
示例#6
0
        public byte[] SignMessage(byte[] data)
        {
            GetPrivateKey(out var privateKey);

            try
            {
                return(TezosSigner.Sign(
                           data: data,
                           privateKey: privateKey));
            }
            finally
            {
                privateKey.Clear();
            }
        }
示例#7
0
        public byte[] SignHash(byte[] hash)
        {
            GetPrivateKey(out var privateKey);

            try
            {
                return(TezosSigner.Sign(
                           data: hash,
                           privateKey: privateKey));
            }
            finally
            {
                privateKey.Clear();
            }
        }
示例#8
0
        public byte[] SignMessage(byte[] data)
        {
            using var securePrivateKey = GetPrivateKey();
            using var scopedPrivateKey = securePrivateKey.ToUnsecuredBytes();

            if (scopedPrivateKey.Length == 32)
            {
                return(TezosSigner.Sign(
                           data: data,
                           privateKey: scopedPrivateKey));
            }

            return(TezosSigner.SignByExtendedKey(
                       data: data,
                       extendedPrivateKey: scopedPrivateKey));
        }
示例#9
0
        public bool VerifyMessage(byte[] data, byte[] signature)
        {
            GetPublicKey(out var publicKey);

            try
            {
                return(TezosSigner.Verify(
                           data: data,
                           signature: signature,
                           publicKey: publicKey));
            }
            finally
            {
                publicKey.Clear();
            }
        }
示例#10
0
        public bool VerifyHash(byte[] hash, byte[] signature)
        {
            GetPublicKey(out var publicKey);

            try
            {
                return(TezosSigner.Verify(
                           data: hash,
                           signature: signature,
                           publicKey: publicKey));
            }
            finally
            {
                publicKey.Clear();
            }
        }
示例#11
0
        public byte[] SignMessage(byte[] data)
        {
            GetPrivateKey(out var privateKey);

            try
            {
                if (privateKey.Length == 32)
                {
                    return(TezosSigner.Sign(
                               data: data,
                               privateKey: privateKey));
                }

                return(TezosSigner.SignByExtendedKey(
                           data: data,
                           extendedPrivateKey: privateKey));
            }
            finally
            {
                privateKey.Clear();
            }
        }
示例#12
0
        public byte[] SignHash(byte[] hash)
        {
            GetPrivateKey(out var privateKey);

            try
            {
                if (privateKey.Length == 32)
                {
                    return(TezosSigner.Sign(
                               data: hash,
                               privateKey: privateKey));
                }

                return(TezosSigner.SignByExtendedKey(
                           data: hash,
                           extendedPrivateKey: privateKey));
            }
            finally
            {
                privateKey.Clear();
            }
        }
示例#13
0
        private async Task <List <OperationResult> > SendOperations(
            JToken operations,
            Keys keys,
            JObject head = null)
        {
            if (head == null)
            {
                head = await GetHeader()
                       .ConfigureAwait(false);
            }

            if (!(operations is JArray arrOps))
            {
                arrOps = new JArray(operations);
            }

            var forgedOpGroup = await ForgeOperations(head, arrOps)
                                .ConfigureAwait(false);

            SignedMessage signedOpGroup;

            if (keys == null)
            {
                signedOpGroup = new SignedMessage
                {
                    SignedBytes      = forgedOpGroup + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
                    EncodedSignature = "edsigtXomBKi5CTRf5cjATJWSyaRvhfYNHqSUGrn4SdbYRcGwQrUGjzEfQDTuqHhuA8b2d8NarZjz8TRf65WkpQmo423BtomS8Q"
                };
            }
            else
            {
                var privateKey = Base58Check.Decode(keys.DecryptPrivateKey(), Prefix.Edsk);

                signedOpGroup = TezosSigner.SignHash(
                    data: Hex.FromString(forgedOpGroup.ToString()),
                    privateKey: privateKey,
                    watermark: Watermark.Generic,
                    isExtendedKey: privateKey.Length == 64);

                privateKey.Clear();
            }

            var opResults = await PreApplyOperations(head, arrOps, signedOpGroup.EncodedSignature)
                            .ConfigureAwait(false);

            /////deleting too big contractCode from response
            //foreach (var opResult in opResults)
            //{
            //    if (opResult.Data?["metadata"]?["operation_result"]?["status"]?.ToString() == "failed")
            //    {
            //        foreach (JObject error in opResult.Data["metadata"]["operation_result"]["errors"])
            //        {
            //            if (error["contractCode"]?.ToString().Length > 1000)
            //                error["contractCode"] = "";
            //        }
            //    }
            //}

            if (opResults.Any() && opResults.All(op => op.Succeeded))
            {
                var injectedOperation = await InjectOperations(signedOpGroup.SignedBytes)
                                        .ConfigureAwait(false);

                opResults.Last().Data["op_hash"] = injectedOperation.ToString();
            }

            return(opResults);
        }