Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0525a52
push original file from Dr.Duan
SheldonHH Dec 10, 2021
4e75a72
add Original_Dr.Duan
SheldonHH Dec 13, 2021
b4c8ffa
add comment to Dr.Duans original works
SheldonHH Dec 13, 2021
8281195
Data, Shares, checksumCoefficient[][], peerProof+serverProof, server.…
SheldonHH Dec 13, 2021
c9e451a
set nLoops=1
SheldonHH Dec 13, 2021
9fc2842
set 🐢 in 2.1 uv.setCheckCoVector; 3.2 pv.setCheckCoVector; 6.server…
SheldonHH Dec 13, 2021
bcd30aa
record before 2nd VectorAdd(s, peerSum, s, F), after Util.vectorAdd(s…
SheldonHH Dec 13, 2021
381c6b4
BL and CLA2l
SheldonHH Dec 13, 2021
242b918
BL CLA2L
SheldonHH Dec 13, 2021
2b3eefe
add ssBL to monitor the change of SquareSum.bitLength()
SheldonHH Dec 13, 2021
ede3588
if ssBL finally =84<86, then numBits=86, hence bcProof.length<=CLA2L,…
SheldonHH Dec 13, 2021
fce7e3e
add challenger_vector index checker in construct()
SheldonHH Dec 13, 2021
ea3ceaa
current Error
SheldonHH Dec 13, 2021
d5f83ec
fix read data from file
SheldonHH Dec 13, 2021
d00d9d2
Added BitCommitmentProof[19].drawio.pdf
SheldonHH Dec 13, 2021
d30b24b
Added Protocol-Page-1.drawio.pdf
SheldonHH Dec 13, 2021
15b28da
add image
SheldonHH Dec 13, 2021
68a623a
rename
SheldonHH Dec 14, 2021
c70607d
add UserTemp
SheldonHH Dec 16, 2021
9ae6e95
restructure package
SheldonHH Dec 17, 2021
b8340bc
add source
SheldonHH Dec 17, 2021
5a0e3e6
remove img
SheldonHH Dec 17, 2021
918d238
add docker run command
SheldonHH Dec 17, 2021
c7027ab
Update README.md
SheldonHH Dec 21, 2021
0630bde
Update README.md
SheldonHH Dec 21, 2021
b09df12
restructure and set config https://postimg.cc/w7dmCYL9
Dec 21, 2021
2deaddc
Merge branch 'restructure' of https://github.com/sheldonhh/p4p into r…
Dec 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 94 additions & 0 deletions Docker_Setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# VSCode连接远程服务器里的docker容器
Source: https://zhuanlan.zhihu.com/p/361934730
[doubleZ](https://www.zhihu.com/people/doubleZ0108)

北京大学信息工程学院硕士在读

关注他

18 人赞同了该文章

以下以`testimage`镜像作为例子

## 在服务器容器中配置ssh

1. 通过一个其他的端口进入容器,这里使用6789端口

```bash
sudo docker run -it -d -p 5920:22 p4p:v1
```

2. 下载openssh

```bash
apt-get update
apt-get install openssh-server
```

3. 设置root密码

```bash
passwd
```

4. 然后设置两遍相同的密码,之后登陆的时候要用到! 4. 修改配置文件

```bash
vim /etc/ssh/sshd_config
```

5. 注释掉 `PermitRootLogin prohibit-password` 这一行 添加这一行 `PermitRootLogin yes`5. 重启ssh服务

```bash
service ssh restart
# 或使用
# /etc/init.d/ssh restart
```

6. 本机连接ssh

```bash
ssh -p 6789 [email protected]
```

7. 远程访问服务器docker里正在运行的容器

```bash
ssh -p 6789 [email protected]
```

【**报错**:ssh: connect to host 0.0.0.0 port 6789: Connection refused】

**原因**:没有开放对应端口

**解决方案**:在主机上

```text
sudo iptables -I INPUT -p tcp --dport 6789 -j ACCEPT
```

## 在自己电脑上配置vscode

1. 本地安装openssh,我用的是mac

```bash
brew install openssh
```

2. vscode中下载Remote-SSH插件

![img](https://pic4.zhimg.com/80/v2-fdfe4989f3f90199089f9b5b9967e40f_720w.jpg)

3. 使用插件连接远程服务器里的容器

![img](https://pic3.zhimg.com/80/v2-8c24b535b938337c7ad6e1744cbe92d2_720w.jpg)



> 注:之前一直用的是Remote-Container,以为可以更方便的连接到服务器里的docker,屡次尝试都不成功,查了些其他人的博客说Remote-Container只能连接本地自己电脑里的docker emmmm…

## Resources

- [Docker Ubuntu上安装ssh和连接ssh_JustToFaith-CSDN博客](https://link.zhihu.com/?target=https%3A//blog.csdn.net/qq_43914736/article/details/90608587)
- [VSCode+Docker: 打造最舒适的深度学习环境 - 知乎](https://zhuanlan.zhihu.com/p/80099904)
- [VSCode中利用Remote SSH插件远程连接服务器并进行远程开发_lenfranky的博客-CSDN博客](https://link.zhihu.com/?target=https%3A//blog.csdn.net/lenfranky/article/details/89972889)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## P4P Credit to [Dr. Yitao Duan](https://scholar.google.com/citations?user=p0L7kOkAAAAJ&hl=en&oi=ao) and [Dr. John Canny](https://scholar.google.com/citations?user=LAv0HTEAAAAJ&hl=en&oi=ao) from UC Berkeley
https://bid.berkeley.edu/projects/p4p/

![Draw by Sheldon](https://github.com/SheldonHH/p4p/blob/restructure/docs_images/6.Protocol.png?raw=true)
![4 Steps](https://github.com/SheldonHH/p4p/blob/restructure/docs_images/5StepspublishAPrime_UpdateA.png)
### Code originate from
http://bid.berkeley.edu/projects/p4p/p4p/code/p4p.tar.gz

Expand Down
8 changes: 4 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ o Interesting classes/packages:

- p4p.crypto: includes a number of commitment schemes and their
zero-knowledge proofs.
- p4p.user.UserVector2: implements the ZKP that the user vector's L2-norm
- UserVector2: implements the ZKP that the user vector's L2-norm
is bounded by a constant L. Used to restrict the influence a malicious
user could have on the computation.
- p4p.sim: includes simulation samples for the P4P computation.
Expand All @@ -34,15 +34,15 @@ run with

./bin/p4p classname

For example, to run the p4p.user.UserVector2 testing code, which tests the
For example, to run the UserVector2 testing code, which tests the
L2-norm ZKP, type

./bin/p4p p4p.user.UserVector2
./bin/p4p UserVector2

Each class can be invoked with various options. Please see the source code
of the corresponding class for details. For example, the following command

./bin/p4p p4p.user.UserVector2 -k 1024 -l 20
./bin/p4p UserVector2 -k 1024 -l 20

starts testing the L2-norm ZKP with security parameter 1024 and a 20-bit L.
The system has some pre-generated parameters for the case of k = 1024 so
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
private long[] s = null; // The accumulated vector sum
private long[] peerSum = null; // The peer's share of the vector sum


before 2nd VectorAdd(s, peerSum, s, F), after Util.vectorAdd(s, u, s, F)
s=[423415934382092800, -63743772828146432, 1437938452422568960, -827156099394474752, 76182506976720640, -1743276040546728704, -1500102254775153920, 66737688933934848, -351584170633951488, -235637947241373696]
peerSum=[-423415886871895594, 63743614238569075, -1437938290428259645, 827156229809895151, -76182261736714936, 1743276244504359410, 1500102466478549832, -66737474705362734, 351584355525083225, 235638017818629922]
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
public main(){
for(int i = 0; i < x.length; i++) {
// First make sure the checksums are computed correctly:
if(x[i] != Util.mod(Util.innerProduct(c[i], u), F)) {
// We are doing server
return false;
}
// Now check if the modular correctors, the Bs, are computed correctly
if(!B[i].equals(tcProofs[i].getCommitment()[0])) {
return false;
}
// Check the 3-way proofs
if(!tc.verify(tcProofs[i])) {
return false;
}
X[i] =
cm.commit(new BigInteger(new Long(x[i]).toString()).mod(q),
// The checksum
r[i]); // The randomness
S[i] = X[i].multiply(B[i]).mod(p).multiply(Y[i]).mod(p);
}

// Next check that the sum of squares does not have excessive bits:
if(bcProofs.length > Integer.toBinaryString(c.length).length()+2*l) {
System.out.println("Sum of squares has too many bits: "
+ bcProofs.length
+ ", the limit is "
+ (Integer.toBinaryString(c.length).length()+2*l));
return false;
}

// Check the square proofs:
SquareCommitment sc = new SquareCommitment(g, h);
for(int i = 0; i < scProofs.length; i++) {
// 1st: check that the square commitment encodes the correct
if(!scProofs[i].getCommitment()[0].equals(S[i])) {
return false;
}
// 2nd: Square Verification
if(!sc.verify(scProofs[i])) {
return false;
}
}

BigInteger z = BigInteger.ONE;
for(int i = 0; i < scProofs.length; i++) {
z = z.multiply(scProofs[i].getCommitment()[1]).mod(p); // *= B
}
z = z.multiply(z).mod(p); // commitment[0] actually stores 2X
// Commitment to square sum wasn't computed correctly
if(!l2Proof.getCommitment()[0].equals(z)) {
return false;
}

// Then check each bits
BitCommitment bc = new BitCommitment(g, h);
BigInteger zz = BigInteger.ONE;

DEBUG("Checking " + bcProofs.length + " bit commitments");

BigInteger ZZ = BigInteger.ONE;
for(int i = 0; i < bcProofs.length; i++) {
if(!bc.verify(bcProofs[i])) {
System.out.println("Bit commitment verification " + i
+ " failed.");
return false;
}
BigInteger e = BigInteger.ZERO.setBit(i);

NativeBigInteger Z =
(NativeBigInteger)bcProofs[i].getCommitment()[0];
ZZ = ZZ.multiply(Z.modPow(e, p)).mod(p);
}
// Homomorphism does not hold
if(!ZZ.equals(z)) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
i == 1 || i==2 || i ==3 || i==4 || i==5 || i== 10 || i == 20 || i == 30 || i == 40 || i == 45 || i==46 || i==47 || i==48 || i==49 || i==50
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading