encryptogroup / ABY

ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
GNU Lesser General Public License v3.0
463 stars 132 forks source link

Change m_pGates GATE* C array into C++ vector<GATE> #119

Closed sebastianst closed 5 years ago

sebastianst commented 5 years ago

This PR changes the central GATEs data structure from the notorious GATE* m_pGates C array into a std::vector<GATE> m_vGates in the ABYParty class. Since ABYParty as well as all specific sharing type classes (descendants of the Circuit class) used the m_pGates pointer directly, I changed all those pointers into a reference std::vector<GATE>& m_vGates. Note that prior to this change, the array was fixed for the whole lifetime of the ABYCircuit class, so it was safe to access the pointer directly. The underlying array of the vector wrapper may change if the vector grows, so at some places I had to change the access to a cleaner &m_vGates[...] access and couldn't just initialize m_pGates with m_vGates.data().

The upside is that we don't need to know the circuit size in advance but the vector just grows as needed. However, the vector will by default reserve space for 2^16 gates on initialization. This reservation can be controlled as the last argument of the ABYParty contructor. It was maxgates before, which is not necessary any more.