简体   繁体   English

Solidity和Python上的椭圆曲线加解密

[英]Elliptic Curve encryption and decryption on Solidity and Python

I am trying to create a smart contract where I have to encrypt (and decrypt) data that I receive from a Python script running on a client.我正在尝试创建一个智能合约,我必须加密(和解密)从客户端上运行的 Python 脚本接收的数据。 The data will be encrypted on the client-side, and I will have to decrypt it on the smart contract.数据将在客户端加密,我必须在智能合约上对其进行解密。

I got a smart contract code which can generate a key pair here .我有一个智能合约代码,可以在这里生成一个密钥对。 I am new to cryptography, and I tried looking up how I can encrypt plaintext using the public key and decrypt using the private key, but I am not getting a proper answer anywhere.我是密码学新手,我尝试查找如何使用公钥加密明文并使用私钥解密,但我在任何地方都没有得到正确的答案。

It will be great if someone can guide me to a relevant resource.如果有人可以指导我找到相关资源,那就太好了。 Thank you.谢谢你。

Actually, this document does a pretty good job of going through the steps of using one particular Python elliptic curve library.实际上, 本文档很好地完成了使用特定 Python 椭圆曲线库的步骤。

Note that you don't actually encrypt or decrypt large amounts of data using the public/private key.请注意,您实际上并未使用公钥/私钥加密或解密大量数据。 Instead, one uses ECC to create a shared secret key, and then that shared secret key is used with AES or whatever is your encryption algorithm of choice.相反,使用 ECC 创建一个共享密钥,然后将该共享密钥与 AES 或您选择的任何加密算法一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM