/// <summary> /// send deploy /// </summary> /// <param name="deploy">deploy data(you can get the deploy data using Util.SignDeploy)</param> /// <returns>the deploy id</returns> public string SendDeploy(DeployDataProto deploy) { var response = client.doDeploy(deploy); if (response.Error != null) { throw new RClientException(response.Error.Messages.ToString()); } //sig of deploy data is deployId return(Util.BytesToHex(deploy.Sig.ToByteArray())); }
private static byte[] GenDeployDataForSig(DeployDataProto deployData) { var data = new DeployDataProto() { Term = deployData.Term, Timestamp = deployData.Timestamp, PhloLimit = deployData.PhloLimit, PhloPrice = deployData.PhloPrice, ValidAfterBlockNumber = deployData.ValidAfterBlockNumber, }; return(data.ToByteArray()); }
public static DeployDataProto SignDeploy(PrivateKey key, string term, long phloPrice = 1, long phloLimit = 1000, long validAfterBlockNo = -1, long timestampMillis = -1) { if (timestampMillis < 0) { timestampMillis = DateTimeToUtc(DateTime.Now); } var data = new DeployDataProto { Deployer = ByteString.CopyFrom(key.PublicKey.Bytes), Term = term, PhloPrice = phloPrice, PhloLimit = phloLimit, ValidAfterBlockNumber = validAfterBlockNo, Timestamp = timestampMillis, SigAlgorithm = "secp256k1", }; var abc = GenDeployDataForSig(data); data.Sig = ByteString.CopyFrom(key.Sign(GenDeployDataForSig(data))); return(data); }
public static bool VerifyDeploy(PublicKey key, byte[] sig, DeployDataProto data) { return(key.Verify(sig, GenDeployDataForSig(data))); }