<commit_before>#!/usr/bin/env python
'''
    Copyright 2009 Slide, Inc.

'''
import copy
import sys
import types
import unittest

import pyecc

#
# These values are built by running the seccure binary 
# and assume the curve of DEFAULT_CURVE (currently p384)
#
DEFAULT_DATA = 'This message will be signed\n'
DEFAULT_SIG = '$=gXkAjkWjA*>FF*eW@xo6>=B:F3X24$M-L:Pg(5O1SE@zs[cskaTh1K?p+O1G=;L~@slSs{v^6[V9oW/HkzJ+OS]q5ml4=iV(+xR~7>rS+y/TpgL~f[&,c'
DEFAULT_PUBKEY = <KEY>'
DEFAULT_PRIVKEY = 'my private key'
DEFAULT_PLAINTEXT = 'This is a very very secret message!\n'

class ECC_Pubkeygen_Tests(unittest.TestCase):
    def test_GenerateWithPrivkey(self):
        pubkey = pyecc.ECC.public_keygen(DEFAULT_PRIVKEY)
        assert pubkey == DEFAULT_PUBKEY, ('Mismatch', pubkey, DEFAULT_PUBKEY)

    def test_GenerateBoth(self):
        ecc = pyecc.ECC.generate()
        print ecc._private
        print ecc._public

class ECC_Verify_Tests(unittest.TestCase):
    def setUp(self):
        super(ECC_Verify_Tests, self).setUp()
        self.ecc = pyecc.ECC(public=DEFAULT_PUBKEY, private=DEFAULT_PRIVKEY)

    def test_BasicVerification(self):
        assert self.ecc.verify(DEFAULT_DATA, DEFAULT_SIG), ('Failed to verify signature',
                DEFAULT_DATA, DEFAULT_SIG, DEFAULT_PUBKEY, DEFAULT_PRIVKEY)

    def test_BadVerification(self):
        assert self.ecc.verify(DEFAULT_DATA, "FAIL") == False , ('Verified on a bad sig',
                DEFAULT_DATA, DEFAULT_SIG, DEFAULT_PUBKEY, DEFAULT_PRIVKEY)
<commit_msg>Add encrypt/decrypt calls to test_GenerateBoth to verify the keys work<commit_after>#!/usr/bin/env python
'''
    Copyright 2009 Slide, Inc.

'''
import copy
import sys
import types
import unittest

import pyecc

#
# These values are built by running the seccure binary 
# and assume the curve of DEFAULT_CURVE (currently p384)
#
DEFAULT_DATA = 'This message will be signed\n'
DEFAULT_SIG = '$=gXkAjkWjA*>FF*eW@xo6>=B:F3X24$M-L:Pg(5O1SE@zs[cskaTh1K?p+O1G=;L~@slSs{v^6[V9oW/HkzJ+OS]q5ml4=iV(+xR~7>rS+y/TpgL~f[&,c'
DEFAULT_PUBKEY = <KEY>'
DEFAULT_PRIVKEY = 'my private key'
DEFAULT_PLAINTEXT = 'This is a very very secret message!\n'

class ECC_KeyGen_Tests(unittest.TestCase):
    def test_GenerateWithPrivkey(self):
        pubkey = pyecc.ECC.public_keygen(DEFAULT_PRIVKEY)
        assert pubkey == DEFAULT_PUBKEY, ('Mismatch', pubkey, DEFAULT_PUBKEY)

    def test_GenerateBoth(self):
        ecc = pyecc.ECC.generate()

        encrypted = ecc.encrypt(DEFAULT_PLAINTEXT)
        assert encrypted, ('Failed to encrypt?', encrypted, ecc)

        decrypted = ecc.decrypt(encrypted)
        assert decrypted, ('Failed to decrypt?', decrypted, ecc)
        
        assert decrypted == DEFAULT_PLAINTEXT, ('Decrypted wrong',
            decrypted, DEFAULT_PLAINTEXT)

class ECC_Verify_Tests(unittest.TestCase):
    def setUp(self):
        super(ECC_Verify_Tests, self).setUp()
        self.ecc = pyecc.ECC(public=DEFAULT_PUBKEY, private=DEFAULT_PRIVKEY)

    def test_BasicVerification(self):
        assert self.ecc.verify(DEFAULT_DATA, DEFAULT_SIG), ('Failed to verify signature',
                DEFAULT_DATA, DEFAULT_SIG, DEFAULT_PUBKEY, DEFAULT_PRIVKEY)

    def test_BadVerification(self):
        assert self.ecc.verify(DEFAULT_DATA, "FAIL") == False , ('Verified on a bad sig',
                DEFAULT_DATA, DEFAULT_SIG, DEFAULT_PUBKEY, DEFAULT_PRIVKEY)

{'fraction_non_alphanumeric': 0.10956470239857861, 'fraction_numerical': 0.011844832691738229, 'mean_word_length': 4.102719033232629, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2507332', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1200, 'n_words': 254}