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 sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler | |
| def test_lwe(n, p, sigma, size=100): | |
| F = GF(p) | |
| a = random_vector(F, n) | |
| HALF_P = int(p/2) | |
| s = random_vector(F,n) | |
| p41 = int(p/4) | |
| p43 = int(p*3/4) | |
| D = DiscreteGaussianDistributionLatticeSampler(F^1, sigma) |
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 numpy as np | |
| P = next_prime(2^256) | |
| N = 64 | |
| k = 16 | |
| BOUND = 32 | |
| HALF_P = int(P/2+0.5) | |
| R.<x> = PolynomialRing(GF(P), 'x') |
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 |