def generate_key(self): """ create keypair, program_id and jid """ signingkey = SigningKey.generate(curve=NIST256p) sk_text = "private-jid0-%s" % my_b32encode(signingkey.to_string()) verifyingkey = signingkey.get_verifying_key() vk_text = "public-jid0-%s" % my_b32encode(verifyingkey.to_string()) self.jid = vk_to_jid(verifyingkey) self.program_id = jid_to_programid(self.jid) self.private_key = sk_text self.public_key = vk_text
def generate_key(self): """ create keypair, program_id and jid """ from ecdsa import SigningKey, NIST256p from cuddlefish.preflight import vk_to_jid, jid_to_programid, my_b32encode sk = SigningKey.generate(curve=NIST256p) sk_text = "private-jid0-%s" % my_b32encode(sk.to_string()) vk = sk.get_verifying_key() vk_text = "public-jid0-%s" % my_b32encode(vk.to_string()) self.jid = vk_to_jid(vk) self.program_id = jid_to_programid(self.jid) self.private_key = sk_text self.public_key = vk_text
def test_base32(self): for l in range(1, 100): text = "a" * l encoded = preflight.my_b32encode(text) decoded = preflight.my_b32decode(encoded) self.assertEqual(text, decoded, (text, encoded, decoded))