/** * Society Protocol — Identity Module * * Ed25519 keypair generation, did:key derivation, message signing/verification. * Uses @noble/ed25519 for cryptography. */ export interface Identity { privateKey: Uint8Array; publicKey: Uint8Array; did: string; displayName: string; } /** * Generate a new Ed25519 identity with a did:key identifier. * * did:key format: did:key:z6Mk * The 0xed01 prefix is the multicodec for Ed25519 public keys. */ export declare function generateIdentity(displayName: string): Identity; /** * Restore an identity from stored keys. */ export declare function restoreIdentity(privateKeyHex: string, displayName: string): Identity; /** * Canonical JSON serialization (sorted keys, no whitespace). * This ensures deterministic serialization for signing. */ export declare function canonicalJson(obj: unknown): string; /** * Deep canonical JSON serialization (recursively sorts all nested objects). */ export declare function deepCanonicalJson(obj: unknown): string; /** * Sign a message (canonical JSON bytes) with the identity's private key. * Returns base64-encoded signature. */ export declare function sign(identity: Identity, message: string): string; /** * Verify a signature against a message and public key. */ export declare function verify(publicKey: Uint8Array, message: string, signatureBase64: string): boolean; /** * Generate an identity with proof-of-work to resist Sybil attacks. * * The PoW requirement forces an attacker to spend O(2^difficulty) hash * evaluations per identity, making mass DID creation economically infeasible. * * The proof is: SHA-512(did || nonce) must have `difficulty` leading zero bits. * The nonce is stored alongside the identity for verification. * * @param displayName - Human-readable name for the identity * @param difficulty - Number of leading zero bits required (default: 16 ≈ 65K hashes) * @returns Identity with proof-of-work nonce */ export declare function generateIdentityWithPoW(displayName: string, difficulty?: number): Identity & { powNonce: number; powDifficulty: number; }; /** * Verify a proof-of-work for a DID. * Returns true if SHA-512(did || nonce) has the required leading zero bits. */ export declare function verifyIdentityPoW(did: string, nonce: number, difficulty: number): boolean; /** * Extract public key bytes from a did:key string. */ export declare function publicKeyFromDid(did: string): Uint8Array; //# sourceMappingURL=identity.d.ts.map