Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/web3p/secp256k1
secp256k1
https://github.com/web3p/secp256k1
ethereum secp256k1
Last synced: 5 days ago
JSON representation
secp256k1
- Host: GitHub
- URL: https://github.com/web3p/secp256k1
- Owner: web3p
- License: mit
- Created: 2018-02-13T09:40:08.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-01T13:22:45.000Z (over 6 years ago)
- Last Synced: 2024-11-09T11:51:41.338Z (9 days ago)
- Topics: ethereum, secp256k1
- Language: PHP
- Size: 25.4 KB
- Stars: 5
- Watchers: 3
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# secp256k1
secp256k1 for ethereum, this package depends on mdanter/ecc package.[![Build Status](https://travis-ci.org/web3p/secp256k1.svg?branch=master)](https://travis-ci.org/web3p/secp256k1)
[![codecov](https://codecov.io/gh/web3p/secp256k1/branch/master/graph/badge.svg)](https://codecov.io/gh/web3p/secp256k1)
[![Licensed under the MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/web3p/secp256k1/blob/master/LICENSE)# Install
Set minimum stability to dev
```
composer require web3p/secp256k1
```# Usage
Sign a message:
```php
use Web3p\Secp256k1\Secp256k1;
use Web3p\Secp256k1\Serializer\HexSignatureSerializer;$secp256k1 = new Secp256k1();
// return signature contains r and s.
// message and privateKey are hex string
$signature = $secp256k1->sign($message, $privateKey);// get r
$r = $signature->getR();// get s
$s = $signature->getS();// encode to hex
$serializer = new HexSignatureSerializer();
$signatureString = $serializer->serialize($signature);// or you can call toHex
$signatureString = $signature->toHex();
```Verify a message:
```php
use Web3p\Secp256k1\Secp256k1;$secp256k1 = new Secp256k1();
// signature was created from sign method.
// hash and publicKey are hex string
$isVerified = $secp256k1->verify($hash, $signature, $publicKey);
```# API
Todo.
# License
MIT