private Transaction signTransaction2Object(byte[] transaction, KeyTriple privateKey) { Transaction transaction1 = Transaction.Parser.ParseFrom(transaction); byte[] rawdata = transaction1.RawData.ToByteArray(); byte[] hash = Sha256.Hash(rawdata); byte[] sign = privateKey.GetSignature(hash); transaction1.Signature.Add(ByteString.CopyFrom(sign)); return(transaction1); }
public static Transaction sign(Transaction transaction, KeyTriple myKey) { byte[] hash = Sha256Keccak.Hash(transaction.RawData.ToByteArray()); // Transaction.Types.Contract listContract = transaction.RawData.Contract; // for (int i = 0; i < listContract.size(); i++) // { byte[] signature = myKey.GetSignature(hash); ByteString bsSign = ByteString.CopyFrom(signature); transaction.Signature.Add(bsSign); //Each contract may be signed with a different private key in the future. // } return(transaction); }
private byte[] signTransaction2Byte(byte[] transactionBytes, KeyTriple privateKey) { Transaction transaction1 = Transaction.Parser.ParseFrom(transactionBytes); byte[] rawdata = transaction1.RawData.ToByteArray(); byte[] hash = Sha256.Hash(rawdata); byte[] sign = privateKey.GetSignature(hash); ByteString byteString = ByteString.CopyFrom(sign); Transaction transaction = transaction1.Clone(); transaction.Signature.Add(byteString); return(transaction.ToByteArray()); }
public Transaction Sign(Transaction transaction, KeyTriple keyTriple) { Transaction transactionBuilderSigned = transaction.Clone(); byte[] hash = Sha256.Hash(transaction.RawData.ToByteArray()); RepeatedField <Transaction.Types.Contract> listContract = transaction.RawData.Contract; for (int i = 0; i < listContract.Count; i++) { // внимание тут подпись нужно смотреть внимательное что переделалось byte[] signatureBytes = keyTriple.GetSignature(hash); ByteString bsSign = ByteString.CopyFrom(signatureBytes); transactionBuilderSigned.Signature .Add(bsSign); //Each contract may be signed with a different private key in the future. } transaction = transactionBuilderSigned.Clone(); return(transaction); }