如何解决如何隐藏本机密钥
如umbral-doc所定义 Main operation of Umbral KEM
- Alice使用公共密钥封装,生成了K(用于chacha20加密的密钥)。
- 重新加密以共享给bob。
- 最后,鲍勃使用privateKey获得K和cipherText,解密cipherText获得plainText。
我的问题是:
最终,Bob得到解密密钥,因此下次Bob可以使用 decrypt Key 解密密文而无需收集cFrags,也可以将密钥发送给其他人(例如clark),如何保守秘密。
类似本影集的节目指南:
from umbral import pre,keys,signing
# Generate Umbral keys for Alice.
alices_private_key = keys.UmbralPrivateKey.gen_key()
alices_public_key = alices_private_key.get_pubkey()
alices_signing_key = keys.UmbralPrivateKey.gen_key()
alices_verifying_key = alices_signing_key.get_pubkey()
alices_signer = signing.Signer(private_key=alices_signing_key)
# Generate Umbral keys for Bob.
bobs_private_key = keys.UmbralPrivateKey.gen_key()
bobs_public_key = bobs_private_key.get_pubkey()
# Generate Umbral keys for Clark.
clarks_private_key = keys.UmbralPrivateKey.gen_key()
clarks_public_key = clarks_private_key.get_pubkey()
# Encrypt data with Alice's public key.
plaintext = b'Proxy Re-Encryption is cool!'
ciphertext,capsule = pre.encrypt(alices_public_key,plaintext)
# Decrypt data with Alice's private key.
cleartext = pre.decrypt(ciphertext=ciphertext,capsule=capsule,decrypting_key=alices_private_key)
# Alice generates "M of N" re-encryption key fragments (or "KFrags") for Bob.
# In this example,10 out of 20.
kfrags = pre.generate_kfrags(delegating_privkey=alices_private_key,signer=alices_signer,receiving_pubkey=bobs_public_key,threshold=10,N=20)
capsule.set_correctness_keys(delegating=alices_public_key,receiving=bobs_public_key,verifying=alices_verifying_key)
cfrags = list() # Bob's cfrag collection
for kfrag in kfrags[:10]:
cfrag = pre.reencrypt(kfrag=kfrag,capsule=capsule)
cfrags.append(cfrag) # Bob collects a cfrag
for cfrag in cfrags:
capsule.attach_cfrag(cfrag)
bob_cleartext = pre.decrypt(ciphertext=ciphertext,decrypting_key=bobs_private_key)
assert bob_cleartext == plaintext
print(bob_cleartext)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。