PHP code example of k2gl / signed-note

1. Go to this page and download the library: Download k2gl/signed-note library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

k2gl / signed-note example snippets


use K2gl\SignedNote\Note;
use K2gl\SignedNote\NoteVerifier;
use K2gl\SignedNote\VerifierKey;

$key = VerifierKey::fromString('PeterNeumann+c74f20a3+ARpc2QcUPDhMQegwxbzhKqiBfsVkmqq/LDE4izWy10TW');

$verified = (new NoteVerifier($key))->verify(Note::parse($envelope));
// $verified is the list of NoteSignature that checked out; SignatureVerificationFailed otherwise.

$log = VerifierKey::fromPem('rekor.sigstore.dev - 1193050959916656506', $logPublicKeyPem);
(new NoteVerifier($log))->verify(Note::parse($checkpoint));

use K2gl\SignedNote\Checkpoint;
use K2gl\SignedNote\NoteVerifier;
use K2gl\SignedNote\VerifierKey;

$checkpoint = Checkpoint::parse($envelope);

$checkpoint->origin;     // "log2025-1.rekor.sigstore.dev"
$checkpoint->treeSize;   // 114068855
$checkpoint->rootHash;   // raw 32 bytes
$checkpoint->extensions; // any lines after the first three

$log = VerifierKey::ed25519($checkpoint->origin, $rawEd25519PublicKey); // a Rekor v2 log
$checkpoint->verify(new NoteVerifier($log)); // SignatureVerificationFailed otherwise

use K2gl\SignedNote\SignerKey;

$signer = SignerKey::fromString('PRIVATE+KEY+PeterNeumann+c74f20a3+AYEKFALVFGyNhPJEMzD1QIDr+Y7hfZx09iUvxdXHKDFz');

$note = $signer->sign("hello\n"); // text must end with a newline
echo $note;                       // renders the note with its signature line