Author

Topic: how to sign a message with php code (Read 210 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
December 18, 2023, 04:49:50 AM
#8
Is there any open source, simple project which just for implement the signing function. It must be open source, no one will trust this kind of software, even Electrum .if I want to sign a message with more than 100 bitcoins, I really can not trust any software even with big companies.  Do you think so?

I have difficulty to understand what you said. But Electrum is open source where the code is available on https://github.com/spesmilo/electrum. And i doubt you can find simple project since signing involve so many things including ECDSA implementation and checking whether you use valid private key.
newbie
Activity: 1
Merit: 23
December 17, 2023, 06:01:44 PM
#7
1.Yes, you need the private key to sign a message. Signing a message involves using your private key to create a digital signature, which can then be verified using your public key.

2.No, anyone cannot sign a message using just a public key. Signing requires the use of the private key. Verification, however, can be done using the associated public key.

3.There are several trusted tools for signing messages, such as Electrum, Bitcoin Core, and online tools like https://tools.bitcoin.com/signature/.

4.To implement message signing in PHP, you can use libraries like phpseclib or bitwasp/bitcoin along with the necessary Bitcoin functions. Here's a basic example using phpseclib:


php
Edit


include('vendor/autoload.php'); // Include the necessary library

use phpseclib\Crypt\RSA;

// Your private key and message
$privateKey = 'YOUR_PRIVATE_KEY_HERE';
$message = 'Message to sign';

// Create an RSA instance
$rsa = new RSA();
$rsa->loadKey($privateKey); // Load your private key
$signature = $rsa->sign($message); // Sign the message
echo "Signature: $signature"; // Output the signature
?>

Remember to replace 'YOUR_PRIVATE_KEY_HERE' with your actual private key.

References:

Bitcoin Wiki: https://en.bitcoin.it/
phpseclib GitHub: https://github.com/phpseclib/phpseclib




legendary
Activity: 3472
Merit: 3217
Playbet.io - Crypto Casino and Sportsbook
December 17, 2023, 09:11:43 AM
#6
to read the whole project is a big task.

Is there any open-source, simple project which just for implement the signing function. It must be open source, no one will trust this kind of software, even Electrum .if I want to sign a message with more than 100 bitcoins, I really can not trust any software even with big companies.  Do you think so?

I couldn't find any simple PHP code that can sign/verify the message.
The open-sourced that I provided above is owned by fbueller who develop bit-wasp. He is no longer active since 2017.

If you can't trust that source why not run this offline?
Or do you want to run this on your website? If yes then you need to study his code to make sure the codes are safe.
newbie
Activity: 10
Merit: 0
December 16, 2023, 08:01:56 AM
#5
As following tips
1.when I want to sign a message, do I must have the private key?
Without a private key you can't able to sign a message it is required when signing a message.

2.any one can using just public key to sign a message?and pass verification?
No, you can't sign a message with the public key, the private key is required because it proves that you own that wallet or that public key.


3.is there any trusted site or tool for signing?
I do not recommend any web tools to sign a message it's risky I recommend use Electrum Wallet instead.

4.how to implement it by PHP?(code better)

I don't have much knowledge in PHP but check this open source code below in PHP.

Edit:

Verify signed message in PHP
- https://github.com/Bit-Wasp/bitcoin-php/blob/master/examples/signedmessage.verify.php


Create sign message in PHP
- https://github.com/Bit-Wasp/bitcoin-php/blob/master/examples/signedmessage.create.php

You need to install the whole respiratory to make the PHP code above work.


to read the whole project is a big task.

Is there any open source, simple project which just for implement the signing function. It must be open source, no one will trust this kind of software, even Electrum .if I want to sign a message with more than 100 bitcoins, I really can not trust any software even with big companies.  Do you think so?
jr. member
Activity: 35
Merit: 33
December 15, 2023, 09:23:14 PM
#4
BitMaxz has provided a great explanation. For question 4, one additional point to consider is an older GitHub page that might be helpful to you:
https://github.com/BitcoinPHP/BitcoinECDSA.php
legendary
Activity: 3472
Merit: 3217
Playbet.io - Crypto Casino and Sportsbook
December 15, 2023, 07:00:27 PM
#3
As following tips
1.when I want to sign a message, do I must have the private key?
Without a private key you can't able to sign a message it is required when signing a message.

2.any one can using just public key to sign a message?and pass verification?
No, you can't sign a message with the public key, the private key is required because it proves that you own that wallet or that public key.


3.is there any trusted site or tool for signing?
I do not recommend any web tools to sign a message it's risky I recommend use Electrum Wallet instead.

4.how to implement it by PHP?(code better)

I don't have much knowledge in PHP but check this open source code below in PHP.

Edit:

Verify signed message in PHP
- https://github.com/Bit-Wasp/bitcoin-php/blob/master/examples/signedmessage.verify.php


Create sign message in PHP
- https://github.com/Bit-Wasp/bitcoin-php/blob/master/examples/signedmessage.create.php

You need to install the whole respiratory to make the PHP code above work.
sr. member
Activity: 686
Merit: 398
December 15, 2023, 06:09:21 PM
#2
First, you don't need to pay anyone to get a quality reply.
 
Yes, without the private key or phrase that proves complete ownership of a wallet, you can't sign in to a message. You either need the private key to the wallet or the phrase.
 
Some bitcoin wallets have a sign-in message function built into them, so you don't need to use any third-party sites, which might end up compromising your wallet to sign in the message. Personally, I use Electrum and BlueWallet for my transactions and sign in with a few messages.
newbie
Activity: 10
Merit: 0
December 15, 2023, 06:05:30 PM
#1
As following tips
1.when I want to sign a message, do I must have the private key?

2.any one can using just public key to sign a message?and pass verification?

3.is there any trusted site or tool for signing?

4.how to implement it by PHP?(code better)

Thanks a lot ,I pay $50 worth bitcoins for the best reply.
Jump to: