Пример #1
0
    def __init__(self, cryptosystem, num_trustees, threshold, public_key_value,
                 verification_partial_public_keys):
        """
        Creates a new threshold public key. Should not be invoked directly.
        
        Instead of using this constructor from outside of PloneVoteCryptoLib, 
        please use ThresholdEncryptionSetUp.generate_public_key().
        
        Arguments:
            (see class attributes for cryptosystem, num_trustees and threshold)
            public_key_value::long        -- The actual value of the public key
                                (g^2P(0) mod p, see ThresholdEncryptionSetUp)
            verification_partial_public_keys::long[]
                    -- A series of "partial public keys" (g^P(i) for each 
                       trustee i), used for partial decryption verification.
                       Note that the key for trustee i must be on index i-1 of
                       the array.
        """
        PublicKey.__init__(self, cryptosystem, public_key_value)

        # Some checks:
        if (threshold > num_trustees):
            raise ValueError("Invalid parameters for the threshold public key:"\
                             " threshold must be smaller than the total number"\
                             " of trustees. Got num_trustees=%d, threshold=%d" \
                             % (num_trustees, threshold))

        if (len(verification_partial_public_keys) != num_trustees):
            raise ValueError("Invalid parameters for the threshold public key:"\
                             " a verification partial public for each trustee "\
                             "must be included.")

        self.num_trustees = num_trustees
        self.threshold = threshold
        self._partial_public_keys = verification_partial_public_keys
Пример #2
0
 def __init__(self, cryptosystem, num_trustees, threshold, 
              public_key_value, verification_partial_public_keys):
     """
     Creates a new threshold public key. Should not be invoked directly.
     
     Instead of using this constructor from outside of PloneVoteCryptoLib, 
     please use ThresholdEncryptionSetUp.generate_public_key().
     
     Arguments:
         (see class attributes for cryptosystem, num_trustees and threshold)
         public_key_value::long        -- The actual value of the public key
                             (g^2P(0) mod p, see ThresholdEncryptionSetUp)
         verification_partial_public_keys::long[]
                 -- A series of "partial public keys" (g^P(i) for each 
                    trustee i), used for partial decryption verification.
                    Note that the key for trustee i must be on index i-1 of
                    the array.
     """
     PublicKey.__init__(self, cryptosystem, public_key_value)
     
     # Some checks:
     if(threshold > num_trustees):
         raise ValueError("Invalid parameters for the threshold public key:"\
                          " threshold must be smaller than the total number"\
                          " of trustees. Got num_trustees=%d, threshold=%d" \
                          % (num_trustees, threshold))
     
     if(len(verification_partial_public_keys) != num_trustees):
         raise ValueError("Invalid parameters for the threshold public key:"\
                          " a verification partial public for each trustee "\
                          "must be included.")
         
     self.num_trustees = num_trustees
     self.threshold = threshold
     self._partial_public_keys = verification_partial_public_keys