# Pure-Python ECDSA and ECDH
[](https://github.com/tlsfuzzer/python-ecdsa/actions?query=workflow%3A%22GitHub+CI%22+branch%3Amaster)
[](https://ecdsa.readthedocs.io/en/latest/?badge=latest)
[](https://coveralls.io/github/tlsfuzzer/python-ecdsa?branch=master)


[](https://github.com/tlsfuzzer/python-ecdsa/actions/workflows/codeql.yml)
[](https://pypi.python.org/pypi/ecdsa/)

This is an easy-to-use implementation of ECC (Elliptic Curve Cryptography)
with support for ECDSA (Elliptic Curve Digital Signature Algorithm),
EdDSA (Edwards-curve Digital Signature Algorithm) and ECDH
(Elliptic Curve Diffie-Hellman), implemented purely in Python, released under
the MIT license. With this library, you can quickly create key pairs (signing
key and verifying key), sign messages, and verify the signatures. You can
also agree on a shared secret key based on exchanged public keys.
The keys and signatures are very short, making them easy to handle and
incorporate into other protocols.
**NOTE: This library should not be used in production settings, see [Security](#Security) for more details.**
## Features
This library provides key generation, signing, verifying, and shared secret
derivation for five
popular NIST "Suite B" GF(p) (_prime field_) curves, with key lengths of 192,
224, 256, 384, and 521 bits. The "short names" for these curves, as known by
the OpenSSL tool (`openssl ecparam -list_curves`), are: `prime192v1`,
`secp224r1`, `prime256v1`, `secp384r1`, and `secp521r1`. It includes the
256-bit curve `secp256k1` used by Bitcoin. There is also support for the
regular (non-twisted) variants of Brainpool curves from 160 to 512 bits. The
"short names" of those curves are: `brainpoolP160r1`, `brainpoolP192r1`,
`brainpoolP224r1`, `brainpoolP256r1`, `brainpoolP320r1`, `brainpoolP384r1`,
`brainpoolP512r1`. Few of the small curves from SEC standard are also
included (mainly to speed-up testing of the library), those are:
`secp112r1`, `secp112r2`, `secp128r1`, and `secp160r1`.
Key generation, siging and verifying is also supported for Ed25519 and
Ed448 curves.
No other curves are included, but it is not too hard to add support for more
curves over prime fields.
## Dependencies
This library uses only Python and the 'six' package. It is compatible with
Python 2.6, 2.7, and 3.6+. It also supports execution on alternative
implementations like pypy and pypy3.
If `gmpy2` or `gmpy` is installed, they will be used for faster arithmetic.
Either of them can be installed after this library is installed,
`python-ecdsa` will detect their presence on start-up and use them
automatically.
You should prefer `gmpy2` on Python3 for optimal performance.
To run the OpenSSL compatibility tests, the 'openssl' tool must be in your
`PATH`. This release has been tested successfully against OpenSSL 0.9.8o,
1.0.0a, 1.0.2f, 1.1.1d and 3.0.1 (among others).
## Installation
This library is available on PyPI, it's recommended to install it using `pip`:
```
pip install ecdsa
```
In case higher performance is wanted and using native code is not a problem,
it's possible to specify installation together with `gmpy2`:
```
pip install ecdsa[gmpy2]
```
or (slower, legacy option):
```
pip install ecdsa[gmpy]
```
## Speed
The following table shows how long this library takes to generate key pairs
(`keygen`), to sign data (`sign`), to verify those signatures (`verify`),
to derive a shared secret (`ecdh`), and
to verify the signatures with no key-specific precomputation (`no PC verify`).
All those values are in seconds.
For convenience, the inverses of those values are also provided:
how many keys per second can be generated (`keygen/s`), how many signatures
can be made per second (`sign/s`), how many signatures can be verified
per second (`verify/s`), how many shared secrets can be derived per second
(`ecdh/s`), and how many signatures with no key specific
precomputation can be verified per second (`no PC verify/s`). The size of raw
signature (generally the smallest
the way a signature can be encoded) is also provided in the `siglen` column.
Use `tox -e speed` to generate this table on your own computer.
On an Intel Core i7 4790K @ 4.0GHz I'm getting the following performance:
```
siglen keygen keygen/s sign sign/s verify verify/s no PC verify no PC verify/s
NIST192p: 48 0.00032s 3134.06 0.00033s 2985.53 0.00063s 1598.36 0.00129s 774.43
NIST224p: 56 0.00040s 2469.24 0.00042s 2367.88 0.00081s 1233.41 0.00170s 586.66
NIST256p: 64 0.00051s 1952.73 0.00054s 1867.80 0.00098s 1021.86 0.00212s 471.27
NIST384p: 96 0.00107s 935.92 0.00111s 904.23 0.00203s 491.77 0.00446s 224.00
NIST521p: 132 0.00210s 475.52 0.00215s 464.16 0.00398s 251.28 0.00874s 114.39
SECP256k1: 64 0.00052s 1921.54 0.00054s 1847.49 0.00105s 948.68 0.00210s 477.01
BRAINPOOLP160r1: 40 0.00025s 4003.88 0.00026s 3845.12 0.00053s 1893.93 0.00105s 949.92
BRAINPOOLP192r1: 48 0.00033s 3043.97 0.00034s 2975.98 0.00063s 1581.50 0.00135s 742.29
BRAINPOOLP224r1: 56 0.00041s 2436.44 0.00043s 2315.51 0.00078s 1278.49 0.00180s 556.16
BRAINPOOLP256r1: 64 0.00053s 1892.49 0.00054s 1846.24 0.00114s 875.64 0.00229s 437.25
BRAINPOOLP320r1: 80 0.00073s 1361.26 0.00076s 1309.25 0.00143s 699.29 0.00322s 310.49
BRAINPOOLP384r1: 96 0.00107s 931.29 0.00111s 901.80 0.00230s 434.19 0.00476s 210.20
BRAINPOOLP512r1: 128 0.00207s 483.41 0.00212s 471.42 0.00425s 235.43 0.00912s 109.61
SECP112r1: 28 0.00015s 6672.53 0.00016s 6440.34 0.00031s 3265.41 0.00056s 1774.20
SECP112r2: 28 0.00015s 6697.11 0.00015s 6479.98 0.00028s 3524.72 0.00058s 1716.16
SECP128r1: 32 0.00018s 5497.65 0.00019s 5272.89 0.00036s 2747.39 0.00072s 1396.16
SECP160r1: 42 0.00025s 3949.32 0.00026s 3894.45 0.00046s 2153.85 0.00102s 985.07
Ed25519: 64 0.00076s 1324.48 0.00042s 2405.01 0.00109s 918.05 0.00344s 290.50
Ed448: 114 0.00176s 569.53 0.00115s 870.94 0.00282s 355.04 0.01024s 97.69
ecdh ecdh/s
NIST192p: 0.00104s 964.89
NIST224p: 0.00134s 748.63
NIST256p: 0.00170s 587.08
NIST384p: 0.00352s 283.90
NIST521p: 0.00717s 139.51
SECP256k1: 0.00154s 648.40
BRAINPOOLP160r1: 0.00082s 1220.70
BRAINPOOLP192r1: 0.00105s 956.75
BRAINPOOLP224r1: 0.00136s 734.52
BRAINPOOLP256r1: 0.00178s 563.32
BRAINPOOLP320r1: 0.00252s 397.23
BRAINPOOLP384r1: 0.00376s 266.27
BRAINPOOLP512r1: 0.00733s 136.3
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
纯 Python ECDSA 和 ECDH 这是 ECC(椭圆曲线密码术)的易于使用的实现,支持 ECDSA(椭圆曲线数字签名算法)、EdDSA(爱德华兹曲线数字签名算法)和 ECDH(椭圆曲线 Diffie-Hellman),纯用 Python 实现,根据 MIT 许可证发布。使用此库,您可以快速创建密钥对(签名密钥和验证密钥)、签署消息和验证签名。您还可以根据交换的公钥商定共享密钥。密钥和签名非常短,因此易于处理并合并到其他协议中。注意该库不应在生产设置中使用,请参阅安全性了解更多详细信息。特征该库为五种流行的 NIST “Suite B” GF(p)(素数域)曲线提供密钥生成、签名、验证和共享秘密派生,密钥长度分别为 192、224、256、384 和 521 位。OpenSSL 工具 () 所熟知的这些曲线的“简称”为、、、、和。openssl ecparam -list_curves它prime192v1包括 比特币使用的256 位曲线。还支持 160 至 512 位的 Brainpool 曲线的常规(非扭曲 )变体。这些曲线的“简称”为、、、
资源推荐
资源详情
资源评论






























收起资源包目录



























































































共 83 条
- 1
资源评论


徐浪老师
- 粉丝: 9546
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 科技管理系统如何借助AI+数智应用突破传统管理限制,实现价值创造?.docx
- 科技外包管理系统如何借助AI+数智应用技术实现智能化升级?.docx
- 科技外包管理系统如何借助AI+数智应用突破传统管理局限,实现高效管理与价值创造?.docx
- 科技项目管理平台升级,如何借助AI+数智应用做到既智能又个性化?.docx
- 科技项目管理中,传统系统为何难以实现价值创造?AI+数智应用能提供何种新方案?.docx
- 科技项目管理系统如何借助AI+数智应用实现智能化升级?.docx
- 企业创新赋能工具如何借助AI+数智应用解决科技服务产品同质化问题?.docx
- 企业技术创新需求多样,如何利用AI+数智应用提供更精准、高效的一站式服务?.docx
- 面对产品同质化,科技服务机构如何借助AI+数智应用打造独特优势?.docx
- 企业竞争力不足,科技服务机构如何通过AI+数智应用创新工具提升产品差异化?.docx
- 如何借助AI+数智应用解决科技服务机构面临的产品同质化和行业内卷问题?.docx
- 如何借助AI+数智应用破解科技管理系统中管理与服务脱节的难题?.docx
- 如何借助AI+数智应用让科技服务机构的品牌和服务脱颖而出?.docx
- 如何借助AI+数智应用重塑科技服务业竞争力?.docx
- 如何借助AI+数智应用提升服务附加值,避免科技服务陷入低价竞争?.docx
- 如何利用AI+数智应用低成本提升科技服务机构的服务竞争力?.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
