nostringer
Version:
Unlinkable ring signatures for Nostr-compatible secp256k1 keys
39 lines (38 loc) • 1.52 kB
TypeScript
/**
* A ring signature consists of an initial challenge `c0`
* plus a list of response scalars `s[]`.
*/
export interface RingSignature {
c0: string;
s: string[];
}
/** Supported formats for generating a new public key. */
export type KeyFormat = "compressed" | "uncompressed" | "xonly";
/**
* Sign a message using a SAG ring signature approach:
* - `message`: the data being signed
* - `privateKeyHex`: 64-hex (32 bytes)
* - `ringPubKeysHex`: each can be x-only (64-hex), compressed (66-hex), or uncompressed (130-hex).
*
* Returns { c0, s[] } with each scalar in 64‑hex.
*/
export declare function sign(message: string | Uint8Array, privateKeyHex: string, ringPubKeysHex: string[]): RingSignature;
/**
* Verify a SAG ring signature:
* - `signature` = { c0, s[] }, each 64‑hex
* - `message`
* - `ringPubKeysHex`: array of x-only, compressed, or uncompressed pubkeys
*/
export declare function verify(signature: RingSignature, message: string | Uint8Array, ringPubKeysHex: string[]): boolean;
/**
* Generate a new random secp256k1 key pair in the requested format:
* - `"compressed"` => 66‑hex public key (33 bytes, starts with 02/03)
* - `"uncompressed"` => 130‑hex public key (65 bytes, starts with 04)
* - `"xonly"` => 64‑hex representing just the X coordinate (assuming even Y)
*
* Returns an object { privateKeyHex, publicKeyHex }.
*/
export declare function generateKeyPair(format?: KeyFormat): {
privateKeyHex: string;
publicKeyHex: string;
};