Download the PHP package uma/secp256k1-nostr without Composer

On this page you can find all versions of the php package uma/secp256k1-nostr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package secp256k1-nostr

secp256k1_nostr extension for PHP

CI

secp256k1_nostr is a PHP 7.4+ extension to validate Nostr events in accordance to NIP-01.

It is implemented as a thick, opinionated wrapper around Bitcoin Core's libsecp256k1.

Sample Usage

The above script will output:

Installation (Linux)

These instructions are tailored for Ubuntu 24.04 LTS. Nevertheless, only the first step might be a bit different on other Linux distributions that don't use the APT package manager.

  1. Install the required dependencies to build both the extension and secp256k1.

  2. Clone this repository:

  3. Build the extension (secp256k1_nostr.so), then install it into your local PHP runtime. The 'install' command will likely require sudo privileges. Optionally, you can run the tests with make check before installing.

    If your Linux distro doesn't have packages (or the minimum required version) for libsodium or libsecp256k1 you can build these dependencies in-tree. For that you'll need to clone the submodules of the repository and run make ext-with-deps instead of make ext:

  4. Append extension=secp256k1_nostr.so to your php.ini file. Note that often the PHP CLI and PHP-FPM have separate php.ini files, so you need to edit both. Finally, test that the extension loads correctly with php -m.

Full API

See secp256k1_nostr.stub.php

F.A.Q.

How do I generate a private key?

A private key is just a random string of 32 bytes. The only caveat is that it has to be hex-encoded.

All functions of secp256k1_nostr only accept hex-encoded strings to lessen the friction of working with Nostr events.

There is an exceedingly remote possibility that the bytes are out of range for a valid private key. In this case secp256k1_nostr_derive_pubkey() would throw an exception, but in practice this should never happen unless you deliberately feed the function a faulty private key such as 0000000000000000000000000000000000000000000000000000000000000000.

Are there stubs for the secp256k1_nostr functions?

Yes. Simply use Composer to install uma/secp256k1-nostr as a development dependency of your project:

NOTICE: This isn't a substitute for the real installation steps described above. This will just make the secp256k1_nostr.stub.php file visible to your IDE so that it's aware of the extension functions. But this does not install the extension, which is really the secp256k1_nostr.so file mentioned earlier.

What was the motivation for developing this extension?

I recently started working on a toy Nostr relay written in async PHP, and a central class in that project is the "Event" domain object that verifies its own signature at construction time.

As I wrote the first handful of unit tests I quickly found out that the existing PHP Schnorr libraries are very slow, therefore I built myself this native extension.

It can be used in any context where Nostr events need to be validated in PHP, not just relays.

How does this extension compare to secp256k1-php?

secp256k1-php is a generic binding to the libsecp256k1 library that exposes its full API function by function (also known as a "thin wrapper"). In contrast secp256k1_nostr is a "thick wrapper" that is tailored for Nostr event validation, in this case libsecp256k1 is just an implementation detail.

secp256k1_nostr could've been written on top of secp256k1-php as a regular PHP library, but unfortunately the project seems abandoned. As I write this it hasn't seen activity on the master branch for 4 years, and the code doesn't even compile on PHP 8.0 and up.

If you need a libsecp256k1 binding that exposes all its functionality you should try to revive that project.

Does secp256k1_nostr follow semantic versioning?

Yes, but the API may still evolve before the 1.0 release.

Is Windows supported?

No, and I don't intend to work on this. But a PR would be welcome.

Is secp256k1_nostr available on PECL?

No :')


All versions of secp256k1-nostr with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package uma/secp256k1-nostr contains the following files

Loading the files please wait ....