本文整理汇总了C++中CConfig::GetCircCreateName方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfig::GetCircCreateName方法的具体用法?C++ CConfig::GetCircCreateName怎么用?C++ CConfig::GetCircCreateName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConfig
的用法示例。
在下文中一共展示了CConfig::GetCircCreateName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
void CClient::Init()
{
// circuit
CConfig* cf = CConfig::GetInstance();
// random
sha1_context sha;
sha1_starts(&sha);
sha1_update(&sha, (BYTE*) cf->GetSeed().c_str(), cf->GetSeed().length());
sha1_finish(&sha, m_aSeed);
m_nCounter = 1;
if( !cf->GetCircFileName().empty() )
{
m_pCircuit = LOAD_CIRCUIT_BIN(cf->GetCircFileName().c_str());
if(!m_pCircuit)
{
cout << "failure in loading circuit " << cf->GetCircFileName() << endl;
return;
}
}
else
{
m_pCircuit = CREATE_CIRCUIT(cf->GetNumParties(), cf->GetCircCreateName(), cf->GetCircCreateParams() );
}
m_pGates = m_pCircuit->Gates();
m_nNumGates = m_pCircuit->GetNumGates();
m_nGateStart = m_pCircuit->GetGateStart();
// bind the constant
m_pGates[0].val = 0;
m_pGates[1].val = 1;
// bind the input
int nBits = m_pCircuit->GetNumVBits(ID_CLIENT);
int nStart = m_pCircuit->GetInputStart(ID_CLIENT);
int nEnd = m_pCircuit->GetInputEnd(ID_CLIENT);
vector<int> vIn;
CConfig::GetInstance()->GetInput(vIn);
int nInputs = vIn.size();
int j=nStart;
for( int i=0; i<nInputs && j <=nEnd; i++ )
{
for(int k=0; k<nBits && j<=nEnd; k++ )
{
int mask = (1 << k );
m_pGates[j++].val = !!(vIn[i] & mask);
}
}
// yao
m_pYaoKeys = new KEY[m_nNumGates];
m_pYaoGates = new YAO_GARBLED_GATE[m_nNumGates-m_nGateStart+1];
m_nGatesDone = -1;
m_bOTDone = FALSE;
m_bOutKeysReady = FALSE;
// batch
m_nGateBatch = NUM_GATE_BATCH;
m_nKeyBatch = NUM_KEY_BATCH;
// IKNP
int nNumInputBits = m_pCircuit->GetInputEnd(ID_CLIENT) - m_pCircuit->GetInputStart(ID_CLIENT) + 1;
m_T.resize(NUM_EXECS_NAOR_PINKAS);
for(int i=0; i<NUM_EXECS_NAOR_PINKAS; i++)
m_T[i].Create(nNumInputBits, m_aSeed, m_nCounter );
}
示例2: Init
BOOL CServer::Init()
{
// circuit
CConfig* cf = CConfig::GetInstance();
int nInputs = cf->GetNumInputs();
if( !cf->GetCircFileName().empty() )
{
m_pCircuit = LOAD_CIRCUIT_BIN(cf->GetCircFileName().c_str());
if(!m_pCircuit)
{
cout << "failure in loading circuit " << cf->GetCircFileName() << endl;
return FALSE;
}
}
else
{
m_pCircuit = CREATE_CIRCUIT(cf->GetNumParties(), cf->GetCircCreateName(), cf->GetCircCreateParams() );
}
m_pGates = m_pCircuit->Gates();
m_nNumGates = m_pCircuit->GetNumGates();
// bind the constant
m_pGates[0].val = 0;
m_pGates[1].val = 1;
// bind the input
int nBits = m_pCircuit->GetNumVBits(ID_SERVER);
int nStart = m_pCircuit->GetInputStart(ID_SERVER);
int nEnd = m_pCircuit->GetInputEnd(ID_SERVER);
vector<int> vIn;
CConfig::GetInstance()->GetInput(vIn);
//cout << "s=" << nStart << " e= " << nEnd << endl;
int j=nStart;
for( int i=0; i<nInputs && j <=nEnd; i++ )
{
for(int k=0; k<nBits && j<=nEnd; k++ )
{
int mask = (1 << k );
m_pGates[j++].val = !!(vIn[i] & mask);
}
}
#ifdef _DEBUG
if( nInputs == 10 )
{
j = nStart;
for( int i=0; i<nInputs; i++ )
{
cout << "id[" << i << "]: ";
for(int k=0; k<nBits; k++ )
{
cout << (int) m_pGates[j].val;
j++;
}
cout << endl;
}
assert(j == nEnd+1);
int i= m_pCircuit->GetInputStart(ID_CLIENT);
m_pGates[i++].val = 0;
m_pGates[i++].val = 0;
m_pGates[i++].val = 1;
m_pGates[i++].val = 0;
m_pGates[i++].val = 0;
m_pGates[i++].val = 1;
m_pGates[i++].val = 1;
m_pGates[i++].val = 0;
m_pGates[i++].val = 0;
m_pGates[i++].val = 0;
m_pCircuit->Evaluate();
}
#endif
// yao
m_pYaoWires = new YAO_WIRE[m_nNumGates];
m_pYaoGates = new YAO_GARBLED_GATE[m_nNumGates - m_pCircuit->GetGateStart()];
m_vOutGates.reserve(1024);
m_nGatesDone = -1;
m_nWiresDone = -1;
// randomness
sha1_context sha;
sha1_starts(&sha);
sha1_update(&sha, (BYTE*) cf->GetSeed().c_str(), cf->GetSeed().length());
sha1_finish(&sha, m_aSeed);
m_nCounter = 1;
// batch parameters
m_nGateBatch = NUM_GATE_BATCH;
m_nKeyBatch = NUM_KEY_BATCH;
//.........这里部分代码省略.........