https://github.com/itzmeanjan/secp256k1
Elliptic Curve Arithmetic for secp256k1 Curve
https://github.com/itzmeanjan/secp256k1
ecdsa elliptic-curve-cryptography montgomery-arithmetic secp256k1
Last synced: 6 months ago
JSON representation
Elliptic Curve Arithmetic for secp256k1 Curve
- Host: GitHub
- URL: https://github.com/itzmeanjan/secp256k1
- Owner: itzmeanjan
- License: cc0-1.0
- Created: 2022-06-28T07:59:58.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-08T14:12:34.000Z (almost 3 years ago)
- Last Synced: 2024-10-06T13:42:50.998Z (12 months ago)
- Topics: ecdsa, elliptic-curve-cryptography, montgomery-arithmetic, secp256k1
- Language: Python
- Homepage:
- Size: 73.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# secp256k1
Elliptic Curve Arithmetic for secp256k1 Curve## Prerequisites
- You must have Python3 installed & its path should be added to `$PATH`.
```bash
python3 --version
Python 3.10.8
```- Download project dependencies from PyPI using `pip`.
```bash
python3 -m pip install --upgrade pip # may not be *always* necessary
python3 -m pip install --user -r requirements.txt
```## Testing
For ensuring functional correctness of
- ECDSA keygen/ sign/ verify
- Secp256k1 base & scalar field arithmetic
- Secp256k1 group arithmetic ( point addition, doubling & multiplication )issue,
```bash
make
```## Usage
Using ECDSA is fairly easy
- Start by importing `ecdsa` module
- Then generate a random ECDSA keypair
- Now pass message bytes along with ECDSA secret key, for signing> **Note**
> ECDSA signature consists of two 256 -bit integers (r, s) | r, s ∈ [0, N)
> N = https://github.com/itzmeanjan/secp256k1/blob/b25f4f7/field/scalar_field_consts.py#L19-L21
- Finally use ECDSA public key & message to verify signature
```python3
>>> import ecdsa
>>> (skey, pkey) = ecdsa.keygen()
>>> msg = b'Just a message'
>>> sig = ecdsa.sign(skey, msg)
>>> verified = ecdsa.verify(pkey, msg, sig)
>>> assert verified
```