Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
py3: partial fix for crypto/lwe
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Mar 10, 2019
1 parent 1040752 commit 04815a4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/sage/crypto/lwe.py
Expand Up @@ -90,7 +90,7 @@

from sage.functions.log import log
from sage.functions.other import sqrt, floor, ceil
from sage.misc.functional import cyclotomic_polynomial
from sage.misc.functional import cyclotomic_polynomial, round
from sage.misc.randstate import set_random_seed
from sage.misc.prandom import randint
from sage.modules.free_module import FreeModule
Expand All @@ -105,6 +105,7 @@
from sage.stats.distributions.discrete_gaussian_integer import DiscreteGaussianDistributionIntegerSampler
from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler


class UniformSampler(SageObject):
"""
Uniform sampling in a range of integers.
Expand Down Expand Up @@ -312,7 +313,7 @@ def __init__(self, n, q, D, secret_dist='uniform', m=None):
self.__s = vector(self.K, self.n, [self.D() for _ in range(n)])
else:
try:
lb, ub = map(ZZ,secret_dist)
lb, ub = map(ZZ, secret_dist)
self.__s = vector(self.K, self.n, [randint(lb,ub) for _ in range(n)])
except (IndexError, TypeError):
raise TypeError("Parameter secret_dist=%s not understood."%(secret_dist))
Expand Down Expand Up @@ -767,7 +768,7 @@ def balance_sample(s, q=None):
EXAMPLES::
sage: from sage.crypto.lwe import balance_sample, samples, Regev
sage: list(map(balance_sample, samples(10, 5, Regev)))
sage: [balance_sample(s) for s in samples(10, 5, Regev)]
[((-9, -4, -4, 4, -4), 4), ((-8, 11, 12, -11, -11), -7),
...
((-11, 12, 0, -6, -3), 7), ((-7, 14, 8, 11, -8), -12)]
Expand All @@ -776,7 +777,7 @@ def balance_sample(s, q=None):
sage: from sage.crypto.lwe import balance_sample, DiscreteGaussianDistributionPolynomialSampler, RingLWE, samples
sage: D = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 5)
sage: rlwe = RingLWE(20, 257, D)
sage: list(map(balance_sample, samples(10, 8, rlwe)))
sage: [balance_sample(s) for s in samples(10, 8, rlwe)]
[((-64, 107, -91, -24, 120, 54, 38, -35), (-84, 121, 28, -99, 91, 54, -60, 11)),
...
((-40, -117, 35, -69, -11, 10, 122, 48), (-80, -2, 119, -91, 27, 66, 121, -1))]
Expand Down

0 comments on commit 04815a4

Please sign in to comment.