Writeup for matdlp in CrewCTF 2022
I wrote this essay to record my idea for matdlp in CrewCTF 2022
It's a good challenge about Diffie-Hellman key exchange based matrix
This is a discrete logarithm problem on a matrix group,in the first time I find that p-1 is so smooth and Xp is a diagonal matrix , so maybe I can solve that with Pholig-Hellman .
1.Find the exact value of t
A interesting part is the system use a pair of secrete keys , so I can't divide the Xt from UsXtU-s . I try another way by mapped matrix to the determinant .
We know det(AB)=det(A)det(B) and det(U-1)det(U)=1
=>det(UsXtU-s)p=det(Xtp)
∵det(Xtp)=det(Xp)t so we only to solve dlp in F_p . That a good idea , but unfortunately it doesn't solve for t .
The reason is that the p-1 is too smooth , so for a element g in P* , ord(g) may not big enough and we can't get t accurately . Then we need more dlp equation get result of t(mod ord(gi)) . And solve the problem by crt
In this case I chose to use the property that Xp as a diagonal matrix, which means that the parts of Xp are divided into powers of the eigenvalues of A
Later I found the author's explanation for the question

2.Construct a fake Us
If we have got the t , we just need to solve eqution XAX-1=B with knowing A and B .
In linear algebra we learn the invertible transformation matrix P of similar matrix is not unique
So if we only use XAX-1=B as our constraint condition , we have a lot of solutions .
But wheather all solution is effective ?
Suppose we get a solution K satisfy KXtK-1=alice_pubkey , we want to use t1 and K to calculate fake_share=K(bob_pubkey)t1K-1 .
Obviously if we want to match the real key we also need KU=UK
\(K(U^{s_2}X^{t_1t_2}U^{-s_2})K^{-1}=U^{s_2}(KX^{t_1*t_2}K^{-1})U^{-s_2}=U^{s_2}(KX^{t_1}K^{-1})^{t_2}U^{-s_2}=sharekey\)
Finally we just need to solve eqution uX=Au and uU=Uu
By compare all elements of Corresponding rows and columns . We can list the constraint eqution
\(\sum_{i,j=1}^nu_{ik}x_{kj}-\sum_{i,j=1}^na_{ik}u_{kj}=0\)
\(\sum_{i,j=1}^nu_{ik}U_{kj}-\sum_{i,j=1}^nU_{ik}u_{kj}=0\)
and solve linear homogeneous equation set TX=0
Just find T 's kernel !

浙公网安备 33010602011771号