📄 ida_8cpp-source.html
字号:
00141 <span class="keywordflow">if</span> (m_outputToInput[i] == m_threshold && i * m_threshold <= 1000*1000)00142 {00143 m_v[i].resize(m_threshold);00144 PrepareBulkPolynomialInterpolationAt(field, m_v[i].begin(), m_outputChannelIds[i], &(m_inputChannelIds[0]), m_w.<a class="code" href="class_sec_block.html#_sec_block_with_hinta7">begin</a>(), m_threshold);00145 }00146 }00147 00148 <span class="keywordtype">void</span> RawIDA::AddOutputChannel(word32 channelId)00149 {00150 m_outputChannelIds.push_back(channelId);00151 m_outputChannelIdStrings.push_back(WordToString(channelId));00152 m_outputQueues.push_back(<a class="code" href="class_byte_queue.html">ByteQueue</a>());00153 <span class="keywordflow">if</span> (m_inputChannelIds.size() == m_threshold)00154 ComputeV(m_outputChannelIds.size() - 1);00155 }00156 00157 <span class="keywordtype">void</span> RawIDA::PrepareInterpolation()00158 {00159 assert(m_inputChannelIds.size() == m_threshold);00160 PrepareBulkPolynomialInterpolation(field, m_w.<a class="code" href="class_sec_block.html#_sec_block_with_hinta7">begin</a>(), &(m_inputChannelIds[0]), m_threshold);00161 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<m_outputChannelIds.size(); i++)00162 ComputeV(i);00163 }00164 00165 <span class="keywordtype">void</span> RawIDA::ProcessInputQueues()00166 {00167 <span class="keywordtype">bool</span> finished = (m_channelsFinished == m_threshold);00168 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;00169 00170 <span class="keywordflow">while</span> (finished ? m_channelsReady > 0 : m_channelsReady == m_threshold)00171 {00172 m_channelsReady = 0;00173 <span class="keywordflow">for</span> (i=0; i<m_threshold; i++)00174 {00175 <a class="code" href="class_message_queue.html">MessageQueue</a> &queue = m_inputQueues[i];00176 queue.<a class="code" href="class_buffered_transformation.html#_zlib_decompressorz7_7">GetWord32</a>(m_y[i]);00177 00178 <span class="keywordflow">if</span> (finished)00179 m_channelsReady += queue.<a class="code" href="class_message_queue.html#_message_queuea6">AnyRetrievable</a>();00180 <span class="keywordflow">else</span>00181 m_channelsReady += queue.<a class="code" href="class_message_queue.html#_message_queuea10">NumberOfMessages</a>() > 0 || queue.<a class="code" href="class_message_queue.html#_message_queuea5">MaxRetrievable</a>() >= 4;00182 }00183 00184 <span class="keywordflow">for</span> (i=0; i<m_outputChannelIds.size(); i++)00185 {00186 <span class="keywordflow">if</span> (m_outputToInput[i] != m_threshold)00187 m_outputQueues[i].PutWord32(m_y[m_outputToInput[i]]);00188 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (m_v[i].size() == m_threshold)00189 m_outputQueues[i].PutWord32(BulkPolynomialInterpolateAt(field, m_y.<a class="code" href="class_sec_block.html#_sec_block_with_hinta7">begin</a>(), m_v[i].begin(), m_threshold));00190 <span class="keywordflow">else</span>00191 {00192 m_u.<a class="code" href="class_sec_block.html#_sec_block_with_hinta23">resize</a>(m_threshold);00193 PrepareBulkPolynomialInterpolationAt(field, m_u.<a class="code" href="class_sec_block.html#_sec_block_with_hinta7">begin</a>(), m_outputChannelIds[i], &(m_inputChannelIds[0]), m_w.<a class="code" href="class_sec_block.html#_sec_block_with_hinta7">begin</a>(), m_threshold);00194 m_outputQueues[i].PutWord32(BulkPolynomialInterpolateAt(field, m_y.<a class="code" href="class_sec_block.html#_sec_block_with_hinta7">begin</a>(), m_u.<a class="code" href="class_sec_block.html#_sec_block_with_hinta7">begin</a>(), m_threshold));00195 }00196 }00197 }00198 00199 <span class="keywordflow">if</span> (m_outputChannelIds.size() > 0 && m_outputQueues[0].AnyRetrievable())00200 FlushOutputQueues();00201 00202 <span class="keywordflow">if</span> (finished)00203 {00204 OutputMessageEnds();00205 00206 m_channelsReady = 0;00207 m_channelsFinished = 0;00208 m_v.clear();00209 00210 vector<MessageQueue> inputQueues;00211 vector<word32> inputChannelIds;00212 00213 inputQueues.swap(m_inputQueues);00214 inputChannelIds.swap(m_inputChannelIds);00215 m_inputChannelMap.clear();00216 m_lastMapPosition = m_inputChannelMap.end();00217 00218 <span class="keywordflow">for</span> (i=0; i<m_threshold; i++)00219 {00220 inputQueues[i].GetNextMessage();00221 inputQueues[i].TransferAllTo(*<a class="code" href="class_filter.html#_zlib_decompressora8">AttachedTransformation</a>(), WordToString(inputChannelIds[i]));00222 }00223 }00224 }00225 00226 <span class="keywordtype">void</span> RawIDA::FlushOutputQueues()00227 {00228 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<m_outputChannelIds.size(); i++)00229 m_outputQueues[i].TransferAllTo(*<a class="code" href="class_filter.html#_zlib_decompressora8">AttachedTransformation</a>(), m_outputChannelIdStrings[i]);00230 }00231 00232 <span class="keywordtype">void</span> RawIDA::OutputMessageEnds()00233 {00234 <span class="keywordflow">if</span> (GetAutoSignalPropagation() != 0)00235 {00236 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<m_outputChannelIds.size(); i++)00237 <a class="code" href="class_filter.html#_zlib_decompressora8">AttachedTransformation</a>()-><a class="code" href="class_buffered_transformation.html#_zlib_decompressorz13_5">ChannelMessageEnd</a>(m_outputChannelIdStrings[i], GetAutoSignalPropagation()-1);00238 }00239 }00240 00241 <span class="comment">// ****************************************************************</span>00242 00243 <span class="keywordtype">void</span> <a class="code" href="class_secret_sharing.html#_secret_sharinga1">SecretSharing::Initialize</a>(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html">NameValuePairs</a> &parameters, <span class="keywordtype">int</span> propagation)00244 {00245 m_pad = parameters.<a class="code" href="class_name_value_pairs.html#_x_t_r___d_ha40">GetValueWithDefault</a>(<span class="stringliteral">"AddPadding"</span>, <span class="keyword">true</span>);00246 m_ida.Initialize(parameters, propagation);00247 }00248 00249 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_secret_sharing.html#_secret_sharinga2">SecretSharing::Put2</a>(<span class="keyword">const</span> byte *begin, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length, <span class="keywordtype">int</span> messageEnd, <span class="keywordtype">bool</span> blocking)00250 {00251 <span class="keywordflow">if</span> (!blocking)00252 <span class="keywordflow">throw</span> BlockingInputOnly(<span class="stringliteral">"SecretSharing"</span>);00253 00254 <a class="code" href="class_sec_block.html">SecByteBlock</a> buf(STDMIN(length, 256U));00255 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> threshold = m_ida.<a class="code" href="class_raw_i_d_a.html#_secret_recoverya2">GetThreshold</a>();00256 <span class="keywordflow">while</span> (length > 0)00257 {00258 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len = STDMIN(length, (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)buf.<a class="code" href="class_sec_block.html#_sec_block_with_hinta13">size</a>());00259 m_ida.<a class="code" href="class_raw_i_d_a.html#_secret_recoverya4">ChannelData</a>(0xffffffff, begin, len, <span class="keyword">false</span>);00260 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<threshold-1; i++)00261 {00262 m_rng.<a class="code" href="class_random_number_generator.html#_x917_r_n_ga4">GenerateBlock</a>(buf, len);00263 m_ida.<a class="code" href="class_raw_i_d_a.html#_secret_recoverya4">ChannelData</a>(i, buf, len, <span class="keyword">false</span>);00264 }00265 length -= len;00266 begin += len;00267 }00268 00269 <span class="keywordflow">if</span> (messageEnd)00270 {00271 m_ida.SetAutoSignalPropagation(messageEnd-1);00272 <span class="keywordflow">if</span> (m_pad)00273 {00274 <a class="code" href="class_buffered_transformation.html#_zlib_decompressorz1_0">SecretSharing::Put</a>(1);00275 <span class="keywordflow">while</span> (m_ida.<a class="code" href="class_raw_i_d_a.html#_secret_recoverya5">InputBuffered</a>(0xffffffff) > 0)00276 <a class="code" href="class_buffered_transformation.html#_zlib_decompressorz1_0">SecretSharing::Put</a>(0);00277 }00278 m_ida.<a class="code" href="class_raw_i_d_a.html#_secret_recoverya4">ChannelData</a>(0xffffffff, NULL, 0, <span class="keyword">true</span>);00279 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<m_ida.<a class="code" href="class_raw_i_d_a.html#_secret_recoverya2">GetThreshold</a>()-1; i++)00280 m_ida.<a class="code" href="class_raw_i_d_a.html#_secret_recoverya4">ChannelData</a>(i, NULL, 0, <span class="keyword">true</span>);00281 }00282 00283 <span class="keywordflow">return</span> 0;00284 }00285 00286 <span class="keywordtype">void</span> <a class="code" href="class_secret_recovery.html#_secret_recoverya1">SecretRecovery::Initialize</a>(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html">NameValuePairs</a> &parameters, <span class="keywordtype">int</span> propagation)00287 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -