attack.py
def keygen(self,
               max_tries_for_A_gen=MAX_TRIES_FOR_A_GEN,
               max_tries_for_V_gen=MAX_TRIES_FOR_V_GEN):
        """
        This function generates a random key pair for binary PKP.
        That is, it returns a triple (A, Vsec, Vpub) such that
            A is an m by n binary matrix
            V and Vsec are two n by l binary matrices
            A*Vsec = 0
            Vsec has no two equal rows (security requirement for PKP)
            Vpub is a permutation of Vsec

        """

        for _try_A in range(max_tries_for_A_gen):

            A = random_matrix(GF(2), self.m, self.n)

            if A.rank() < self.m:
                continue

            try:
                Vsec = self.gen_Vsec_from_A(A, max_tries_for_V_gen=max_tries_for_V_gen)
                Vpub = matrix(sorted(Vsec))

                return A, Vsec, Vpub

            except RuntimeError:
                pass

        raise ValueError('Could not generate a key with the selected parameters.')

        This function generates a random key pair for binary PKP.
        That is, it returns a triple (A, Vsec, Vpub) such that
            A is an m by n binary matrix
            V and Vsec are two n by l binary matrices
            A*Vsec = 0
            Vsec has no two equal rows (security requirement for PKP)
            Vpub is a permutation of Vsec

        
This function generates a random key pair for binary PKP.
That is, it returns a triple (A, Vsec, Vpub) such that
A is an m by n binary matrix
V and Vsec are two n by l binary matrices
A*Vsec = 0
Vsec has no two equal rows (security requirement for PKP)
Vpub is a permutation of Vsec
This function generates a random key pair for binary PKP . That is it returns a triple ( A Vsec Vpub ) such that A is an m by n binary matrix V and Vsec are two n by l binary matrices A * Vsec = 0 Vsec has no two equal rows ( security requirement for PKP ) Vpub is a permutation of Vsec
def keygen(self,
               max_tries_for_A_gen=MAX_TRIES_FOR_A_GEN,
               max_tries_for_V_gen=MAX_TRIES_FOR_V_GEN):
        for _try_A in range(max_tries_for_A_gen):
            A = random_matrix(GF(2), self.m, self.n)
            if A.rank() < self.m:
                continue
            try:
                Vsec = self.gen_Vsec_from_A(A, max_tries_for_V_gen=max_tries_for_V_gen)
                Vpub = matrix(sorted(Vsec))
                return A, Vsec, Vpub
            except RuntimeError:
                pass
        raise ValueError('Could not generate a key with the selected parameters.')
def keygen ( self , max_tries_for_A_gen = MAX_TRIES_FOR_A_GEN , max_tries_for_V_gen = MAX_TRIES_FOR_V_GEN ) : for _try_A in range ( max_tries_for_A_gen ) : A = random_matrix ( GF ( 2 ) , self . m , self . n ) if A . rank ( ) < self . m : continue try : Vsec = self . gen_Vsec_from_A ( A , max_tries_for_V_gen = max_tries_for_V_gen ) Vpub = matrix ( sorted ( Vsec ) ) return A , Vsec , Vpub except RuntimeError : pass raise ValueError ( 'Could not generate a key with the selected parameters.' )
This function generates a random key pair for binary PKP.
This function generates a random key pair for binary PKP .
"""
        This function generates a random key pair for binary PKP.
        That is, it returns a triple (A, Vsec, Vpub) such that
            A is an m by n binary matrix
            V and Vsec are two n by l binary matrices
            A*Vsec = 0
            Vsec has no two equal rows (security requirement for PKP)
            Vpub is a permutation of Vsec

        """
self
max_tries_for_A_gen
max_tries_for_V_gen