Problems in ot_store
maths644311798 opened this issue · 2 comments
(1) In /crypto/primitives/ot/ot_store, SliceBase::ConsistencyCheck()
:
YACL_ENFORCE(internal_buf_size_ > internal_buf_ctr_, "Slice out of range!");
If the buf is fully used, then internal_buf_ctr_
should equal internal_buf_size_
. Actually, the Reset()
function makes internal_buf_ctr_= internal_buf_size_
hold. YACL_ENFORCE(internal_buf_size_ > internal_buf_ctr_
should be YACL_ENFORCE(internal_buf_size_ >= internal_buf_ctr_
.
(2) In OtSendStore::GetBlock
,
uint128_t OtSendStore::GetBlock(uint64_t ot_idx, uint64_t msg_idx) const {
YACL_ENFORCE(msg_idx == 0 || msg_idx == 1);
const uint64_t ot_blk_num = (type_ == OtStoreType::Compact) ? 1 : 2;
if (delta_ == 0) { // rot must be normal mode
return blk_buf_->operator[](GetBufIdx(2 * ot_idx) + msg_idx);
} else { // cot could be normal mode or compact mode
return blk_buf_->operator[](GetBufIdx(ot_blk_num * ot_idx)) ^
(delta_ * msg_idx);
}
}
In the normal mode for COT, for a specific slice, GetBlock[]
never visits blk_buf_->[](2k+1)
, where k is an integer. Half of the buffer is wasted. Should COT only have compact mode?
Thanks for your comments.
YACL_ENFORCE(internal_buf_size_ > internal_buf_ctr_ should be YACL_ENFORCE(internal_buf_size_ >= internal_buf_ctr_
Yes, internal_buf_ctr_
could be equal to internal_buf_size_
. When it happens, the corresponding ot_store
might not be able to generate a NextSlice
, but it is still considered a valid state.
Should COT only have compact mode?
Good idea. In the initial design phase, we think we might support converting a CotSendStore
to a RotSendStore
. For this reason, normal mode COT could transform into ROT through ParaCrHashInplace
without extra memory allocation.
By the way, we would redesign ot_store
in recent times. :)
I would like to pull a request for fixing some typos and deleting #include "yacl/crypto/primitives/ot/gywz_ote.h"
in gywz_ote.h.