Example #1
0
        public ByzantineBgwProtocol(AsyncParty e, Circuit circuit, ReadOnlyCollection<int> playerIds,
			Zp playerInput, StateKey stateKey)
            : base(e, circuit, playerIds, playerInput, stateKey)
        {
            throw new NotImplementedException();

            // PolynomialDeg = NumParties % 4 == 0 ? (NumParties / 4 - 1) : (NumParties / 4);
            // Mahdi: Changed to the following since n/3 - 1 of players can be dishonest.
            // degree = n - t, where t is the number of dishonest players
            PolynomialDeg = (int)Math.Floor(2 * NumParties / 3.0);
        }
Example #2
0
        public virtual void Parse()
        {
            StreamReader reader;
            if (File.Exists(pathOrString))
                reader = new StreamReader(pathOrString);
            else
                reader = new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(pathOrString)));

            varsToWires = new Dictionary<string, Wire>();
            string line = null;
            int lineNumber = 0;
            while (!reader.EndOfStream)
            {
                line = reader.ReadLine();
                if (line == null)
                    break;

                int commentIndex = line.IndexOf("//");
                if (commentIndex != -1)
                    line = line.Substring(0, commentIndex);

                try
                {
                    ReadLine(line.Trim().Replace("\t", ""));	// remove white spaces
                    lineNumber++;
                }
                catch (Exception e)
                {
                    throw new Exception("Error in line " + lineNumber + "\n" + e.Message);
                }
            }
            outputWire = GetWireFromString(outputVar);
            outputWire.IsOutput = true;
            circuit = CreateCircuit(prime, inputs);
            if (circuit == null)
                throw new Exception("Error in parsing the circuit!");
        }