0

Two accounts want to use a smart contract to exchange (with SSTORE) the public parameters for a Diffie-Hellman key exchange, and use their private keys to generate the shared symmetric key. Is there any publicly deployed contract for this? SmartDHX seems like an example of one project that worked on something along those lines, overall seems relatively easy service to provide, and possible that there are working public contracts for this.

Johan
  • 23
  • 3

1 Answers1

0

Having looked at this now, the only public parameter that is needed is the public key of an account (to newcomers, the address is distinct from the public key and calculated from it. ) So a contract where people publish their public key is needed.

contract PublicKey {
    mapping (address => bytes) public publicKey;
    function publish(bytes _publicKey) external {
        // validate _publicKey to tx.origin, if not valid revert
        publicKey[tx.origin] = _publicKey;
    }
}

Any implementation of diffie hellman on secp256k1 with parameters used on Ethereum (and most other blockchains incl. Bitcoin) can then be used. This one looks good, https://github.com/andreacorbellini/ecc/blob/master/scripts/ecdhe.py.

Johan
  • 23
  • 3