def encrypt_ballot_contests(ballot: PlaintextBallot, description: InternalManifest, context: CiphertextElectionContext, nonce_seed: ElementModQ) -> Optional[List[CiphertextBallotContest]]:
    'Encrypt contests from a plaintext ballot with a specific style'
    encrypted_contests: List[CiphertextBallotContest] = []
    for ballot_style_contest in description.get_contests_for(ballot.style_id):
        use_contest = None
        for contest in ballot.contests:
            if (contest.object_id == ballot_style_contest.object_id):
                use_contest = contest
                break
        if (not use_contest):
            use_contest = contest_from(ballot_style_contest)
        encrypted_contest = encrypt_contest(use_contest, ballot_style_contest, context.elgamal_public_key, context.crypto_extended_base_hash, nonce_seed)
        if (encrypted_contest is None):
            return None
        encrypted_contests.append(get_optional(encrypted_contest))
    return encrypted_contests
Encrypt contests from a plaintext ballot with a specific style
def encrypt_ballot_contests(ballot: PlaintextBallot, description: InternalManifest, context: CiphertextElectionContext, nonce_seed: ElementModQ) -> Optional[List[CiphertextBallotContest]]:
    
    encrypted_contests: List[CiphertextBallotContest] = []
    for ballot_style_contest in description.get_contests_for(ballot.style_id):
        use_contest = None
        for contest in ballot.contests:
            if (contest.object_id == ballot_style_contest.object_id):
                use_contest = contest
                break
        if (not use_contest):
            use_contest = contest_from(ballot_style_contest)
        encrypted_contest = encrypt_contest(use_contest, ballot_style_contest, context.elgamal_public_key, context.crypto_extended_base_hash, nonce_seed)
        if (encrypted_contest is None):
            return None
        encrypted_contests.append(get_optional(encrypted_contest))
    return encrypted_contests