This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.cluster.vq import vq, kmeans | |
from scipy.spatial.distance import cdist | |
import numpy as np | |
class PQ(object): | |
def __init__(self, M, k): | |
self.M = M | |
self.k = k | |
def fit(self, vectors, iter=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.cluster.vq import vq, kmeans | |
import numpy as np | |
class PQ(object): | |
def __init__(self, M, k): | |
self.M = M | |
self.k = k | |
def fit(self, vectors, iter=None): | |
assert vectors.ndim == 2, "vectors must be 2 dim array" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
# https://drive.google.com/file/d/1ZzEouo7lRJvajxK6jLM2K_p9xAwGw1tS/view | |
df = pd.read_csv("clustering.csv") | |
k = 3 | |
epoch = 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import s3fs | |
import pandas as pd | |
import time | |
import polars | |
s3conf = dict( | |
key="<key>", | |
secret="<secret>", | |
client_kwargs={"endpoint_url": "<url>"} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import numpy as np | |
from sympy import nextprime | |
def generate_pk_sk(m, n, q): | |
A = np.random.randint(1, q, size=(m, n)) | |
s = np.random.randint(1, q, n) | |
low = q // ((4*m) + 1) | |
e = np.random.randint(-low, low, m) | |
B = (A @ s + e) % q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyarrow as pa | |
import pyarrow.csv | |
import socket | |
def make_endpoint(ip_addr, port): | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect((ip_addr, port)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
traefik: | |
# The official v2 Traefik docker image | |
image: traefik:v2.3.5 | |
# Enables the web UI and tells Traefik to listen to docker | |
command: | |
- --api.insecure=true | |
- --providers.docker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zmq | |
from zmq.utils import z85 | |
server_public, server_secret = zmq.curve_keypair() | |
context = zmq.Context() | |
server = context.socket(zmq.PAIR) | |
server.set(zmq.CURVE_SECRETKEY, z85.decode(server_secret)) | |
server.set(zmq.CURVE_PUBLICKEY, z85.decode(server_public)) | |
server.set(zmq.CURVE_SERVER, True) | |
server.bind("tcp://127.0.0.1:5556") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
https://github.com/OpenMined/PyPSI | |
''' | |
import gmpy2 | |
import secrets | |
import hashlib | |
from Crypto.PublicKey import RSA | |
class PSI(object): | |
def __init__(self, rsa_size=1024): |