Giter VIP home page Giter VIP logo

bitcoinecdsa.php's People

Contributors

anthonyryan1 avatar cuchulain avatar dragu avatar erikpelli avatar in3rsha avatar mikerousseau avatar rgex avatar tuaris avatar yfgeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bitcoinecdsa.php's Issues

Call to undefined function BitcoinPHP\BitcoinECDSA\getWif()

Error: Call to undefined function BitcoinPHP\BitcoinECDSA\getWif()
in: src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php
is:

    public function getUncompressedWif()
    {
        return getWif(false);
    }

should be:

    public function getUncompressedWif()
    {
        return $this->getWif(false);
    }

How to tweak this library for Litecoin?

Hi,

I'm working on a project where I'd be using your codebase :)

I was wondering if it can be tweaked for LTC addresses?

My use-case is to convert hexa private key to wallet address

Addresses which start with "bc1" are not validated

Here's the sample of address: bc1qwjyrqmz07fjatnlzff9hs4qlpdkatpum8aclmc

The library returns: ErrorException: gmp_add(): Unable to convert variable to GMP - wrong type

As far as I understand it's a new format of addresses for BTC

Method: checkSignatureForRawMessage() fails when a signed message is provided.

My issue is best explained by examples.

It works if I do it this way:

$bitcoinECDSA = new BitcoinECDSA();
$bitcoinECDSA->generateRandomPrivateKey();

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

echo $signedMessage . PHP_EOL;
$result = $bitcoinECDSA->checkSignatureForRawMessage($signedMessage);
echo 'Message Signature Valid: ' . ($result ? 'True' : 'False') . PHP_EOL;

Result:

-----BEGIN BITCOIN SIGNED MESSAGE-----
Test 1234
-----BEGIN SIGNATURE-----
1QByU6YzFcUwA5QX759cg2eFhkdTCV7CtW
H/B2dpyiirAV3dW1aqAtyu7KQylz47DyS/GSXo2DLEiiyfFArocW7T6TVss6WXhZDyeu6AraLPrJLju+DXRz6I0=
-----END BITCOIN SIGNED MESSAGE-----
Message Signature Valid: True

If I do this:

$bitcoinECDSA = new BitcoinECDSA();

$signedMessage = "-----BEGIN BITCOIN SIGNED MESSAGE-----" . PHP_EOL;
$signedMessage .= "Test 1234" . PHP_EOL;
$signedMessage .= "-----BEGIN SIGNATURE-----" . PHP_EOL;
$signedMessage .= "1QByU6YzFcUwA5QX759cg2eFhkdTCV7CtW" . PHP_EOL;
$signedMessage .= "H/B2dpyiirAV3dW1aqAtyu7KQylz47DyS/GSXo2DLEiiyfFArocW7T6TVss6WXhZDyeu6AraLPrJLju+DXRz6I0=" . PHP_EOL;
$signedMessage .= "-----END BITCOIN SIGNED MESSAGE-----";

echo $signedMessage . PHP_EOL;
$result = $bitcoinECDSA->checkSignatureForRawMessage($signedMessage);
echo 'Message Signature Valid: ' . ($result ? 'True' : 'False') . PHP_EOL;

I get this:

Fatal error:  Uncaught exception 'Exception' with message 'No Private Key was defined'

Okay, so I add to the above:

$bitcoinECDSA->generateRandomPrivateKey();

Fails.

-----BEGIN BITCOIN SIGNED MESSAGE-----
Test 1234
-----BEGIN SIGNATURE-----
1QByU6YzFcUwA5QX759cg2eFhkdTCV7CtW
H/B2dpyiirAV3dW1aqAtyu7KQylz47DyS/GSXo2DLEiiyfFArocW7T6TVss6WXhZDyeu6AraLPrJLju+DXRz6I0=
-----END BITCOIN SIGNED MESSAGE-----
Message Signature Valid: False

What am I doing wrong?

About the function signHash()

Thanks for the code!
when I print signHash()
Result length is 140,
but when use Python (import ecdsa) Result length is 128
Is this code can do like Python to print result length just 128?

Diffie Hellman

Hi! It would be super useful if you implemented a method to support Diffie Hellman. That is, given one keypair's public key and another keypair's private key, multiplying the two yields a very useful symmetric key.

WIF is not readable by Mycelium wallet

Here are the details of the wallet:

ADDRESS : 1GRTPtfbTk2oTfnrDhXajvmCHpEeJxWr7H
WIF : nvcAtj5QiQprwWQk6LW6gDVMxQGmvJsXjZU5qmndRjL83ZJGEK5
Private Key : ba24185ce261850993e13ff7f0ad2ab01d418b0f48534880ea33e304cb388b9d

When I am entering or scanning the qr code for WIF, the mycelium wallet app is not detecting it as valid.

I imported the Private Key in blockchain.info wallet, it was a success. Then I generated the WIF from their interface, the WIF generated was different:

L3TYYUQPQ6FjP2sCkfUjF48JP2jKRYwZJTJNaoB8tFfisYYmNJHp

and mycelium could read this format successfully.

What am I missing? Thanks.

Question regarding your code

Hi,

Please check the following code from BitcoinECDSA.php line 101

$table = [ '1','2','3','4','5','6','7','8','9','A','B','C','D', 'E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W', 'X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','m','n','o', 'p','q','r','s','t','u','v','w','x','y','z' ];

Why the capital "i" and capital "o" also number zero are missing?

[Warning] gmp_add(): Unable to convert variable to GMP

Thanks for this module, you've done amazing work with it!

We're receiving the above warning when a user attempts to validate a CashAddr formatted address with this module, I'd guess due to the presence of non-base58 characters. Could the module detect this and throw a catchable Exception before gmp throws a warning? Happy to raise a pull request if you're happy with that!

bech32 address

Hi, this is the only script that works immediately, without a composer installation and that is small and clear (all other scripts are massive, messy to read, and use 300+ files).

The only thing is that the generated address are not bech32 and so fees on such addresses are much higher.

On 32bit systems int overflows when generating random 256bits hexa string

In BitcoinECDSA.php on line 149, there is rand() with parameters 100000000000 and 1000000000000. Everything is okay on 64bit systems, but on 32bit systems, those ints overflow and they become float which causes that no number is generated. Possible solution is to use constant PHP_INT_MAX and generate this random number in range which is supported on current system.

Not really an issue - Just encouragement

I know its unfinished but I would just like to say, good stuff!

I was thinking of doing something similar but you seem to be on the right track, looking forward to WIF, verify message and sign message completion.

different results

Hi,

I'm getting different results with getAddress() when using compressed and uncompressed private keys.

compressed bitcoin address: 155NQk5psqEsDjfbYV5iWhGpVhm3GeLYBs
$key uncompressed: 5Hpepo99cdVV4xhMFUYteoHzW7M5hdccMmMpniKa11wNsUhxqfi
$key compressed: KwFKwxey2G4itUq6NtbkyqKzoV1dkLcB4enuvmNxf591XjhLzdCe

$bitcoinECDSA->setPrivateKeyWithWif($key);
$address = $bitcoinECDSA->getAddress();
echo $address;

Result for uncompressed key:
155NQk5psqEsDjfbYV5iWhGpVhm3GeLYBs (correct)

Result for compressed key:
1PShnSX6kerVFkC8MhuLwL1uhxL2aCBsJt (wrong)

how to print private and public key

Hi, im basic. I need to print private and public key. I tried to use $bitcoinECDSA->getPrivateKey();, buto when i do this, the private key is not for generateg BTC address, but other. Can you help me?

Full code:

`require_once 'src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php';

use BitcoinPHP\BitcoinECDSA\BitcoinECDSA;

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

//Validate an address (Verify the checksum)
if($bitcoinECDSA->validateAddress($address)) {
echo "The address is valid" . PHP_EOL;
print $p . "

";
} else {
echo "The address is invalid" . PHP_EOL;
}`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.