<commit_before>"""
Support for EC keypair operation missing form public libcrypto API
"""
from ctypescrypto.pkey import PKey, PKeyError
from ctypes import c_void_p,c_char_p,c_int,byref
from ctypescrypto import libcrypto

def create(curve,data):
	"""
		Creates EC keypair from the just secret key and curve name
		
		@param curve - name of elliptic curve
		@param num - long number representing key
	"""
	ec=libcrypto.EC_KEY_new_by_curve_name(curve.nid)
	if ec is None:	
		raise PKeyError("EC_KEY_new_by_curvename")
	group=libcrypto.EC_KEY_get0_group(ec)
	if group is None:
		raise PKeyError("EC_KEY_get0_group")
	libcrypto.EC_GROUP_set_asn1_flag(group,1)
	raw_key=libcrypto.BN_new()
	if raw_key is None:
		raise PKeyError("BN_new")
	ctx=libcrypto.BN_CTX_new()
	if ctx is None:
		raise PKeyError("BN_CTX_new")
	if libcrypto.BN_bin2bn(data,len(data),raw_key) is None:
		raise PKeyError("BN_bin2bn")
	order=libcrypto.BN_new()
	if order is None:
		raise PKeyError("BN_new")
	priv_key = libcrypto.BN_new()
	if priv_key is None:
		raise PKeyError("BN_new")<commit_msg>Suppot for python integer as key material<commit_after>"""
Support for EC keypair operation missing form public libcrypto API
"""
from ctypescrypto.pkey import PKey, PKeyError
from ctypes import c_void_p,c_char_p,c_int,byref
from ctypescrypto import libcrypto

def create(curve,data):
	"""
		Creates EC keypair from the just secret key and curve name
		
		@param curve - name of elliptic curve
		@param num - byte array or long number representing key
	"""
	ec=libcrypto.EC_KEY_new_by_curve_name(curve.nid)
	if ec is None:	
		raise PKeyError("EC_KEY_new_by_curvename")
	group=libcrypto.EC_KEY_get0_group(ec)
	if group is None:
		raise PKeyError("EC_KEY_get0_group")
	libcrypto.EC_GROUP_set_asn1_flag(group,1)
	raw_key=libcrypto.BN_new()
	if isinstance(data,int):
		BN_hex2bn(byref(raw_key),hex(data))
	else:
		if raw_key is None:
			raise PKeyError("BN_new")
		if libcrypto.BN_bin2bn(data,len(data),raw_key) is None:
			raise PKeyError("BN_bin2bn")
	ctx=libcrypto.BN_CTX_new()
	if ctx is None:
		raise PKeyError("BN_CTX_new")
	order=libcrypto.BN_new()
	if order is None:
		raise PKeyError("BN_new")
	priv_key = libcrypto.BN_new()
	if priv_key is None:
		raise PKeyError("BN_new")
{'fraction_non_alphanumeric': 0.09370816599732262, 'fraction_numerical': 0.005800981704596163, 'mean_word_length': 5.6726190476190474, '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': '5066517', 'n_tokens_mistral': 886, 'n_tokens_neox': 840, 'n_words': 210}