Skip to content

Commit e165a07

Browse files
authored
Merge pull request r3kapig#18 from crazymanarmy/master
update dicectf 2023
2 parents 329c93b + bcc7882 commit e165a07

File tree

2 files changed

+8
-88
lines changed

2 files changed

+8
-88
lines changed

20230206-DiceCTF2023-CN/README.md

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,37 +1169,13 @@ if __name__ == '__main__':
11691169
11701170
### Membrane:
11711171
1172-
一开始,我想要去直接LLL出来"e"s(which is in [-10,10]) : $pk_b= pk_A * S+ 257 * e \pmod{q}$
1173-
1174-
为了让目标向量足够小,我这么做: $new\_pk_b=pk_b*(p^{-1})\pmod{q},new\_pk_A=pk_A*(p^{-1})\pmod{q}$
1175-
1176-
那么 $|new\_pk_A\cdot S-new\_pk_b|<10$, 但是格子规模太大了,同时目标向量不是足够小
1177-
1178-
大约 1000 个维度.....XD
1179-
1180-
用了巨久去找一些奇怪的问题, 最后, 我发现每个A 满足线性关系: $c_{i} \cdot pk_A = A$, $pk_A$ 是 612*512的一个矩阵
1181-
1182-
![](https://i.imgur.com/4W3zLbc.png)
1172+
![](https://i.imgur.com/2BDPfju.png)
11831173
11841174
**关键点来了:**
11851175
1186-
$pk_A$ 的最后 100 行可以被前面 512 行线性表示
1187-
1188-
$pk_{A,i-1}$ : the i-th row of $pk_A$. $pk_{A,i-1}=pk_{A,i-1},i\in[1,512]$ ; $pk_{A,i-1}=\sum_{j=0}^{511}x_{i,j}\cdot pk_{A,j-1},i\in[513,612]$
1189-
1190-
于是用最新的表达方式表示 $pk_A$. $pk_A$ 就只有512个分量了 新关系式如下
1191-
1192-
$$c\text{fake}_i = k_i+\sum_{j=512}^{611} k_j\cdot x_{i,j}\pmod{q}\Rightarrow -k_i = -c\text{fake}_i+\sum_{j=512}^{611} k_j\cdot x_{i,j}\pmod{q}$$
1193-
1194-
对于真正的 c, $c_i=k_i\i\set{0,-1,1}$ ,用了100条 (可能50条就够) 关系去构造格子 $\mathcal{L}$ (201*201, like knapsack,SIS)
1195-
1196-
![](https://i.imgur.com/aOxFjOk.png)
1176+
![](https://i.imgur.com/mK44OTN.png)
11971177
1198-
LLL这个格子以后可以得到目标向量 $(k_{512},\dots,k_{611},-1,k_{0},\dots,k_{99})$
1199-
1200-
接着使用 $(k_{512},\dots,k_{611})$ 计算出来 $(k_{0},\dots,k_{511})$. 就得到了真正的c
1201-
1202-
![](https://i.imgur.com/2Hbwazh.png)
1178+
![](https://i.imgur.com/p2IdvkX.png)
12031179
12041180
然后即可解密拿到flag:
12051181
@@ -1328,22 +1304,7 @@ enc0, enc1 = alice.encrypt(mask)
13281304
13291305
**OT-csidh**:
13301306
1331-
$$pub_0=[priv0]base,pub1=[priv1]base,ssi=[-privi]mask$$
1332-
1333-
$$enc_0=m_0\oplus ss_0,enc_1=m_1\oplus ss_1,flag=m_0\oplus m_1$$
1334-
1335-
If choose mask=pub0,then
1336-
1337-
![](https://i.imgur.com/qbeRDcO.png)
1338-
1339-
为了让题目比较神奇一点,我们使用 mask == libcsidh.base,
1340-
然后 ss = apply_iso(clibcsidh.base,-priv),pub = apply_iso(clibcsidh.base,priv)
1341-
1342-
$$ss = [a]^{-1}\text{base},pub=[a]\text{base}$$
1343-
1344-
但是笔者并不理解csidh, 所以尝试去猜测 ss 和 pub 是否有什么代数关系
1345-
1346-
然后发现 $ss=-pub\pmod{p}$
1307+
![](https://i.imgur.com/21wUr7V.png)
13471308
13481309
**Note:** 小端序 !
13491310

20230206-DiceCTF2023-EN/README.md

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,39 +1193,13 @@ if __name__ == '__main__':
11931193
11941194
### Membrane:
11951195
1196-
In the beginning, I wanted to get "e"s(which is in [-10,10]) : $pk_b= pk_A * S+ 257 * e \pmod{q}$
1197-
1198-
In order to make the target small, I did this: $new\_pk_b=pk_b*(p^{-1})\pmod{q},new\_pk_A=pk_A*(p^{-1})\pmod{q}$ Then $|new\_pk_A\cdot S-new\_pk_b|<10$
1199-
1200-
but the Lattice is too large to be LLL & target is not small enough.
1201-
1202-
The Lattice is about 1000 dimensions.....XD
1203-
1204-
I spent 4 hours trying to find something odd.. Finally, I found that every A satisfying this LINEAR RELATIONSHIP: $c_{i} \cdot pk_A = A$ , $pk_A$ is matrix 612*512...
1205-
1206-
![](https://i.imgur.com/rbdPS1h.png)
1196+
![](https://i.imgur.com/yIpffoK.png)
12071197
12081198
**Here comes the key point.**
12091199
1210-
The last 100 rows can be linearly represented by the former 512 rows in matrix $pk_A$.
1211-
1212-
$pk_{A,i-1}$ : the i-th row of $pk_A$. $pk_{A,i-1}=pk_{A,i-1},i\in[1,512]$ ; $pk_{A,i-1}=\sum_{j=0}^{511}x_{i,j}\cdot pk_{A,j-1},i\in[513,612]$
1213-
1214-
So get new expressions of 100 rows of $pk_A$.. $pk_A$ is just 512 components.
1215-
1216-
New relationship comes out.
1217-
1218-
$$c\text{fake}_i = k_i+\sum_{j=512}^{611} k_j\cdot x_{i,j}\pmod{q}\Rightarrow -k_i = -c\text{fake}_i+\sum_{j=512}^{611} k_j\cdot x_{i,j}\pmod{q}$$
1219-
1220-
For real c, $c_i=k_i\i\set{0,-1,1}$ ,I use 100 (maybe 50 is enough) relationships to build Lattice $\mathcal{L}$ (201*201, like knapsack,SIS).
1200+
![](https://i.imgur.com/373pYyo.png)
12211201
1222-
![](https://i.imgur.com/aOxFjOk.png)
1223-
1224-
Then we can get the target vector $(k_{512},\dots,k_{611},-1,k_{0},\dots,k_{99})$ .
1225-
1226-
Finally, use $(k_{512},\dots,k_{611})$ can compute $(k_{0},\dots,k_{511})$ . So we get the real c.
1227-
1228-
![](https://i.imgur.com/2Hbwazh.png)
1202+
![](https://i.imgur.com/YeM6SdZ.png)
12291203
12301204
Haha, decrypt it and get the flag!(but I spent 3 hours debugging this.. T_T....)
12311205
@@ -1354,22 +1328,7 @@ enc0, enc1 = alice.encrypt(mask)
13541328
13551329
**OT-csidh:**
13561330
1357-
$$pub_0=[priv0]base,pub1=[priv1]base,ssi=[-privi]mask$$
1358-
1359-
$$enc_0=m_0\oplus ss_0,enc_1=m_1\oplus ss_1,flag=m_0\oplus m_1$$
1360-
1361-
If choose mask=pub0,then
1362-
1363-
![](https://i.imgur.com/qbeRDcO.png)
1364-
1365-
To find something odd, we choose mask == libcsidh.base,
1366-
then ss = apply_iso(clibcsidh.base,-priv),pub = apply_iso(clibcsidh.base,priv)
1367-
1368-
$$ss = [a]^{-1}\text{base},pub=[a]\text{base}$$
1369-
1370-
But idk csidh, so try to guess if ss and pub have any algebraic relationship.
1371-
1372-
Then find $ss=-pub\pmod{p}$.
1331+
![](https://i.imgur.com/5iuhjNY.png)
13731332
13741333
**Note:** The pub and ss are little-endian storage.
13751334

0 commit comments

Comments
 (0)