{"id":26502152,"url":"https://github.com/grunch/mostro-mediator","last_synced_at":"2025-07-31T04:05:14.784Z","repository":{"id":282423796,"uuid":"948546551","full_name":"grunch/mostro-mediator","owner":"grunch","description":"Mostro P2P dispute mediator (proof of concept)","archived":false,"fork":false,"pushed_at":"2025-03-14T14:28:15.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T15:36:59.318Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grunch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-14T14:25:53.000Z","updated_at":"2025-03-14T14:28:19.000Z","dependencies_parsed_at":"2025-03-14T18:15:55.238Z","dependency_job_id":null,"html_url":"https://github.com/grunch/mostro-mediator","commit_stats":null,"previous_names":["grunch/mostro-mediator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grunch%2Fmostro-mediator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grunch%2Fmostro-mediator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grunch%2Fmostro-mediator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grunch%2Fmostro-mediator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grunch","download_url":"https://codeload.github.com/grunch/mostro-mediator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244662721,"owners_count":20489793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-20T17:35:44.171Z","updated_at":"2025-03-20T17:35:44.656Z","avatar_url":"https://github.com/grunch.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MostroMediator\n\n**MostroMediator** is a Rust program demonstrating a cryptographic mechanism for secure peer-to-peer (P2P) communication and dispute resolution, built on the [Nostr protocol](https://nostr.com/) using the `nostr-sdk` library. It leverages Elliptic Curve Diffie-Hellman (ECDH) to generate a shared key between two parties (e.g., Alice and Bob), which can be voluntarily shared with a third party to resolve disputes in systems like [Mostro](https://mostro.network/). The program encrypts messages using this shared key, ensuring privacy, authenticity, and the ability to reveal the truth if needed.\n\n## Features\n\n- **Shared Key Generation**: Creates a shared secret between two parties using ECDH (secp256k1).\n- **Message Encryption**: Wraps messages in a simplified, non-standard NIP-59-like \"gift wrap\" event, signed by the sender and encrypted to the shared key.\n- **Dispute Resolution**: Allows both parties to share the shared key with a mediator to decrypt and verify messages in case of a dispute.\n- **Nostr Integration**: Built with `nostr-sdk` for key management, event creation, and verification.\n\n## Use Case\n\nIn P2P marketplaces like Mostro, disputes between buyers and sellers can occur. MostroMediator enables secure communication between parties, with the option to reveal encrypted messages to a trusted third party if a dispute arises. This ensures transparency and accountability without compromising initial privacy.\n\n## Prerequisites\n\n- Rust (stable recommended, e.g., `1.75.0` or later).\n\n## Installation\n\nClone the repository:\n\n```bash\n    git clone https://github.com/grunch/MostroMediator.git\n    cd MostroMediator\n```\n\nRun the program:\n\n```bash\n    cargo run\n```\n\n## Usage\n\nThe program currently demonstrates a hardcoded example with Alice and Bob:\n\n- Alice and Bob generate a shared key using their private and public keys.\n- Alice encrypts a message (\"Let’s reestablish the peer-to-peer nature of Bitcoin!\") to the shared key.\n- Bob (or any party with the shared key) decrypts and verifies the message.\n- In a dispute, Alice and Bob can share the shared key with a mediator to decrypt and inspect the message.\n\n## Example output:\n\n```\nAlice PubKey: npub1qqq98sa5wucc9e7ycxmjkfedxjlqr06yzjn2yhye39mu294ydgqsf8r490\nShared PubKey: npub1yvxg2xdp66jrf58hz6mk6p7n9rfrw7nqpfvzuva8q282d2pwypdsdy7l6r\nShared private key: def6633a53d07d1e829484c4d4bdbbeed2f4b14c21743e63871c174338e39475\nBob PubKey: npub1qqqqntjul70kh2ds29v7chk43sv87kyzafmus8k4m5v3vvnj5htshl66x6\nOuter event: {...}\nInner event: {...}\n```\n\nTo adapt this for real-world use:\n\n- Replace hardcoded keys with dynamic inputs.\n- Integrate with a Nostr relay for event transmission.\n- Extend mostro_wrap and mostro_unwrap for additional functionality.\n\n## Code Structure\n\n- main(): Orchestrates the key generation, encryption, and decryption process.\n- mostro_wrap(): Creates a signed and encrypted \"gift wrap\" event.\n- mostro_unwrap(): Decrypts and verifies the inner event using the shared key.\n\n## How It Works\n\n- Key Setup: Alice and Bob each have a keypair (private/public).\n- Shared Key: Generated via ECDH using Alice’s private key and Bob’s public key (or vice versa).\n- Encryption: Alice signs a message and encrypts it to the shared key using a custom NIP-59-like wrapper.\n- Decryption: Bob uses the shared key to decrypt and verify the message.\n- Dispute Resolution: If a dispute occurs, both parties can share the shared key with a mediator, who can decrypt and verify the message to determine the truth.\n\n## License\n\nThis project is licensed under the MIT License. See LICENSE for details.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n\n## Acknowledgments\n\n- Built with nostr-sdk.\n- Inspired by Nostr NIP-59 and Mostro.\n- Thanks to the Nostr and Rust communities!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrunch%2Fmostro-mediator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrunch%2Fmostro-mediator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrunch%2Fmostro-mediator/lists"}