ecdsa-python | A lightweight and fast pure Python ECDSA library | Download Utils library
kandi X-RAY | ecdsa-python Summary
kandi X-RAY | ecdsa-python Summary
We tried other Python libraries such as python-ecdsa, fast-ecdsa and other less famous ones, but we didn't find anything that suited our needs. The first one was pure Python, but it was too slow. The second one mixed Python and C and it was really fast, but we were unable to use it in our current infrastructure, which required pure Python code. For this reason, we decided to create something simple, compatible with OpenSSL and fast using elegant math such as Jacobian Coordinates to speed up the ECDSA. Starkbank-ECDSA is fully compatible with Python2 and Python3.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generate a public key from a string
- Returns True if p is contained within this region
- Matrix multiplication
- Creates a Point from Jacobian
- Verify a message
- Sign a message using a private key
- Construct a private key from a string
- Parse a hexadecimal string
- Return the data for a tag
- Return a curve by oid
- Generate a Key object from a string
- Construct a Certificate from a string
- Parse a hexadecimal integer
- Read content of a file
ecdsa-python Key Features
ecdsa-python Examples and Code Snippets
from json import dumps
from ellipticcurve.ecdsa import Ecdsa
from ellipticcurve.privateKey import PrivateKey
# Generate privateKey from PEM string
privateKey = PrivateKey.fromPem("""
-----BEGIN EC PARAMETERS-----
BgUrgQQACg==
-----END E
openssl ecparam -name secp256k1 -genkey -out privateKey.pem
openssl ec -in privateKey.pem -pubout -out publicKey.pem
openssl dgst -sha256 -sign privateKey.pem -out signatureDer.txt message.txt
from ellipticcurve.ecdsa import Ecdsa
from ellipticcurv
Community Discussions
Trending Discussions on ecdsa-python
QUESTION
I'm trying to manually create an ES256 JWT token. I've a small script written in python which signs a sha256 hash which uses ecdsa-python. But the signature is invalid on jwt.io.
Steps to reproduce:
- Create base64 header + payload:
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0
- Create SHA256 hash from the base64 header + payload:
FFC89E33091FFDD3C61798A0A74BF7C2D1A6FD231A6CB519F33952F7696BBE9F
- Generate ec_private key:
openssl ec -in ec_private.pem -noout -text
- Use the small python program to ecdsa sign the SHA256 hash
ANSWER
Answered 2021-Feb-25 at 15:47The library you are using hashes implicitly, applying SHA1 by default. I.e. for compatibility with ES256 SHA256 must be explicitly specified and the unhashed JWT must be used, e.g.:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ecdsa-python
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page