JasonHe-WQ / encryptLayer

这是一个完全在本地的基于以太坊账户系统的端对端加密系统A local point to point encrypt and decrypt system using EVM account

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

encryptLayer

CN

这是一个完全在本地的基于以太坊账户系统的端对端加密系统。
感谢maiyude2018大佬,完善了公钥查找。
现在已经可以上polygon testnet
再次感谢maiyude2018大佬,感谢script-money 大佬让我接触到这么优秀的大佬
还要感谢box和h神,不断地给我提示,支持我
关于哈希算公钥和其他密码学的原理,我推荐一些文章
关于公钥的压缩与解压
公钥的反向计算Go实现
比特币加密算法
寻找随机素数
后量子时代的加密

EN

This project aims to handle point to point encryption and decryption with EVM account both online and offline.
Special thanks to maiyude2018 who helped me alot in 'findPublicKey.py' and script-money who let me get to know a bunch of Experts in CS who expertised in Ethereum.

如何使用

How to use

首先,安装此工程需要的库并全部升级到最新版本
First, install packages this project depends on and upgrade them to the latest
requests pycryptodome eth-account eth-keys eciespy web3.py

然后克隆或下载这个库源码,打开 'main.py'
Clone or download the source code of this project, and open 'main.py'

msg = mailbox(ifHadAccount=True) #default: False

初始化mailbox这个类,参数ifHadAccount代表你是否愿意使用已有账户,输入True会要求 输入十六进制私钥,输入False将会创建账户
When mailbox initiating, parameter ifHanAcount is able to be sent in to represent whether the client would to use their existed account. Once True was sent, the client will be request to input their private key in Hex, and False means this programme will generate an account

msg.encrypt(
    senderPublicKey=None,
    senderAddr=0x5568BC7EebC605A88e247769c4acA92d95BC9360, Type='RSA')

当使用非对称加密时,请在第三个参数Type传入RSA,并且传入在已经支持的网络上有过交易的 senderAddr作为第二个参数,或者任意地址的公钥作为第一个参数
当使用对称加密时Type参数请传入ESA,密钥将会自动生成并保存在本地
注意:在这个函数中,请以字典形式传入参数
When using asymmetrical encryption, please set the third parameter Type RSA and send in an address which has made tx on supported network as parameter senderAddr or public key of any account as parameter publicKey
When using Type as ESA, the password will be stored in local computer.
Attention:In this method, please send in parameter as dictionary.

msg.sign()

这个函数将会使用你的私钥对消息签名
This method will sign the massage with your private key

msg.decrypt(senderAddr=0x5568BC7EebC605A88e247769c4acA92d95BC9360, password=None)

这个函数将会对签名校验,如果是senderAddr发送的信息,将会使用你的私钥解密并输出(RSA)或使用保存 在本地的对称密钥解密(ESA)。你也可以传入第二个参数password对称密钥的字节串作为对称密钥
This method will check the sign, if the actual sender is the same as parameter senderAddr, the method will decrypt(RSA) or decrypt with local password(ESA). You can also send in the second parameter password with your password in bytes string

msg.sendOnline(chainID='80001', permanent=False)

这个函数将会把你的签名和加密后的信息作为字节串上传,当第二个参数permanentTrue 时,会作为交易的data写入区块链,chainID代表你选择的链。当第二个参数为False时,会上传到 中心化服务器并在7天内删除
This method will upload your signature and encrypted data as bytes string. When the second parameter is True, the data bytes will be sent on chain as data, else, these will be uploaded to a centralized server and deleted with 7 days.

About

这是一个完全在本地的基于以太坊账户系统的端对端加密系统A local point to point encrypt and decrypt system using EVM account


Languages

Language:Python 100.0%