cburkert / fuzzy-commitment

Python library providing a fuzzy commitment scheme
MIT License
7 stars 4 forks source link

"ValueError: Witness exceeds the given maximum length (1960>240)." #3

Closed Asrar-b closed 4 years ago

Asrar-b commented 4 years ago

Hi,,

can anyone help me? plez,, I want to use FCS and the length of Witness that I have been used is a list with 30 binary elements ( the bit size should be 240) but I got an assertion error about that, said "ValueError: Witness exceeds the given maximum length (1960>240).", thus , the code forces me to enter the t (error capability- tolerance in the code-) greater than 30 (list length) may reach to 120 ! (which is wrong )

and

What dose polynomial mean in BCH(polynomial, tolerance ), is it the same of (n) in BCH(n,k,t) as in the papers?

cburkert commented 4 years ago

The second part first: You've asked the same question in #1 . Please find my answer there.

To the first part: Sounds like your list of elements is not converted into bytes as you might think. If you do not provide a custom extractor FCS uses bytes(...) on your list. Have a look at the result and I guess you'll understand what the error is ;-)

Asrar-b commented 4 years ago

@cburkert thank you so much for your answer.. but, how can I provide a custom extractor for a list? sorry I am new on Python

cburkert commented 4 years ago

@lolib11 I have a test that should demonstrate that nicely. Have a look at https://github.com/cburkert/fuzzy-commitment/blob/master/fcs/test_fcs.py#L69

Asrar-b commented 4 years ago

@cburkert thank you , I got it,,,

Asrar-b commented 4 years ago

@cburkert I apologize for the inconvenience and sorry for these questions ..but , same error came again! I make a custom extractor for a numpy array

def list_extractor(value: np.ndarray) -> BitVector:

    value_bytes = np.ndarray.tobytes(value)

    return BitVector(hexstring=value_bytes.hex())

and I make the object like... cs = fcs.FCS[np.ndarray](30, 3,extractor=list_extractor)

this is my array: `ar=[1. 1. 1. 1. 1. 1. 0. 1. 0. 0. 1. 1. 1. 1. 1. 0. 0. 1. 1. 0. 1. 1. 0. 1.

          1. 1.]` with size =30

the error : ValueError: Witness exceeds the given maximum length (960>30).

could you tell me how can I solve this problem,

cburkert commented 4 years ago

@lolib11 Your error is that you assume that your bit list or rather np.array consists of 1 bit sized elements. That's not the case. There is no 1 bit sized data type in Python or IIRC in numpy. Since you did not provide the dtype of your np.array, I'm not sure, but it seems to be an 32 bit integer. Hence 32*30=960. So the FCS's error is correct. If you want a list of 30 bits, you cannot simply put 30 zeros and ones in a list or array. Consider using the BitVector class directly.

Asrar-b commented 4 years ago

@cburkert thank you for answering... but,,if I use 960 length; the system reject all the users with multiple trails (different n,k and t) and when I use this extractor (below) ; the false rejection become lower.. but I don't know, If it is right or wrong!

the extractor:

def list_extractor2(value: list) -> BitVector:
        return (BitVector(bitlist=value))

what about if I use it? Is it right ( by logic) ? It is work for me,

thank you so much ,,, for your code , and helping me,,

cburkert commented 4 years ago

@lolib11 I fear, I don't know enough about your use case to be able to help you here.