Skip to content

Implement confidential payment helpers for Pedersen commitment generation and reveal #420

Description

@Kingsman-99

Overview

Add TypeScript helpers for the confidential payment flow — generate a Pedersen commitment for a payment amount, store the blinding factor securely, and build the reveal transaction when the payer is ready to settle.

Requirements

  • generateCommitment(amount: bigint): { commitment: Buffer, blindingFactor: Buffer } — generates a cryptographic Pedersen commitment
  • buildRevealTransaction(invoiceId: bigint, value: bigint, blindingFactor: Buffer, payer: string): Transaction — builds the reveal_payment contract call
  • storeBlindingFactor(invoiceId: bigint, blindingFactor: Buffer): void — encrypts and stores locally (using Web Crypto API)
  • loadBlindingFactor(invoiceId: bigint): Buffer | null — decrypts and retrieves stored blinding factor
  • Use @noble/curves or @noble/secp256k1 for elliptic curve operations (no heavy dependencies)
  • Write tests verifying commitment/reveal roundtrip, tampered value detected, missing blinding factor handled

Acceptance Criteria

  • Commitment generation produces valid 32-byte commitments
  • Reveal transaction builds correctly
  • Blinding factor storage/retrieval works
  • Tampered inputs detected
  • npm test passes with zero failures
  • TypeScript compiles with zero errors
  • ESLint passes with zero errors

Definition of Done

All CI checks must pass before the PR is reviewed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions