<commit_before>from __future__ import unicode_literals


class PublicKey(object):
    def key_type(self):
        raise NotImplementedError()

    def key_id(self):
        raise NotImplementedError()

    def crypto_public_key(self):
        raise NotImplementedError()

    def pem_block(self):
        raise NotImplementedError()

    def marshal_json(self):
        raise NotImplementedError()

    def verify(self, buffer, alg, signature):
        raise NotImplementedError()


class PrivateKey(PublicKey):
    def public_key(self):
        raise NotImplementedError()

    def crypto_private_key(self):
        raise NotImplementedError()

    def sign(self, buffer, hash_id):
        raise NotImplementedError()<commit_msg>add from jwk common function<commit_after>from __future__ import unicode_literals

import json


class PublicKey(object):
    def key_type(self):
        raise NotImplementedError()

    def key_id(self):
        raise NotImplementedError()

    def crypto_public_key(self):
        raise NotImplementedError()

    def pem_block(self):
        raise NotImplementedError()

    def marshal_json(self):
        raise NotImplementedError()

    def verify(self, buffer, alg, signature):
        raise NotImplementedError()


class PrivateKey(PublicKey):
    def public_key(self):
        raise NotImplementedError()

    def crypto_private_key(self):
        raise NotImplementedError()

    def sign(self, buffer, hash_id):
        raise NotImplementedError()


def unmarshal_public_key_jwk(data):
    from libtrust import ec_key
    from libtrust import rsa_key

    jwk = json.loads(data)

    kty = jwk['kty']
    return {
        'EC': ec_key.ec_public_key_from_map(jwk),
        'RSA': rsa_key.rsa_public_key_from_map(jwk)
    }[kty]
{'fraction_non_alphanumeric': 0.0831918505942275, 'fraction_numerical': 0.0, 'mean_word_length': 3.29126213592233, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4641286', 'n_tokens_mistral': 558, 'n_tokens_neox': 524, 'n_words': 123}