我需要在 pyNaCl 中生成签名和私钥并将它们存储在某个地方。之后,我需要能够从字符串中加载它们。
这是生成新 SigningKey 和公钥的代码。
def gen_keys():
global sk
sk = nacl.signing.SigningKey.generate()
global pk
pk = sk.verify_key
pk = pk.encode(encoder=nacl.encoding.HexEncoder)
sk = sk.encode(encoder=nacl.encoding.HexEncoder)
pk_list.insert(INSERT, "=PRIVATE=\n")
pk_list.insert(INSERT, sk)
pk_list.insert(INSERT, "\n=PUBLIC=\n")
pk_list.insert(INSERT, pk)
pk_list.insert(INSERT, "\n\n")
我希望从其值加载 SigningKey,但唯一可用的选项是使用种子生成一个新的。