public void KeyGenerationProtocol_PublishKey( IOutputChannel output_channel) { // proof of knowledge [CaS97] for the public key // commitment BigInteger v = mpz_srandom.mpz_srandomm(q); BigInteger t = g.ModPow(v, p); // challenge // Here we use the well-known "Fiat-Shamir heuristic" to make // the PK non-interactive, i.e. we turn it into a statistically // zero-knowledge (Schnorr signature scheme style) proof of // knowledge (SPK) in the random oracle model. BigInteger c = mpz_shash_tools.mpz_shash(new BigInteger [] { g, h_i, t }); // response BigInteger r = c * x_i; r = r.FlipSign(); r += v; r = r % q; output_channel.Send(h_i); output_channel.Send(c); output_channel.Send(r); System.Diagnostics.Debug.WriteLine("g " + g.BitLength() + " h_i " + h_i.BitLength() + " t " + t.BitLength()); }
void CP_Prove( BigInteger x, BigInteger y, BigInteger gg, BigInteger hh, BigInteger alpha, IOutputChannel output_channel, bool fpowm_usage) { BigInteger b; BigInteger c; BigInteger r; BigInteger omega = mpz_srandom.mpz_srandomm(q); // proof of knowledge (equality of discrete logarithms) [CaS97] BigInteger a = g.ModPow(omega, p); b = g.ModPow(omega, p); // challenge // Here we use the well-known "Fiat-Shamir heuristic" to make // the PK non-interactive, i.e. we turn it into a statistically // zero-knowledge (Schnorr signature scheme style) proof of // knowledge (SPK) in the random oracle model. c = mpz_shash_tools.mpz_shash(new BigInteger [] { a, b, x, y, gg, hh }); // response r = c * a; r = r.FlipSign(); r = r + omega; r = r % q; output_channel.Send(c); output_channel.Send(r); }
void PublishGroup( IOutputChannel output_channel) { output_channel.Send(p); output_channel.Send(q); output_channel.Send(g); output_channel.Send(k); }
void VerifiableDecryptionProtocol_Prove( BigInteger c_1, IOutputChannel output_channel) { // compute $d_i = {c_1}^{x_i} \bmod p$ BigInteger d_i = c_1.ModPow(x_i, p); output_channel.Send(d_i); output_channel.Send(h_i_fp); // invoke CP(d_i, h_i, c_1, g; x_i) as prover CP_Prove(d_i, h_i, c_1, g, x_i, output_channel, false); }
public void PublishGroup( IOutputChannel output_channel) { System.Diagnostics.Debug.WriteLine("GrothVSSHE::PublishGroup:p " + p.BitLength()); System.Diagnostics.Debug.WriteLine("GrothVSSHE::PublishGroup:q " + q.BitLength()); System.Diagnostics.Debug.WriteLine("GrothVSSHE::PublishGroup:g " + g.BitLength()); System.Diagnostics.Debug.WriteLine("GrothVSSHE::PublishGroup:h " + h.BitLength()); output_channel.Send(p); output_channel.Send(q); output_channel.Send(g); output_channel.Send(h); com.PublishGroup(output_channel); }
void OR_ProveSecond( BigInteger y_1, BigInteger y_2, BigInteger g_1, BigInteger g_2, BigInteger alpha, IOutputChannel output_channel) { // proof of knowledge ($y_1 = g_1^\beta \vee y_2 = g_2^\alpha$) [CaS97] // 1. choose $v_1, v_2$ and $w\in_R\mathbb{Z}_q$ and compute // $t_1 = y_1^w g_1^{v_1}$ and $t_2 = g_2^{v_2}$ BigInteger v_1 = mpz_srandom.mpz_srandomm(q); BigInteger v_2 = mpz_srandom.mpz_srandomm(q); BigInteger w = mpz_srandom.mpz_srandomm(q); BigInteger t_1 = y_1.ModPow(w, p); BigInteger t_2 = g_2.ModPow(v_2, p); BigInteger tmp = g_1.ModPow(v_1, p); t_1 = t_1 * tmp; t_1 = t_1 % p; // 2. compute $c = \mathcal{H}(g_1, y_1, g_2, y_2, t_1, t_2)$ BigInteger c = mpz_shash_tools.mpz_shash(new BigInteger [] { g_1, y_1, g_2, y_2, t_1, t_2 }); c = c % q; // 3. split the challenge: $c_1 = w$ and $c_2 = c - c_1$ BigInteger c_1 = w; BigInteger c_2 = c - c_1; c_2 = c_2 % q; // 4. forge $r_1 = v_1$ and set $r_2 = v_2 - c_2\alpha$ BigInteger r_1 = v_1 % q; tmp = c_2 * alpha; tmp = tmp % q; BigInteger r_2 = v_2 - tmp; r_2 = r_2 % q; output_channel.Send(c_1); output_channel.Send(c_2); output_channel.Send(r_1); output_channel.Send(r_2); }
public void Send <TData>(BusMessage <TData> busMessage) { DataContractKey contractKey; Type type = typeof(TData); if (!_nameMappings.TryGetValue(type, out contractKey)) { DataContract contract = new DataContract(busMessage.Data); _nameMappings.TryAdd(type, contract.Key); _contractCollector.AddKnownContract(contract); contractKey = contract.Key; } using (Message message = Message.CreateMessage(_messageVersion, MessagingConstants.MessageAction.Regular, busMessage.Data)) { SetBusHeaders(message, contractKey); SetUserHeaders(busMessage, message); _outputChannel.Send(message); } }
private void SendMessage(IOutputChannel channel, string action, bool commit) { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew)) { Message message = Message.CreateMessage(MessageVersion.Default, action); if (this.Parameters.AsyncSend) { IAsyncResult result = channel.BeginSend(message, null, null); channel.EndSend(result); } else { channel.Send(message); } if (commit) { ts.Complete(); } else { Transaction.Current.Rollback(); } } }
static void SendMessages(IOutputChannel clientChannel, Binding binding) { // Send messages to queue: Console.WriteLine("Started sending messages..."); Random rand = new Random(); for (int i = 0; i < SampleManager.NumMessages; ++i) { string sessionName = rand.Next(SampleManager.NumSessions).ToString(); // Creating BrokeredMessageProperty BrokeredMessageProperty property = new BrokeredMessageProperty(); property.SessionId = sessionName; string soapBody = "Order_" + Guid.NewGuid().ToString().Substring(0, 5); property.Label = soapBody; // Creating message and adding BrokeredMessageProperty to the properties bag Message message = Message.CreateMessage(binding.MessageVersion, "SoapAction", soapBody); message.Properties.Add(BrokeredMessageProperty.Name, property); // Sending message clientChannel.Send(message); SampleManager.OutputMessageInfo("Send", message); Thread.Sleep(senderDelay); } Console.WriteLine("Finished sending messages"); }
//入口方法 static void Main(string[] args) { try { //建立自定义的通道栈 BindingElement[] bindingElements = new BindingElement[3]; bindingElements[0] = new TextMessageEncodingBindingElement(); //OneWayBindingElement可以使得传输通道支持数据报模式 bindingElements[1] = new OneWayBindingElement(); bindingElements[2] = new HttpTransportBindingElement(); CustomBinding binding = new CustomBinding(bindingElements); using (Message message = Message.CreateMessage(binding.MessageVersion, "sendMessage", "Message Body")) { //创建ChannelFactory IChannelFactory <IOutputChannel> factory = binding.BuildChannelFactory <IOutputChannel>(new BindingParameterCollection()); factory.Open(); //这里创建IOutputChannel IOutputChannel outputChannel = factory.CreateChannel(new EndpointAddress("http://localhost/InputService")); outputChannel.Open(); //发送消息 outputChannel.Send(message); Console.WriteLine("已经成功发送消息!"); outputChannel.Close(); factory.Close(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { Console.Read(); } }
private void SendMetric(string metricType, string name, string prefix, string value, string postFix = null) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } _outputChannel.Send(PrepareMetric(metricType, name, prefix, value, postFix)); }
public void PublishGroup( IOutputChannel output_channel) { System.Diagnostics.Debug.WriteLine("PedersenCommitmentScheme::PublishGroup:p " + p.BitLength()); System.Diagnostics.Debug.WriteLine("PedersenCommitmentScheme::PublishGroup:q " + q.BitLength()); System.Diagnostics.Debug.WriteLine("PedersenCommitmentScheme::PublishGroup:k " + k.BitLength()); System.Diagnostics.Debug.WriteLine("PedersenCommitmentScheme::PublishGroup:h " + h.BitLength()); output_channel.Send(p); output_channel.Send(q); output_channel.Send(k); output_channel.Send(h); for (int i = 0; i < g.Count; i++) { output_channel.Send(g[i]); } }
private int ProcessOpcodeAndMove(long opcode, Mode nounMode, Mode verbMode, Mode resMode, int ptr) { switch (opcode) { case 1: SetMemory(_memory[ptr + 3], resMode, GetValueByMode(nounMode, _memory[ptr + 1]) + GetValueByMode(verbMode, _memory[ptr + 2])); return(ptr + 4); case 2: SetMemory(_memory[ptr + 3], resMode, GetValueByMode(nounMode, _memory[ptr + 1]) * GetValueByMode(verbMode, _memory[ptr + 2])); return(ptr + 4); case 3: SetMemory(_memory[ptr + 1], nounMode, _input.GetNext()); return(ptr + 2); case 4: _output.Send(GetValueByMode(nounMode, _memory[ptr + 1])); return(ptr + 2); case 5: if (GetValueByMode(nounMode, _memory[ptr + 1]) != 0) { return((int)GetValueByMode(verbMode, _memory[ptr + 2])); } return(ptr + 3); case 6: if (GetValueByMode(nounMode, _memory[ptr + 1]) == 0) { return((int)GetValueByMode(verbMode, _memory[ptr + 2])); } return(ptr + 3); case 7: SetMemory(_memory[ptr + 3], resMode, GetValueByMode(nounMode, _memory[ptr + 1]) < GetValueByMode(verbMode, _memory[ptr + 2]) ? 1 : 0); return(ptr + 4); case 8: SetMemory(_memory[ptr + 3], resMode, GetValueByMode(nounMode, _memory[ptr + 1]) == GetValueByMode(verbMode, _memory[ptr + 2]) ? 1 : 0); return(ptr + 4); case 9: _relativeBase += GetValueByMode(nounMode, _memory[ptr + 1]); return(ptr + 2); default: throw new NotImplementedException($"Invalid value {opcode}"); } }
public async Task Process() { var pipe = _pipeBuilder.Build(); var context = new TextProcessingContext(); await pipe.Send(context); _out.Send(context.ProcessedLines); }
private void SendMessage(object objectToSend) { IChannelFactory <IOutputChannel> channelFactory = Util.GetBinding().BuildChannelFactory <IOutputChannel>(); channelFactory.Open(); IOutputChannel proxy = channelFactory.CreateChannel(new EndpointAddress(Queue)); proxy.Open(); Message toSend = Message.CreateMessage(MessageVersion.Default, string.Empty, objectToSend); proxy.Send(toSend); toSend.Close(); channelFactory.Close(); }
public void Send(Message message, TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); IOutputChannel outputChannel = ValidateStateAndGetOutputChannel(message, timeoutHelper); try { outputChannel.Send(message, timeoutHelper.RemainingTime()); outputChannel.Close(timeoutHelper.RemainingTime()); } finally { outputChannel.Abort(); } }
static void Main(string[] args) { try { Options options = new Options(args); AmqpBinaryBinding binding = new AmqpBinaryBinding(); binding.BrokerHost = options.Broker; binding.BrokerPort = options.Port; binding.TransferMode = TransferMode.Streamed; IChannelFactory <IOutputChannel> factory = binding.BuildChannelFactory <IOutputChannel>(); factory.Open(); try { System.ServiceModel.EndpointAddress addr = options.Address; IOutputChannel sender = factory.CreateChannel(addr); sender.Open(); MyRawBodyWriter.Initialize(options.Content); DateTime end = DateTime.Now.Add(options.Timeout); System.ServiceModel.Channels.Message message; for (int count = 0; ((count < options.Count) || (options.Count == 0)) && ((options.Timeout == TimeSpan.Zero) || (end.CompareTo(DateTime.Now) > 0)); count++) { message = Message.CreateMessage(MessageVersion.None, "", new MyRawBodyWriter()); AmqpProperties props = new AmqpProperties(); props.ContentType = "text/plain"; string id = Guid.NewGuid().ToString() + ":" + count; props.PropertyMap.Add("spout-id", new AmqpString(id)); message.Properties["AmqpProperties"] = props; sender.Send(message); } } finally { factory.Close(); } } catch (Exception e) { Console.WriteLine("Spout: " + e); } }
private void SendMetric(string metricType, string name, string value, string postFix = null) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } _stream.SetLength(_initialPosition); // prefix is already written with dot ending _writer.Write(name); _writer.Write(":"); _writer.Write(value); _writer.Write("|"); _writer.Write(metricType); _writer.Flush(); _outputChannel.Send(_stream.GetBuffer(), (int)_stream.Position); }
private void SendMessage(object objectToSend, AmqpProperties propertiesToSend) { ChannelFactory <IOutputChannel> channelFactory = new ChannelFactory <IOutputChannel>(Util.GetBinding(), SendToUri); IOutputChannel proxy = channelFactory.CreateChannel(); proxy.Open(); Message toSend = Message.CreateMessage(MessageVersion.Default, string.Empty, objectToSend); toSend.Properties["AmqpProperties"] = propertiesToSend; proxy.Send(toSend); toSend.Close(); proxy.Close(); channelFactory.Close(); }
internal override Message RequestCorrelated(Message msg, TimeSpan timeout, IOutputChannel channel) { DateTime startTime = DateTime.Now; Message ret = null; ManualResetEvent wait = new ManualResetEvent(false); Action <Message> handler = delegate(Message reply) { ret = reply; wait.Set(); }; ReplyHandlerQueue.Enqueue(handler); channel.Send(msg, timeout); if (ret == null && !wait.WaitOne(timeout - (DateTime.Now - startTime))) { throw new TimeoutException(); } return(ret); }
static void WarmUpTransactionSubsystem(Options opts) { // see if any use of transactions is expected if ((opts.type == ClientType.Publisher) && (opts.pubTxSize == 0)) { return; } if ((opts.type == ClientType.Subscriber) && (opts.subTxSize == 0)) { return; } if (opts.type == ClientType.InteropDemo) { if ((opts.subTxSize == 0) && (opts.pubTxSize == 0)) { return; } } Console.WriteLine("Initializing transactions"); IRawBodyUtility bodyUtil = new RawEncoderUtility(); // Send a transacted message to nowhere to force the initial registration with MSDTC. // MSDTC insists on verifying it can contact the resource in the manner expected for // recovery. This requires setting up and finishing a separate connection to the // broker by a thread owned by the DTC. Excluding this time allows the existing // reporting mechanisms to better reflect the cost per transaction without requiring // long test runs. IOutputChannel channel = QueueChannelFactory.CreateWriterChannel("amq.direct", Guid.NewGuid().ToString()); Message msg = bodyUtil.CreateMessage("sacrificial transacted message from WcfPerftest"); using (TransactionScope ts = new TransactionScope()) { channel.Send(msg); // abort/rollback ts.Dispose(); } channel.Close(); Console.WriteLine("transaction resource manager ready"); }
public void Should_execute_operations_in_order() { var helper = GetInvocationHelper(); using (_repository.Ordered()) { Expect.Call(() => _messageDispatcher.Register(_responseHandler)); Expect.Call(_channel.Send(Arg <IMessage> .Is.Anything)).Return(true); Expect.Call(() => _responseHandler.WaitForResponse(DefaultConfig.Timeout, CancellationToken.None)); Expect.Call(_responseHandler.HandledMessageType).Return(_handlerId); Expect.Call(() => _messageDispatcher.Unregister(_handlerId)); Expect.Call(_responseHandler.GetValue()); } _repository.ReplayAll(); helper.Item1.Hello(5); _repository.VerifyAll(); }
public override void Dispatch(MessageDelivery messageDelivery) { IOutputChannel channel = CreateChannelFactory().CreateChannel(); bool closed = false; try { channel.Open(); channel.Send(_converter.ToMessage(messageDelivery)); } finally { channel.Close(); closed = true; } if (!closed) { channel.Abort(); } }
static void Main(string[] args) { try { //建立自定义通道栈 BindingElement[] bindingElements = new BindingElement[3]; bindingElements[0] = new TextMessageEncodingBindingElement();//文本编码 //OneWayBindingElement 可以使得传输通道支持数据报模式 bindingElements[1] = new OneWayBindingElement(); //http传输 // bindingElements[2] = new HttpTransportBindingElement(); //命名管道传输 bindingElements[2] = new NamedPipeTransportBindingElement(); CustomBinding binding = new CustomBinding(bindingElements); using (Message message = Message.CreateMessage(binding.MessageVersion, "sendMessage", "Message Body")) //创建消息 { //创建ChannelFactory IChannelFactory <IOutputChannel> factory = binding.BuildChannelFactory <IOutputChannel>(new BindingParameterCollection()); factory.Open();//打开ChannelFactory //创建IoutputChannel IOutputChannel outputChannel = factory.CreateChannel(new System.ServiceModel.EndpointAddress("net.pipe://localhost/InputService")); outputChannel.Open(); //打开通道 outputChannel.Send(message); //发送消息 Console.WriteLine("已经成功发送消息!"); outputChannel.Close(); //关闭通道 factory.Close(); //关闭工厂 } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { Console.Read(); } }
public void Send(Message message, TimeSpan timeout) { _channel.Send(message, timeout); }
public void Send(Message message, TimeSpan timeout) { // Apply the context information before sending the message. this.ApplyContext(message); innerOutputChannel.Send(message, timeout); }
public bool Verify_interactive( List <Tuple <BigInteger, BigInteger> > e, List <Tuple <BigInteger, BigInteger> > E, IInputChannel input_channel, IOutputChannel output_channel) { Debug.Assert(com.g.Count >= e.Count); Debug.Assert(e.Count == E.Count); Debug.Assert(E.Count >= 2); // initialize BigInteger c, c_d, Z, lambda, foo, bar, foo2, bar2, foo3, bar3; Tuple <BigInteger, BigInteger> E_d = new Tuple <BigInteger, BigInteger>(1, 1); List <BigInteger> f = new List <BigInteger>(); List <BigInteger> m = new List <BigInteger>(); List <BigInteger> t = new List <BigInteger>(); for (int i = 0; i < e.Count; i++) { f.Add(0); m.Add(0); t.Add(0); } // verifier: first move c = input_channel.Recieve(); c_d = input_channel.Recieve(); E_d = new Tuple <BigInteger, BigInteger>(input_channel.Recieve(), input_channel.Recieve()); // verifier: second move for (int i = 0; i < t.Count; i++) { t[i] = mpz_srandom.mpz_srandomb(l_e); output_channel.Send(t[i]); } // verifier: third move for (int i = 0; i < f.Count; i++) { f[i] = input_channel.Recieve(); } Z = input_channel.Recieve(); // verifier: fourth move lambda = mpz_srandom.mpz_srandomb(l_e); output_channel.Send(lambda); // verifier: fifth to seventh move (Shuffle of Known Content) /* * This part is not necessary: see personal communication with Jens Groth * // SKC commitment $c^{\lambda} c_d \mathrm{com}(f_1,\ldots,f_n;0) \bmod p$ * mpz_set_ui(bar, 0L); * com.CommitBy(foo, bar, f, false); * mpz_mul(foo, foo, c_d); * mpz_mod(foo, foo, com.p); * mpz_powm(bar, c, lambda, com.p); * mpz_mul(foo, foo, bar); * mpz_mod(foo, foo, com.p); */ // SKC (optimized homomorphic) commitment $c^{\lambda} c_d \bmod p$ foo = c.ModPow(lambda, com.p); foo = foo * c_d; foo = foo % com.p; // SKC messages // $m_i := i \lambda + t_i \bmod q$ for all $i = 1,\ldots, n$ for (int i = 0; i < m.Count; i++) { BigInteger value = i + 1; value *= lambda; value %= com.q; value = value + t[i]; value = value % com.q; m[i] = value; } // perform and verify SKC if (!skc.Verify_interactive(foo, f, m, input_channel, output_channel)) { return(false); } // check whether $c, c_d \in\mathcal{C}_{ck}$ if (!(com.TestMembership(c) && com.TestMembership(c_d))) { return(false); } // check whether $E_d\in\mathcal{C}_{pk}$ foo = E_d.Item1.ModPow(q, p); bar = E_d.Item2.ModPow(q, p); if (foo != 1 || bar != 1) { return(false); } // check whether $2^{\ell_e} \le f_1,\ldots,f_n < q$ for (int i = 0; i < f.Count; i++) { if ((f[i].BitLength() < l_e) || (f[i].CompareTo(com.q) >= 0)) { return(false); } } // check whether $Z\in\mathcal{R}_{pk}$ if ((Z.CompareTo(0) <= 0) || (Z.CompareTo(q) >= 0)) { return(false); } // check whether // $\prod_{i=1}^n e_i^{-t_i} \prod_{i=1}^n E_i^{f_i} E_d = E(1;Z)$ foo2 = 1; bar2 = 1; for (int i = 0; i < e.Count; i++) { t[i] = t[i].FlipSign(); foo = e[i].Item1.ModPow(t[i], p); foo2 = foo2 * foo; foo2 = foo2 % p; bar = e[i].Item2.ModPow(t[i], p); bar2 = bar2 * bar; bar2 = bar2 % p; } foo3 = 1; bar3 = 1; for (int i = 0; i < E.Count; i++) { foo = E[i].Item1.ModPow(f[i], p); foo3 = foo3 * foo; foo3 = foo3 % p; bar = E[i].Item2.ModPow(f[i], p); bar3 = bar3 * bar; bar3 = bar3 % p; } foo3 = foo3 * E_d.Item1; foo3 = foo3 % p; bar3 = bar3 * E_d.Item2; bar3 = bar3 % p; foo3 = foo3 * foo2; foo3 = foo3 % p; bar3 = bar3 * bar2; bar3 = bar3 % p; foo = g.ModPow(Z, p); bar = h.ModPow(Z, p); if (foo3 == foo || bar3 != bar) { return(false); } return(true); }
public void Prove_interactive( List <int> pi, List <BigInteger> R, List <Tuple <BigInteger, BigInteger> > e, List <Tuple <BigInteger, BigInteger> > E, IInputChannel input_channel, IOutputChannel output_channel) { Debug.Assert(com.g.Count >= pi.Count); Debug.Assert(pi.Count == R.Count); Debug.Assert(R.Count == e.Count); Debug.Assert(e.Count == E.Count); Debug.Assert(E.Count >= 2); // initialize BigInteger r, R_d, r_d, c, c_d, Z, lambda, rho, foo, bar; Tuple <BigInteger, BigInteger> E_d; List <BigInteger> d = new List <BigInteger>(); List <BigInteger> f = new List <BigInteger>(); List <BigInteger> m = new List <BigInteger>(); List <BigInteger> t = new List <BigInteger>(); for (int i = 0; i < e.Count; i++) { d.Add(0); f.Add(0); m.Add(0); t.Add(0); } // prover: first move r = mpz_srandom.mpz_srandomm(com.q); R_d = mpz_srandom.mpz_srandomm(q); for (int i = 0; i < d.Count; i++) { d[i] = mpz_srandom.mpz_srandomm(com.q).FlipSign(); } r_d = mpz_srandom.mpz_srandomm(com.q); for (int i = 0; i < m.Count; i++) { m[i] = new BigInteger(pi[i] + 1); } c = com.CommitBy(r, m); c_d = com.CommitBy(r_d, d); E_d = new Tuple <BigInteger, BigInteger>(1, 1); for (int i = 0; i < d.Count; i++) { // Compute and multiply $E_i^{-d_i}$ foo = E[i].Item1.ModPow(d[i], p); BigInteger E_d1 = E_d.Item1; E_d1 = E_d1 * foo; E_d1 = E_d1 % p; bar = E[i].Item2.ModPow(d[i], p); BigInteger E_d2 = E_d.Item2; E_d2 = E_d2 * bar; E_d2 = E_d2 % p; E_d = new Tuple <BigInteger, BigInteger>(E_d1, E_d2); } // Compute and multiply $E(1;R_d)$ foo = g.ModPow(R_d, p); bar = h.ModPow(R_d, p); E_d = new Tuple <BigInteger, BigInteger>((E_d.Item1 * foo) % p, (E_d.Item2 * bar) % p); output_channel.Send(c); output_channel.Send(c_d); output_channel.Send(E_d.Item1); output_channel.Send(E_d.Item2); // prover: second move for (int i = 0; i < f.Count; i++) { t[i] = input_channel.Recieve(); // check whether the $t_i$'s are from $\{0, 1\}^{\ell_e}$ if (t[i].BitLength() > l_e) { t[i] = t[i] % exp2l_e; } } // prover: third move for (int i = 0; i < f.Count; i++) { f[i] = (d[i].FlipSign() + t[pi[i]]) % com.q; } Z = 0; for (int i = 0; i < t.Count; i++) { foo = t[pi[i]] * R[i]; foo = foo % q; Z = Z + foo; Z = Z % q; } Z = Z + R_d; Z = Z % q; for (int i = 0; i < f.Count; i++) { output_channel.Send(f[i]); } output_channel.Send(Z); // prover: fourth move lambda = input_channel.Recieve(); // check whether $\lambda$ is from $\{0, 1\}^{\ell_e}$, otherwise reduce if (lambda.BitLength() > l_e) { lambda = lambda % exp2l_e; } // prover: fifth to seventh move (Shuffle of Known Content) // $\rho := \lambda r + r_d \bmod q$ rho = lambda * r; rho = rho % com.q; rho = rho * r_d; rho = rho % com.q; /* * This part is not necessary: see personal communication with Jens Groth * // SKC commitment $c^{\lambda} c_d \mathrm{com}(f_1,\ldots,f_n;0) \bmod p$ * mpz_set_ui(bar, 0L); * com.CommitBy(foo, bar, f, false); * mpz_mul(foo, foo, c_d); * mpz_mod(foo, foo, com.p); * mpz_powm(bar, c, lambda, com.p); * mpz_mul(foo, foo, bar); * mpz_mod(foo, foo, com.p); */ // SKC messages $m_i := i \lambda + t_i \bmod q$ for all $i = 1,\ldots, n$ for (int i = 0; i < m.Count; i++) { BigInteger value = i + 1; value = value + lambda; value = value % com.q; value = value + t[i]; value = value % com.q; m[i] = value; } skc.Prove_interactive(pi, rho, m, input_channel, output_channel); }
internal override Message RequestCorrelated (Message msg, TimeSpan timeout, IOutputChannel channel) { DateTime startTime = DateTime.Now; Message ret = null; ManualResetEvent wait = new ManualResetEvent (false); Action<Message> handler = delegate (Message reply) { ret = reply; wait.Set (); }; ReplyHandlerQueue.Enqueue (handler); channel.Send (msg, timeout); if (ret == null && !wait.WaitOne (timeout - (DateTime.Now - startTime))) throw new TimeoutException (); return ret; }
static void Main(string[] args) { // Creating the Channel string channelName = "EMailHelloWorld"; string serverAddress = "*****@*****.**"; string serverPWD = "MyPassword"; string clientAddress = "*****@*****.**"; string exchangeServerLocation = "http://example.com"; ExchangeWebServiceMailBinding binding = new ExchangeWebServiceMailBinding( new Uri(exchangeServerLocation), new System.Net.NetworkCredential(serverAddress, serverPWD)); BindingParameterCollection parameters = new BindingParameterCollection(); IChannelListener <IInputChannel> listener = binding.BuildChannelListener <IInputChannel> (MailUriHelper.CreateUri(channelName, ""), parameters); listener.Open(); // Opening the Channel IInputChannel inputChannel = listener.AcceptChannel(); inputChannel.Open(TimeSpan.MaxValue); Console.WriteLine("Channel Open"); // Waiting and receiving the Message Message reply = inputChannel.Receive(TimeSpan.MaxValue); Console.WriteLine("Message Recieved"); XmlSerializerWrapper wrapper = new XmlSerializerWrapper( typeof(TransmittedObject)); TransmittedObject to = reply.GetBody <TransmittedObject>(wrapper); // Processing the Message to.str = to.str + " World"; to.i = to.i + 1; Console.WriteLine("Response: " + to.str + " " + to.i.ToString()); // Creating and returning the Message Message m = Message.CreateMessage(binding.MessageVersion, "urn:test", to, wrapper); IChannelFactory <IOutputChannel> channelFactory = binding.BuildChannelFactory <IOutputChannel>(parameters); channelFactory.Open(); IOutputChannel outChannel = channelFactory.CreateChannel( new EndpointAddress( MailUriHelper.CreateUri(channelName, clientAddress))); outChannel.Open(); Console.WriteLine("Out Channel Open"); // Sending the Message over the OutChannel outChannel.Send(m); Console.WriteLine("Message Sent"); // Cleaning up outChannel.Close(); channelFactory.Close(); listener.Close(); inputChannel.Close(); binding.Close(); }
protected virtual void OnSend(Message message, TimeSpan timeout) { inner.Send(message, timeout); }