All Projects → BitcoinPHP → Bitcoinecdsa.php

BitcoinPHP / Bitcoinecdsa.php

PHP library to generate BTC addresses and signatures from private keys.

Projects that are alternatives of or similar to Bitcoinecdsa.php

Exonum
An extensible open-source framework for creating private/permissioned blockchain applications
Stars: ✭ 1,037 (+513.61%)
Mutual labels:  bitcoin, cryptography
Bitp0wn
Algorithms to re-compute a private key, to fake signatures and some other funny things with Bitcoin.
Stars: ✭ 59 (-65.09%)
Mutual labels:  bitcoin, ecdsa
Merkle Tools
Tools for creating Merkle trees, generating merkle proofs, and verification of merkle proofs.
Stars: ✭ 54 (-68.05%)
Mutual labels:  bitcoin, cryptography
Blockchain Papers
区块链相关的有价值的文献
Stars: ✭ 20 (-88.17%)
Mutual labels:  bitcoin, cryptography
Javascript Opentimestamps
Stars: ✭ 99 (-41.42%)
Mutual labels:  bitcoin, cryptography
Swift Crypto
Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
Stars: ✭ 1,005 (+494.67%)
Mutual labels:  cryptography, ecdsa
Fastecdsa
Python library for fast elliptic curve crypto
Stars: ✭ 158 (-6.51%)
Mutual labels:  cryptography, ecdsa
Blockchain
Compilation of useful documents and scientific papers about Blockchain & cryptocurrencies.
Stars: ✭ 751 (+344.38%)
Mutual labels:  bitcoin, cryptography
Bitcoin Cryptography Library
Nayuki's implementation of cryptographic primitives used in Bitcoin.
Stars: ✭ 81 (-52.07%)
Mutual labels:  bitcoin, cryptography
Lightning Rfc
Lightning Network Specifications
Stars: ✭ 1,224 (+624.26%)
Mutual labels:  bitcoin, cryptography
Ipchain
IPChain Core Wallet
Stars: ✭ 26 (-84.62%)
Mutual labels:  bitcoin, cryptography
Opentimestamps Server
OpenTimestamps server component
Stars: ✭ 143 (-15.38%)
Mutual labels:  bitcoin, cryptography
Aeternity
æternity: solving scalability problems by making sense of state-channels
Stars: ✭ 923 (+446.15%)
Mutual labels:  bitcoin, cryptography
Joeecc
Elliptic Curve Cryptography playground/toolkit written in pure Python
Stars: ✭ 46 (-72.78%)
Mutual labels:  cryptography, ecdsa
Secp256k1 Go
Bindings to lib-secp256k1 for golang
Stars: ✭ 22 (-86.98%)
Mutual labels:  bitcoin, ecdsa
Qtum
Qtum Core Wallet
Stars: ✭ 1,080 (+539.05%)
Mutual labels:  bitcoin, cryptography
Lnd
Lightning Network Daemon ⚡️
Stars: ✭ 5,623 (+3227.22%)
Mutual labels:  bitcoin, cryptography
Brainflayer
A proof-of-concept cracker for cryptocurrency brainwallets and other low entropy key alogrithms.
Stars: ✭ 561 (+231.95%)
Mutual labels:  bitcoin, cryptography
Python Opentimestamps
Stars: ✭ 64 (-62.13%)
Mutual labels:  bitcoin, cryptography
Cryptolib4pascal
Crypto for Modern Object Pascal
Stars: ✭ 127 (-24.85%)
Mutual labels:  cryptography, ecdsa

Build   Quality Score   Latest Stable Version   Downloads

WARNING

This piece of software is provided without warranty of any kind, use it at your own risk.

REQUIREMENTS

php 5.4.0 or newer.

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.

USAGE

Installation

Best way is to use composer

composer require bitcoin-php/bitcoin-ecdsa

Alternatively add following snippet in you composer.json

"bitcoin-php/bitcoin-ecdsa" : ">=1.3"

Instanciation

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

Set a private key

$bitcoinECDSA->setPrivateKey($k);

examples of private keys :

4C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC

Generate a random private key

$bitcoinECDSA->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. Using a nonce adds randomness, which means the generated private key is stronger.

Get the private key

$bitcoinECDSA->getPrivateKey();

Returns the private key.

Get the Wif

$bitcoinECDSA->getWif();

returns the private key under the Wallet Import Format

Get the Public Key

$bitcoinECDSA->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.

Example : 0226c50013603b085fbc26411d5d7e564b252d88964eedc4e01251d2d495e92c29

Get the Uncompressed Public Key

$bitcoinECDSA->getUncompressedPubKey();

Returns the uncompressed PubKey. The uncompressed PubKey starts with 0x04, the next 32 bytes are the x coordinates, the last 32 bytes are the y coordinates.

Example : 04c80e8af3f1b7816a18aa24f242fc0740e9c4027d67c76dacf4ce32d2e5aace241c426fd288a9976ca750f1b192d3acd89dfbeca07ef27f3e5eb5d482354c4249

Get the coordinates of the Public Key

$bitcoinECDSA->getPubKeyPoints();

Returns an array containing the x and y coordinates of the public key

Example : Array ( [x] => a69243f3c4c047aba38d7ac3660317629c957ab1f89ea42343aee186538a34f8 [y] => b6d862f39819060378542a3bb43ff76b5d7bb23fc012f09c3cd2724bebe0b0bd )

Get the Address

$bitcoinECDSA->getAddress();

Returns the compressed Bitcoin Address.

Get the uncompressed Address

$bitcoinECDSA->getUncompressedAddress();

Returns the uncompressed Bitcoin Address.

Validate an address

$bitcoinECDSA->validateAddress($address);

Returns true if the address is valid and false if it isn't

Validate a Wif key

$bitcoinECDSA->validateWifKey($wif);

Returns true if the WIF key is valid and false if it isn't

Signatures

Sign a message

$bitcoinECDSA->signMessage('message');

Returns a satoshi client standard signed message.

verify a message

$bitcoinECDSA->checkSignatureForRawMessage($signedMessage);

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

sign a sha256 hash

$bitcoinECDSA->signHash($hash);

Returns a DER encoded hexadecimal signature.

verify a signature

$bitcoinECDSA->checkDerSignature($pubKey, $signature, $hash)

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

Examples

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].