Skip to content

feat: implement confidential payment helpers for Pedersen commitment generation and reveal#430

Open
mayborn005 wants to merge 1 commit into
Stellar-split:mainfrom
mayborn005:feat/confidential-payment-helpers
Open

feat: implement confidential payment helpers for Pedersen commitment generation and reveal#430
mayborn005 wants to merge 1 commit into
Stellar-split:mainfrom
mayborn005:feat/confidential-payment-helpers

Conversation

@mayborn005

Copy link
Copy Markdown

Summary

Implements Issue #420 - Confidential payment helpers for Pedersen commitment generation and reveal.

New Functions:

  • generateCommitment(amount): Generates cryptographic Pedersen commitment (C = aH + vG)
  • verifyCommitment(): Verifies commitment matches value and blinding factor
  • storeBlindingFactor(): Encrypts and stores blinding factor in IndexedDB/localStorage
  • loadBlindingFactor(): Decrypts and retrieves stored blinding factor
  • deleteBlindingFactor(): Removes stored blinding factor
  • buildRevealTransaction(): Builds reveal_payment contract call
  • generateAndStoreCommitment(): Convenience function combining generation and storage
  • buildRevealTransactionFromStorage(): Convenience function for reveal flow

Features:

  • Uses secp256k1 curve via @noble/curves for elliptic curve operations
  • Session-based AES-256-GCM encryption for blinding factor storage
  • Supports IndexedDB with localStorage fallback
  • Tamper detection for modified values or blinding factors

New Error Types:

  • CommitmentGenerationError
  • BlindingFactorStorageError
  • BlindingFactorNotFoundError
  • BlindingFactorDecryptionError

Test plan

  • Commitment generation produces valid 33-byte compressed points
  • Different commitments generated for same amount (randomness)
  • Commitment/reveal roundtrip verification works
  • Tampered value detection (wrong amount fails verification)
  • Wrong blinding factor detection
  • Blinding factor storage and retrieval works
  • Missing blinding factor returns null
  • Reveal transaction builds correctly
  • Error type guards work correctly
  • All 31 tests pass

Closes #420

…tion and reveal

Implements Issue Stellar-split#420 - Confidential payment helpers using Pedersen commitments:

- generateCommitment(amount): Generates cryptographic Pedersen commitment
- verifyCommitment(): Verifies commitment matches value and blinding factor
- storeBlindingFactor(): Encrypts and stores blinding factor in IndexedDB
- loadBlindingFactor(): Decrypts and retrieves stored blinding factor
- buildRevealTransaction(): Builds reveal_payment contract call
- Convenience functions: generateAndStoreCommitment, buildRevealTransactionFromStorage

Features:
- Uses secp256k1 curve via @noble/curves for elliptic curve operations
- Session-based AES-256-GCM encryption for blinding factor storage
- Supports IndexedDB with localStorage fallback
- Tamper detection for modified values or blinding factors
- 31 comprehensive tests covering roundtrip verification
@Kingsman-99

Copy link
Copy Markdown
Contributor

Please resolve you conflict and make sure there is no conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement confidential payment helpers for Pedersen commitment generation and reveal

3 participants