Пример #1
0
class EncryptedAnswerWithRandomness(LegacyObject):
    FIELDS = ["choices", "individual_proofs", "overall_proof", "randomness", "answer"]
    STRUCTURED_FIELDS = {
        "choices": arrayOf("legacy/EGCiphertext"),
        "individual_proofs": arrayOf("legacy/EGZKDisjunctiveProof"),
        "overall_proof": "legacy/EGZKDisjunctiveProof",
        "randomness": arrayOf("core/BigInteger"),
    }
Пример #2
0
class EncryptedAnswer(LegacyObject):
    WRAPPED_OBJ_CLASS = homomorphic.EncryptedAnswer
    FIELDS = ["choices", "individual_proofs", "overall_proof"]
    STRUCTURED_FIELDS = {
        "choices": arrayOf("legacy/EGCiphertext"),
        "individual_proofs": arrayOf("legacy/EGZKDisjunctiveProof"),
        "overall_proof": "legacy/EGZKDisjunctiveProof",
    }
Пример #3
0
class EncryptedAnswer(LDObject):
    FIELDS = [
        "choices", "individual_proofs", "overall_proof", "randomness", "answer"
    ]
    STRUCTURED_FIELDS = {
        "choices": arrayOf("pkc/elgamal/EGCiphertext"),
        "individual_proofs": arrayOf("pkc/elgamal/DisjunctiveProof"),
        "overall_proof": "pkc/elgamal/DisjunctiveProof",
        "randomness": "core/BigInteger"
        # answer is not a structured field, it's an as-is integer
    }
Пример #4
0
class EncryptedVoteWithRandomness(LegacyObject):
    """
    An encrypted ballot with randomness for answers
    """

    WRAPPED_OBJ_CLASS = homomorphic.EncryptedVote
    FIELDS = ["answers", "election_hash", "election_uuid"]
    STRUCTURED_FIELDS = {"answers": arrayOf("legacy/EncryptedAnswerWithRandomness")}
Пример #5
0
class Trustee(LegacyObject):
    FIELDS = [
        "uuid",
        "public_key",
        "public_key_hash",
        "pok",
        "decryption_factors",
        "decryption_proofs",
        "email",
    ]

    STRUCTURED_FIELDS = {
        "public_key": "legacy/EGPublicKey",
        "pok": "legacy/DLogProof",
        "decryption_factors": arrayOf(arrayOf("core/BigInteger")),
        "decryption_proofs": arrayOf(arrayOf("legacy/EGZKProof")),
    }
Пример #6
0
class Trustee(LDObject):
    """
    a trustee
    """

    FIELDS = [
        "uuid",
        "public_key",
        "public_key_hash",
        "pok",
        "decryption_factors",
        "decryption_proofs",
        "email",
    ]
    STRUCTURED_FIELDS = {
        "pok": "pkc/elgamal/DiscreteLogProof",
        "public_key": "pkc/elgamal/PublicKey",
        "decryption_factors": arrayOf(arrayOf("core/BigInteger")),
        "decryption_proofs": arrayOf(arrayOf("legacy/EGZKProof")),
    }
Пример #7
0
class EGZKDisjunctiveProof(LegacyObject):
    WRAPPED_OBJ_CLASS = crypto_elgamal.ZKDisjunctiveProof
    FIELDS = ["proofs"]
    STRUCTURED_FIELDS = {"proofs": arrayOf("legacy/EGZKProof")}

    def loadDataFromDict(self, d):
        "hijack and make sure we add the proofs name back on"
        return super(EGZKDisjunctiveProof, self).loadDataFromDict({"proofs": d})

    def toDict(self, complete=False):
        "hijack toDict and make it return the proofs array only, since that's the spec for legacy"
        return super(EGZKDisjunctiveProof, self).toDict(complete=complete)["proofs"]
Пример #8
0
class EncryptedVote(LegacyObject):
    """
    An encrypted ballot
    """

    WRAPPED_OBJ_CLASS = homomorphic.EncryptedVote
    FIELDS = ["answers", "election_hash", "election_uuid"]
    STRUCTURED_FIELDS = {"answers": arrayOf("legacy/EncryptedAnswer")}

    def includeRandomness(self):
        return self.instantiate(
            self.wrapped_obj, datatype="legacy/EncryptedVoteWithRandomness"
        )
Пример #9
0
class Tally(LegacyObject):
    WRAPPED_OBJ_CLASS = homomorphic.Tally
    FIELDS = ["tally", "num_tallied"]
    STRUCTURED_FIELDS = {"tally": arrayOf(arrayOf("legacy/EGCiphertext"))}
Пример #10
0

class CastVote(LDObject):
    FIELDS = ["vote", "cast_at", "voter_uuid", "voter_hash", "vote_hash"]
    STRUCTURED_FIELDS = {
        "cast_at": "core/Timestamp",
        "vote": "legacy/EncryptedVote"
    }

    @property
    def short(self):
        return self.instantiate(self.wrapped_obj,
                                datatype="2011/01/ShortCastVote")


Questions = arrayOf("2011/01/Question")


class Question(LDObject):
    FIELDS = [
        "answer_urls",
        "answers",
        "choice_type",
        "max",
        "min",
        "question",
        "result_type",
        "short_name",
        "tally_type",
    ]