web3labs / crux

Data Privacy for Quorum Blockchains
https://www.web3labs.com
Apache License 2.0
53 stars 28 forks source link

two recipients in privateFor #58

Closed thericciflow closed 5 years ago

thericciflow commented 5 years ago

Hi, I am sending a private tx with two pubkeys in the privateFor array but I'm not sure if it is possible in crux current version.

han0110 commented 5 years ago

Hi, we ran into the exact same issue.

Possible reason

The commit 2e0330f1 seems to broke the function store. The change make it call api.Push at the end iteration over recipients instead of the iteration above, however, the encryptedPayload.RecipientBoxes is reset at here to be [][]byte{sealedBox}, which make the end iteration run into panic index out of range

Reproduce

Clone the repo and modify the privateFor in docker/quorum-crux/scripts/simpleContract.js as below

privateFor: ["QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=", "1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg="]

Then run the 4-node example then geth attach to node1, call loadScript('script/simpleContract.js'), you will get err message shown in geth console as below

err creating contract Error: Send Payload failed: rpc error: code = Unavailable desc = transport is closing

Then crux1 will run into panic with these log message:

time="2019-03-14T17:23:50Z" level=debug msg="Processing send request" b64From= b64Recipients="[QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc= 1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=]" payload=606060405234156100000...000002a
time="2019-03-14T17:23:50Z" level=debug msg="Publishing payload" digest=f9477d4522a156e87c8c01e9684c576004466a322e03fc4f32566384a6f04863d75f20b73f9754cb70e4d1e41df06506c12404a19a6d45cff460d70fae798996 recipient=41f783032b3d30f0ecd971c4c6d73ce232861f1660fda8f9d834e1d2fb40dd77
panic: runtime error: index out of range

goroutine 32 [running]:
github.com/blk-io/crux/enclave.(*SecureEnclave).store(0xc4200c66e0, 0xc420077320, 0xc4200a6340, 0xc4200a6360, 0xc4201cb050, 0x2, 0x2, 0x5626780d8dad, 0xc4200c8000, 0xc4205f81e0, ...)
    /quorum/crux/.GOPATH/src/github.com/blk-io/crux/enclave/enclave.go:195 +0xcd8
...
alikefia commented 5 years ago

@thericciflow please see #59 (fixes the problem)