Skip to content

Instantly share code, notes, and snippets.

@starbackr-dev
starbackr-dev / nut15.md
Last active March 23, 2024 14:35
NUT-15: Authentication with Schnorr Signatures

NUT-15: Authentication with Schnorr Signatures

==========================

optional use with: NUT-04, NUT-05

In this document, we describe a mechanism for obtaining time-bounded OAuth bearer tokens using Schnorr signatures for accessing protected endpoints for a mint. This specifically applies only for minting (NUT-04) and melting tokens (NUT-05). This NUT provides the mint with the ability to restrict who can mint and melt cashu tokens or, in some cases, implement temporary time-bound restrictions.

The registration process for authorizing public keys is outside the scope of this NUT and should be implemented separately by the mint. The mint should generate and store auth tokens based on the described authentican flow below. The auth tokens will be time bounded with an explict expiry time, after which the tokens should be destroyed by the mint.

NOTE: This NUT does not apply to swapping tokens (NUT-03) to preserve users' privacy and utilize spending conditions (NUT-10) to restrict swapping when req

const {WebSocket} = require('websocket-polyfill');
const {relayInit,
getEventHash,
getPublicKey,
verifySignature,
signEvent,
generatePrivateKey} = require('nostr-tools');
const https = require('https');
//********* Constants **********************************************************************
@starbackr-dev
starbackr-dev / nip59.js
Created May 29, 2023 19:20
This code demonstrates how clients can implement NIP-59 for secure DMs using a paid relay which requires AUTH (NIP-42)
const {WebSocket} = require('websocket-polyfill');
const {relayInit,nip04,
getEventHash,
getPublicKey,
verifySignature,
signEvent,
nip42,finishEvent,
generatePrivateKey} = require('nostr-tools');