|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
-
-
-
-
-
-
-
-
-
- class KyberNTTSimulation(SimulationProject):
- KYBER_K = 2
- KYBER_N = 256
-
- @classmethod
- def get_binary_path(cl):
- return 'project.bin'
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
-
- def set_input(self, input):
- """ Write into the 'input' file of ELMO tool
- the parameters and the challenges for the simulation """
- super().set_input(input)
-
- def set_input_for_each_challenge(self, input, challenge):
- """ Write into the 'input' file of ELMO tool
- the 'challenge' for the simulation """
- secret = challenge
-
-
- for j in range(self.KYBER_K):
- for k in range(self.KYBER_N):
- write(input, secret[j,k])
-
- def get_test_challenges(self):
- import numpy as np
- just_ones = np.ones((self.KYBER_K, self.KYBER_N), dtype=int)
- return [
- 0 * just_ones,
- 1 * just_ones,
- -2 * just_ones,
- ]
-
- def get_random_challenges(self, nb_challenges=5):
- import numpy as np
- return [ np.random.choice(
- [-2, -1, 0, 1, 2],
- (self.KYBER_K, self.KYBER_N),
- p=[1/16, 4/16, 6/16, 4/16, 1/16],
- ) for _ in range(nb_challenges) ]
|