Skip to content

Commit

Permalink
Bitcoin -> Folm
Browse files Browse the repository at this point in the history
  • Loading branch information
gduymaz committed Nov 27, 2018
1 parent b4b0ca4 commit 081b770
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 119 deletions.
12 changes: 6 additions & 6 deletions Examples/generateAddress.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

require_once '../src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php';
require_once '../src/FolmPHP/FolmECDSA/FolmECDSA.php';

use BitcoinPHP\BitcoinECDSA\BitcoinECDSA;
use FolmPHP\FolmECDSA\FolmECDSA;

$bitcoinECDSA = new BitcoinECDSA();
$bitcoinECDSA->generateRandomPrivateKey(); //generate new random private key
$address = $bitcoinECDSA->getAddress(); //compressed Bitcoin address
$folmECDSA = new FolmECDSA();
$folmECDSA->generateRandomPrivateKey(); //generate new random private key
$address = $folmECDSA->getAddress(); //compressed Folm address
echo "Address: " . $address . PHP_EOL;

//Validate an address (Verify the checksum)
if($bitcoinECDSA->validateAddress($address)) {
if($folmECDSA->validateAddress($address)) {
echo "The address is valid" . PHP_EOL;
} else {
echo "The address is invalid" . PHP_EOL;
Expand Down
12 changes: 6 additions & 6 deletions Examples/signMessage.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

require_once '../src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php';
require_once '../src/FolmPHP/FolmECDSA/FolmECDSA.php';

use BitcoinPHP\BitcoinECDSA\BitcoinECDSA;
use FolmPHP\FolmECDSA\FolmECDSA;

$bitcoinECDSA = new BitcoinECDSA();
$bitcoinECDSA->generateRandomPrivateKey(); //generate new random private key
$folmECDSA = new FolmECDSA();
$folmECDSA->generateRandomPrivateKey(); //generate new random private key

$message = "Test message";
$signedMessage = $bitcoinECDSA->signMessage($message);
$signedMessage = $folmECDSA->signMessage($message);

echo "signed message:" . PHP_EOL;
echo $signedMessage . PHP_EOL;
Expand All @@ -26,7 +26,7 @@


// If you only want the signature you can do this
$signature = $bitcoinECDSA->signMessage($message, true);
$signature = $folmECDSA->signMessage($message, true);

echo "signature:" . PHP_EOL;
echo $signature . PHP_EOL;
Expand Down
10 changes: 5 additions & 5 deletions Examples/verifyMessage.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

require_once '../src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php';
require_once '../src/FolmPHP/FolmECDSA/FolmECDSA.php';

use BitcoinPHP\BitcoinECDSA\BitcoinECDSA;
use FolmPHP\FolmECDSA\FolmECDSA;

$bitcoinECDSA = new BitcoinECDSA();
$folmECDSA = new FolmECDSA();

//To verify a message like this one
$rawMessage = "-----BEGIN BITCOIN SIGNED MESSAGE-----
Expand All @@ -14,7 +14,7 @@
HxTqM+b3xj2Qkjhhl+EoUpYsDUz+uTdz6RCY7Z4mV62yOXJ3XCAfkiHV+HGzox7Ba/OC6bC0y6zBX0GhB7UdEM0=
-----END BITCOIN SIGNED MESSAGE-----";

if($bitcoinECDSA->checkSignatureForRawMessage($rawMessage)) {
if($folmECDSA->checkSignatureForRawMessage($rawMessage)) {
echo "Message verified" . PHP_EOL;
} else {
echo "Couldn't verify message" . PHP_EOL;
Expand All @@ -25,7 +25,7 @@
$address = "1L56ndSQ1LfrAB2xyo3ZN7egiW4nSs8KWS";
$message = "Test message";

if($bitcoinECDSA->checkSignatureForMessage($address, $signature, $message)) {
if($folmECDSA->checkSignatureForMessage($address, $signature, $message)) {
echo "Message verified" . PHP_EOL;
} else {
echo "Couldn't verify message" . PHP_EOL;
Expand Down
22 changes: 11 additions & 11 deletions Examples/wif.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php

require_once '../src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php';
require_once '../src/FolmPHP/FolmECDSA/FolmECDSA.php';

use BitcoinPHP\BitcoinECDSA\BitcoinECDSA;
use FolmPHP\FolmECDSA\FolmECDSA;

$bitcoinECDSA = new BitcoinECDSA();
$bitcoinECDSA->generateRandomPrivateKey(); //generate new random private key
$folmECDSA = new FolmECDSA();
$folmECDSA->generateRandomPrivateKey(); //generate new random private key

$wif = $bitcoinECDSA->getWif();
$address = $bitcoinECDSA->getAddress();
$wif = $folmECDSA->getWif();
$address = $folmECDSA->getAddress();
echo "Address : " . $address . PHP_EOL;
echo "WIF : " . $wif . PHP_EOL;

unset($bitcoinECDSA); //destroy instance
unset($folmECDSA); //destroy instance

//import wif
$bitcoinECDSA = new BitcoinECDSA();
if($bitcoinECDSA->validateWifKey($wif)) {
$bitcoinECDSA->setPrivateKeyWithWif($wif);
$address = $bitcoinECDSA->getAddress();
$folmECDSA = new FolmECDSA();
if($folmECDSA->validateWifKey($wif)) {
$folmECDSA->setPrivateKeyWithWif($wif);
$address = $folmECDSA->getAddress();
echo "imported address : " . $address . PHP_EOL;
} else {
echo "invalid WIF key" . PHP_EOL;
Expand Down
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build](https://travis-ci.org/BitcoinPHP/BitcoinECDSA.php.svg?branch=master)](https://travis-ci.org/BitcoinPHP/BitcoinECDSA.php) &nbsp;
[![Quality Score](https://scrutinizer-ci.com/g/BitcoinPHP/BitcoinECDSA.php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/BitcoinPHP/BitcoinECDSA.php/?branch=master) &nbsp;
[![Latest Stable Version](https://poser.pugx.org/bitcoin-php/bitcoin-ecdsa/v/stable.svg)](https://packagist.org/packages/bitcoin-php/bitcoin-ecdsa) &nbsp;
[![Downloads](http://img.shields.io/packagist/dt/bitcoin-php/bitcoin-ecdsa.svg?style=flat)](https://packagist.org/packages/bitcoin-php/bitcoin-ecdsa)
[![Build](https://travis-ci.org/FolmPHP/FolmECDSA.php.svg?branch=master)](https://travis-ci.org/FolmPHP/FolmECDSA.php) &nbsp;
[![Quality Score](https://scrutinizer-ci.com/g/FolmPHP/FolmECDSA.php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/FolmPHP/FolmECDSA.php/?branch=master) &nbsp;
[![Latest Stable Version](https://poser.pugx.org/folm/folmecdsa/v/stable.svg)](https://packagist.org/packages/folm/folmecdsa) &nbsp;
[![Downloads](http://img.shields.io/packagist/dt/folm/folmecdsa.svg?style=flat)](https://packagist.org/packages/folm/folmecdsa)


WARNING
Expand All @@ -16,7 +16,7 @@ REQUIREMENTS

*php5-gmp* needs to be installed.

If you want to launch the test file you need to be under a unix system with libbitcoin intalled on it.
If you want to launch the test file you need to be under a unix system with libfolm intalled on it.

USAGE
===============
Expand All @@ -25,25 +25,25 @@ USAGE

Best way is to use composer
```
composer require bitcoin-php/bitcoin-ecdsa
composer require folm/folmecdsa
```
Alternatively add following snippet in you composer.json
```
"bitcoin-php/bitcoin-ecdsa" : ">=1.3"
"folm/folmecdsa" : ">=1.3"
```

**Instanciation**

```php
use BitcoinPHP\BitcoinECDSA\BitcoinECDSA;
require_once("src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php");
$bitcoinECDSA = new BitcoinECDSA();
use FolmPHP\FolmECDSA\FolmECDSA;
require_once("src/FolmPHP/FolmECDSA/FolmECDSA.php");
$folmECDSA = new FolmECDSA();
```

**Set a private key**

```php
$bitcoinECDSA->setPrivateKey($k);
$folmECDSA->setPrivateKey($k);
```
examples of private keys :

Expand All @@ -53,7 +53,7 @@ examples of private keys :
**Generate a random private key**

```php
$bitcoinECDSA->generateRandomPrivateKey($nonce);
$folmECDSA->generateRandomPrivateKey($nonce);
```

The nonce is optional, typically the nonce is a chunck of random data you get from the user. This can be mouse coordinates.
Expand All @@ -62,15 +62,15 @@ Using a nonce adds randomness, which means the generated private key is stronger
**Get the private key**

```php
$bitcoinECDSA->getPrivateKey();
$folmECDSA->getPrivateKey();
```

Returns the private key.

**Get the Wif**

```php
$bitcoinECDSA->getWif();
$folmECDSA->getWif();
```

returns the private key under the Wallet Import Format
Expand All @@ -79,7 +79,7 @@ returns the private key under the Wallet Import Format
**Get the Public Key**

```php
$bitcoinECDSA->getPubKey();
$folmECDSA->getPubKey();
```
Returns the compressed public key.
The compressed PubKey starts with 0x02 if it's y coordinate is even and 0x03 if it's odd, the next 32 bytes corresponds to the x coordinates.
Expand All @@ -89,7 +89,7 @@ Example : 0226c50013603b085fbc26411d5d7e564b252d88964eedc4e01251d2d495e92c29
**Get the Uncompressed Public Key**

```php
$bitcoinECDSA->getUncompressedPubKey();
$folmECDSA->getUncompressedPubKey();
```

Returns the uncompressed PubKey.
Expand All @@ -100,7 +100,7 @@ Example : 04c80e8af3f1b7816a18aa24f242fc0740e9c4027d67c76dacf4ce32d2e5aace241c42
**Get the coordinates of the Public Key**

```php
$bitcoinECDSA->getPubKeyPoints();
$folmECDSA->getPubKeyPoints();
```

Returns an array containing the x and y coordinates of the public key
Expand All @@ -111,32 +111,32 @@ Array ( [x] => a69243f3c4c047aba38d7ac3660317629c957ab1f89ea42343aee186538a34f8
**Get the Address**

```php
$bitcoinECDSA->getAddress();
$folmECDSA->getAddress();
```

Returns the compressed Bitcoin Address.
Returns the compressed Folm Address.

**Get the uncompressed Address**

```php
$bitcoinECDSA->getUncompressedAddress();
$folmECDSA->getUncompressedAddress();
```

Returns the uncompressed Bitcoin Address.
Returns the uncompressed Folm Address.


**Validate an address**

```php
$bitcoinECDSA->validateAddress($address);
$folmECDSA->validateAddress($address);
```
Returns true if the address is valid and false if it isn't


**Validate a Wif key**

```php
$bitcoinECDSA->validateWifKey($wif);
$folmECDSA->validateWifKey($wif);
```
Returns true if the WIF key is valid and false if it isn't

Expand All @@ -147,7 +147,7 @@ Signatures
**Sign a message**

```php
$bitcoinECDSA->signMessage('message');
$folmECDSA->signMessage('message');
```

Returns a satoshi client standard signed message.
Expand All @@ -156,7 +156,7 @@ Returns a satoshi client standard signed message.
**verify a message**

```php
$bitcoinECDSA->checkSignatureForRawMessage($signedMessage);
$folmECDSA->checkSignatureForRawMessage($signedMessage);
```

Returns true if the signature is matching the address and false if it isn't.
Expand All @@ -165,7 +165,7 @@ Returns true if the signature is matching the address and false if it isn't.
**sign a sha256 hash**

```php
$bitcoinECDSA->signHash($hash);
$folmECDSA->signHash($hash);
```

Returns a DER encoded hexadecimal signature.
Expand All @@ -174,17 +174,17 @@ Returns a DER encoded hexadecimal signature.
**verify a signature**

```php
$bitcoinECDSA->checkDerSignature($pubKey, $signature, $hash)
$folmECDSA->checkDerSignature($pubKey, $signature, $hash)
```

Returns true if the signature is matching the public key and false if it isn't.

Examples
===============
- [Generate an address](https://github.com/BitcoinPHP/BitcoinECDSA.php/blob/master/Examples/generateAddress.php)
- [Sign a message](https://github.com/BitcoinPHP/BitcoinECDSA.php/blob/master/Examples/signMessage.php)
- [Verify a message](https://github.com/BitcoinPHP/BitcoinECDSA.php/blob/master/Examples/verifyMessage.php)
- [Import or export a private key using WIF](https://github.com/BitcoinPHP/BitcoinECDSA.php/blob/master/Examples/wif.php)
- [Generate an address](https://github.com/FolmPHP/FolmECDSA.php/blob/master/Examples/generateAddress.php)
- [Sign a message](https://github.com/FolmPHP/FolmECDSA.php/blob/master/Examples/signMessage.php)
- [Verify a message](https://github.com/FolmPHP/FolmECDSA.php/blob/master/Examples/verifyMessage.php)
- [Import or export a private key using WIF](https://github.com/FolmPHP/FolmECDSA.php/blob/master/Examples/wif.php)

License
===============
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "bitcoin-php/bitcoin-ecdsa",
"name": "folm/folm-ecdsa",
"type": "library",
"description": "PHP library allowing to generate BTC addresses from private keys",
"keywords": ["ECDSA","Bitcoin"],
"homepage": "https://github.com/BitcoinPHP/BitcoinECDSA.php",
"description": "PHP library allowing to generate FLM addresses from private keys",
"keywords": ["ECDSA","Folm"],
"homepage": "https://github.com/folm/FolmECDSA.php",
"license": "unlicense",
"authors": [
{
"name": "BitcoinPHP",
"email": "panda@panda.cat",
"homepage": "http://github.com/BitcoinPHP",
"name": "folm",
"email": "dev@folm.io",
"homepage": "http://github.com/folm",
"role": "Developer"
}
],
Expand All @@ -20,7 +20,7 @@
},
"autoload": {
"psr-0": {
"BitcoinPHP\\BitcoinECDSA": "src"
"FolmPHP\\FolmECDSA": "src"
}
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="src/BitcoinPHP/Tests/BootStrap.php" colors="true">
<phpunit bootstrap="src/FolmPHP/Tests/BootStrap.php" colors="true">
<testsuites>
<testsuite name="All">
<file>src/BitcoinPHP/Tests/BitcoinECDSATest.php</file>
<file>src/FolmPHP/Tests/FolmECDSATest.php</file>
</testsuite>
</testsuites>

Expand Down

0 comments on commit 081b770

Please sign in to comment.