Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def createEncAndSigKeys(enc_key_dir, sig_key_dir, name, seed=None):
seed = seed or randomSeed()
if isinstance(seed, str):
seed = seed.encode()
# ATTENTION: Passing `seed` encoded to bytes or not in
# `crypto_sign_seed_keypair` will generate different keypairs
verif_key, sig_key = crypto_sign_seed_keypair(seed)
createCertsFromKeys(sig_key_dir, name, z85.encode(verif_key),
z85.encode(sig_key[:32]))
public_key, secret_key = ep2c(verif_key), es2c(sig_key)
createCertsFromKeys(enc_key_dir, name, z85.encode(public_key),
z85.encode(secret_key))
return (public_key, secret_key), (verif_key, sig_key)
def __init__(self, seed, encoder=encoding.RawEncoder):
# Decode the seed
seed = encoder.decode(seed)
# Verify that our seed is the proper size
if len(seed) != libnacl.crypto_sign_SEEDBYTES:
raise ValueError(
"The seed must be exactly %d bytes long" %
libnacl.crypto_sign_SEEDBYTES
)
public_key, secret_key = libnacl.crypto_sign_seed_keypair(seed)
self._seed = seed
self._signing_key = secret_key
self.verify_key = VerifyKey(public_key)
def __init__(self, seed=None):
'''
Create a signing key, if not seed it supplied a keypair is generated
'''
if seed:
if len(seed) != libnacl.crypto_sign_SEEDBYTES:
raise ValueError('Invalid seed bytes')
self.vk, self.sk = libnacl.crypto_sign_seed_keypair(seed)
else:
seed = libnacl.randombytes(libnacl.crypto_sign_SEEDBYTES)
self.vk, self.sk = libnacl.crypto_sign_seed_keypair(seed)
self.seed = seed
def __init__(self, seed=None):
'''
Create a signing key, if not seed it supplied a keypair is generated
'''
if seed:
if len(seed) != libnacl.crypto_sign_SEEDBYTES:
raise ValueError('Invalid seed bytes')
self.vk, self.sk = libnacl.crypto_sign_seed_keypair(seed)
else:
seed = libnacl.randombytes(libnacl.crypto_sign_SEEDBYTES)
self.vk, self.sk = libnacl.crypto_sign_seed_keypair(seed)
self.seed = seed
def __init__(self, seed, encoder=encoding.RawEncoder):
# Decode the seed
seed = encoder.decode(seed)
# Verify that our seed is the proper size
if len(seed) != libnacl.crypto_sign_SEEDBYTES:
raise ValueError(
"The seed must be exactly %d bytes long" %
libnacl.crypto_sign_SEEDBYTES
)
public_key, secret_key = libnacl.crypto_sign_seed_keypair(seed)
self._seed = seed
self._signing_key = secret_key
self.verify_key = VerifyKey(public_key)
def __init__(self, seed=None):
'''
Create a signing key, if not seed it supplied a keypair is generated
'''
if seed:
if len(seed) != libnacl.crypto_sign_SEEDBYTES:
raise ValueError('Invalid seed bytes')
self.vk, self.sk = libnacl.crypto_sign_seed_keypair(seed)
else:
seed = libnacl.randombytes(libnacl.crypto_sign_SEEDBYTES)
self.vk, self.sk = libnacl.crypto_sign_seed_keypair(seed)
self.seed = seed
def createEncAndSigKeys(enc_key_dir, sig_key_dir, name, seed=None):
seed = seed or randomSeed()
if isinstance(seed, str):
seed = seed.encode()
# ATTENTION: Passing `seed` encoded to bytes or not in
# `crypto_sign_seed_keypair` will generate different keypairs
verif_key, sig_key = crypto_sign_seed_keypair(seed)
createCertsFromKeys(sig_key_dir, name, z85.encode(verif_key),
z85.encode(sig_key[:32]))
public_key, secret_key = ep2c(verif_key), es2c(sig_key)
createCertsFromKeys(enc_key_dir, name, z85.encode(public_key),
z85.encode(secret_key))
return (public_key, secret_key), (verif_key, sig_key)