codecryptanalysis / mccl

modular code cryptanalysis library
MIT License
8 stars 3 forks source link

How to use m4ri #17

Closed qc20000sj closed 1 month ago

qc20000sj commented 1 month ago

I want to use m4ri in test_dumer.cpp ,for example mzd_t* h=mzd_init(1,2). What should I do?

cr-marcstevens commented 1 month ago

Is that M4RI code you are writing? Looks more like GMP?

M4RI support is mostly intended for applications that want to use MCCL library with M4RI matrices. Or to use M4RI algorithm implementations on MCCL matrices.

You need to enable M4RI at configure time: ./configure --with-m4ri. You also need to include mccl/core/matrix_m4ri.hpp. Now you can call the functions specified in that header library. The basic concept is that you create a M4RI handle for a MCCL matrix, which you can then use for M4RI functions calls.

qc20000sj commented 1 month ago

I need to search several times, so I want to convert the result ISD_stern_dumer.get_solution() to the mzd_t* in the m4ri library and store it. And I need a lot of operations based on the m4ri library. What should I do?

cr-marcstevens commented 1 month ago

M4RI support is quite experimental, and isn't deeply supported yet. Deep down M4RI and MCCL have very similar memory layout for binary matrices and vectors, so it isn't too hard to make them work together by manually creating handles / views. I don't have much more expertise to help you further, so you'll have to figure some things out yourself. I would suggest to look at everything written in matrix_m4ri.hpp and matrix_m4ri.cpp. If you manage to get better support code for M4RI and MCCL then a PR would be greatly appreciated to further help the community with similar issues.

qc20000sj commented 1 month ago

Thanks for you reply very much. Now I face a problem.When I ues test_mmt.cpp, I set n=10000,w=10, but the program can't find any results. How should I solve this problem?Thank you.

cr-marcstevens commented 1 month ago

Aren't you just giving it a too large problem, and it would take too long to find a solution.

qc20000sj commented 1 month ago

The program reports error results as follows: terminate called after throwing an instance of 'std::runtime_error' what(): ISD_generic::callback: internal error 2: solution is incorrect! And I use test_dumer.cpp, this program can search for results.

qc20000sj commented 1 month ago

I used your program to solve the following problem: Given Code word matrix C, find a vector h, s.t. ChT=0, wt(h)<=w.(Vector hT is the transpose of h). I have solved this problem using the test_dumer.cpp program. I want to see if using test_mmt.cpp will find the desired ground vector h faster. However, when I tried to solve the above problem using the test_mmt.cpp program, I set n=10000,w=10, but the program said: internal error 2: solution is incorrect!

cr-marcstevens commented 1 month ago

This seems a bug in the MMT implementation. Could you start a new issue and give a minimal problematic example (code & data) that we can test and debug?

qc20000sj commented 1 month ago

Ok,Thank you very much.