Skip to content

/utils/schnorrSign API metod#2290

Open
kushti wants to merge 10 commits intov6.0.3from
schnorrSign
Open

/utils/schnorrSign API metod#2290
kushti wants to merge 10 commits intov6.0.3from
schnorrSign

Conversation

@kushti
Copy link
Member

@kushti kushti commented Jan 16, 2026

Schnorr Signature API Specification

Overview

The new /utils/schnorrSign endpoint allows users to generate Schnorr signatures for arbitrary messages using the private key associated with a specified P2PK address in the node's wallet. It would be useful for offchain applications working with Schnorr signature verifying contracts, see https://www.ergoforum.org/t/verifying-schnorr-signatures-in-ergoscript/3407

API Endpoint

POST /utils/schnorrSign

Request Format

{
  "signerAddress": "3WwbzW6u8hKWBcL1W7kNVMr25s2UHfSBnYtwSHvrRQt7DdPuoXrt",
  "message": "68656c6c6f20776f726c64"
}

Parameters

  • signerAddress (string, required): The P2PK address whose associated private key will be used for signing
  • message (string, required): The hex-encoded message to be signed

Response Format

On success (HTTP 200):

{
  "signedMessage": "68656c6c6f20776f726c64",
  "signature": "01abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
  "publicKey": "02a7955281885bf0f0ca4a48678848cad8dc5b328ce8bc1d4481d041c98e891ff3"
}

Response Fields

  • signedMessage: The hex-encoded signed message
  • signature: The hex-encoded Schnorr signature (concatenated R and s values)
  • publicKey: The hex-encoded public key used for signing

Error Responses

  • HTTP 400: Invalid address, message, or node does not have the secret key for the specified address
  • HTTP 500: Internal server error (e.g., wallet not initialized)

Signing Process

  1. The API validates that the provided signerAddress is a valid P2PK address
  2. It looks up the corresponding extended public key in the wallet
  3. It retrieves the private key for the derivation path associated with that public key
  4. It generates a Schnorr signature using the following algorithm:
    • Generate a random nonce k
    • Calculate point a = g^k (where g is the generator)
    • Calculate challenge e = H(a || message || publicKey)
    • Calculate response z = k + e * s (mod n) where s is the private key
    • Return signature as a concatenated with z

Usage Example

curl -X POST http://localhost:9053/utils/schnorrSign \
  -H "Content-Type: application/json" \
  -d '{
    "signerAddress": "3WwbzW6u8hKWBcL1W7kNVMr25s2UHfSBnYtwSHvrRQt7DdPuoXrt",
    "message": "68656c6c6f20776f726c64"
  }'

Prerequisites

  • The node must have the private key for the specified address in its wallet
  • The address must be a valid P2PK address
  • The message must be properly hex-encoded

@kushti kushti changed the base branch from master to v6.0.3 February 5, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant