How should callableArgs in compute() of the Enigma contract be formatted?

Hi, I’m trying to write a smart contract for tallying encrypted votes (inspired by https://blog.enigma.co/private-voting-for-tcrs-with-enigma-b441b5d4fa7b), where I want to pass a bytes32[] of encrypted votes as the input argument. However, I can’t figure out whether the current Enigma contract supports this; compute() only provides a bytes field callableArgs, which the doc says is “encrypted a priori”, but provides no further details as to how it’s formatted. Does it mean that I should tightly-pack arguments in plaintext first and then encrypt, or does it mean I can encrypt each argument (and each item in arrays) individually and pack the ciphertext together? I would appreciate some clarification.

I looked at the CoinMixer contract, which does something similar to what I want to do (pass array of encrypted data), but it literally just passes an empty bytes var to compute() LMAO. It would be great if the devs can provide some contract examples that are not dummies, now that the testnet is out.

We’re working on a tutorial and more examples. This will be available soon. In the meantime, this might help: https://github.com/enigmampc/enigma-contract/blob/develop/integration/coin-mixer-2.js.

Hi, can you tell me how exactly encrypted arguments will be differentiated from plaintext arguments? The documentation says that encrypted arguments need to be prefixed with “" in the function signature string, but in the file you provided the signature does not "” prefix the encryptedAddresses argument. Thanks.

You’re right. We will update the documentation to remove this. Encrypted arguments are automatically recognized by the worker. You do not have to do anything to differentiate them other than simply encrypting them.

1 Like