-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathsign-message.php
More file actions
28 lines (18 loc) · 871 Bytes
/
sign-message.php
File metadata and controls
28 lines (18 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/**
* Demonstrates how to sign and verify a message using Stellar keypairs
*/
require '../vendor/autoload.php';
use \ZuluCrypto\StellarSdk\Keypair;
$message = 'test stellar message';
// Sign the message: private key is required
// GDRXE2BQUC3AZNPVFSCEZ76NJ3WWL25FYFK6RGZGIEKWE4SOOHSUJUJ6
$signingKeypair = Keypair::newFromSeed('SBGWSG6BTNCKCOB3DIFBGCVMUPQFYPA2G4O34RMTB343OYPXU5DJDVMN');
$signatureBytes = $signingKeypair->sign($message);
printf("Signed (base-64 encoded): " . base64_encode($signatureBytes) . PHP_EOL);
// Verify the signature
// Note that only the public key is required
$verifyingKeypair = Keypair::newFromPublicKey('GDRXE2BQUC3AZNPVFSCEZ76NJ3WWL25FYFK6RGZGIEKWE4SOOHSUJUJ6');
$isVerified = $verifyingKeypair->verifySignature($signatureBytes, $message);
printf(PHP_EOL);
printf("Verified? %s" . PHP_EOL, ($isVerified) ? 'Yes' : 'No');