This project implements an ECDSA (Elliptic Curve Digital Signature Algorithm) API to sign, verify, and manage cryptographic keys. The API is built using Flask and is designed for ease of use.
- Generate and manage ECDSA keys.
- Sign data using private keys.
- Verify data signatures with public keys.
- Rotate keys dynamically.
- Description: Welcome endpoint to confirm the API is running.
- Response:
{ "message": "Welcome to ECDSA API!" }
- Description: Sign the provided data using the private key.
- Request Body:
{ "data": "message_to_sign" } - Response:
{ "signature": "308201..." }
- Description: Verify the provided signature and data using the public key.
- Request Body:
{ "data": "message_to_sign", "signature": "308201..." } - Response:
{ "valid": true }
- Description: Regenerate ECDSA keys.
- Response:
{ "message": "Keys rotated successfully" }
- Python 3.8+
- Virtual environment for dependency management
-
Clone the repository:
git clone https://github.com/your-repo/ECDSA_HANDLER.git cd ECDSA_HANDLER -
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Navigate to the
srcdirectory and start the server:python api.py
-
The API will be available at
http://127.0.0.1:5000/.
Execute the following command to run all unit tests:
python -m unittest discover -s tests-
Test the home endpoint:
curl -X GET http://127.0.0.1:5000/
-
Sign data:
curl -X POST http://127.0.0.1:5000/sign -H "Content-Type: application/json" -d '{"data": "message_to_sign"}'
-
Verify a signature:
curl -X POST http://127.0.0.1:5000/verify -H "Content-Type: application/json" -d '{"data": "message_to_sign", "signature": "308201..."}'
-
Rotate keys:
curl -X POST http://127.0.0.1:5000/rotate
ECDSA_HANDLER/
├── src/
│ ├── api.py # API implementation
│ ├── ecdsa_handler.py # ECDSA key handling logic
│ ├── private_key.pem # Private key (generated dynamically)
│ ├── public_key.pem # Public key (generated dynamically)
├── tests/
│ ├── test_ecdsa_handler.py # Unit tests
├── README.md # Project documentation
├── requirements.txt # Python dependencies
└── .gitignore # Git ignore file
This project is licensed under the MIT License.