Add LoveEnvelope secret/bearer-code contract #6
- @julien opened this issue · Sep 18, 2026edited
What
Implement the on-chain mechanism assumed by docs/notes/add-privacy-to-love.md: a
LoveEnvelopecontract that lets a depositor lock LOVE behind a secret hash instead of a recipient address, and lets whoever later proves knowledge of the secret withdraw against it.deposit(bytes32 secretHash, uint256 amount) returns (uint256 depositId)— locksamountLOVE under an auto-incrementingdepositId, storingsecretHashand a decrementingremainingbalance.withdraw(uint256 depositId, bytes32 secret, uint256 amount)— bearer-note semantics: no recipient check, whoever supplies the correct preimage first is paid. Reusable untilremaininghits zero.- Events
Deposited/Withdrawn, matching the naming used in the note.
Why
The note documents the off-chain processes (secret generation, encoding, distribution, timing discipline) around this mechanism, but the mechanism itself doesn't exist yet in this repo — only the unrelated wETH-peg
deposit/withdrawinLove.soldoes.Done looks like
src/LoveEnvelope.solwith the two functions above, custom errors, and NatSpec in the repo's existing style.test/LoveEnvelope.t.solcovering full/partial withdrawal, remaining accounting, independent envelopes, and the wrong-secret / insufficient-remaining / unknown-deposit / zero-amount revert paths, plus fuzzing.forge testandforge fmt --checkpass.
Deploy script, CREATE2 determinism and off-chain tooling are explicitly out of scope for this issue.
- @julien · Sep 18, 2026edited
Closed via 5 — merged 13964fbd8e7ff218c363dce3e0cfb9fd515c655f into main.
Sign in to comment.