/// <summary>
        /// Generates a unique signature for this module.
        /// </summary>
        /// <param name="privateKey">The private key that only the developer of this module should know.</param>
        /// <returns>Returns whether or not the signature of the module was successfully generated.</returns>
        public bool GenerateSignature(byte[] privateKey)
        {
            this.PublicKey = Signing.GetPublicKey(privateKey);
            this.Signature = Signing.GenerateSignature(this.CompiledCode, privateKey);

            return(this.Signature != null);
        }
Beispiel #2
0
 public ServerUploader(VectorDescription vectorDescription, CommandHandler cmd)
 {
     try
     {
         if (cmd != null)
         {
             cmd.EventFired += SendEvent;
         }
         var duplicates = vectorDescription._items.GroupBy(x => x.Descriptor).Where(x => x.Count() > 1).Select(x => x.Key);
         if (duplicates.Any())
         {
             throw new Exception("Title of datapoint in vector was listed twice: " + string.Join(", ", duplicates));
         }
         var loopName = IOconfFile.GetLoopName();
         _signing = new Signing(loopName);
         vectorDescription.IOconf = IOconfFile.RawFile;
         _vectorDescription       = vectorDescription;
         _plot = PlotConnection.Establish(loopName, _signing.GetPublicKey(), GetSignedVectorDescription(vectorDescription)).GetAwaiter().GetResult();
         new Thread(() => this.LoopForever()).Start();
         _cmd = cmd;
         cmd?.AddCommand("escape", Stop);
     }
     catch (Exception ex)
     {
         OnError("failed initializing uploader", ex);
         throw;
     }
 }
Beispiel #3
0
        public bool GenerateSignature(byte[] privateKey)
        {
            this.PublicKey = Signing.GetPublicKey(privateKey);

            if (this.CompiledCode == null)
            {
                throw new Exception("Compiled code is null for page: " + this.ID);
            }

            this.Signature = Signing.GenerateSignature(this.CompiledCode, privateKey);
            return(this.Signature != null);
        }