Something went wrong. Try again.
A Social Deduction / Deception Game
Something went wrong. Try again.
1.2 kB · 24 lines
TypeScript
at main
12345678910111213141516171819202122232425// The server's own signing identity (PLAN §8). At round end the server canonically signs each// player's result payload so the log is verifiable and unforgeable — a player can't doctor their// own history. We assume the server already has a keypair; provisioning (where the secret lives,// how the public key is published for verifiers) is left for later.//// Dev default: generate an ephemeral secp256k1 keypair at startup and log its did:key. Production:// set SABOTAGE_SIGNING_KEY to a 32-byte secp256k1 private key (hex) so the identity is stable and// its did:key can be published for verifiers.
import { Secp256k1Keypair } from '@atproto/crypto'
let signerPromise: Promise<Secp256k1Keypair> | null = null
export function getSigner(): Promise<Secp256k1Keypair> { if (!signerPromise) { signerPromise = (async () => { const hex = process.env.SABOTAGE_SIGNING_KEY?.trim() const kp = hex ? await Secp256k1Keypair.import(hex) : await Secp256k1Keypair.create({ exportable: true }) console.log(`[signing] server signing identity: ${kp.did()}${hex ? '' : ' (ephemeral — set SABOTAGE_SIGNING_KEY to persist)'}`) return kp })() } return signerPromise}