Skip to content

Commit

Permalink
Use structs in events rather than using flattened structs as per gako…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeaster committed Sep 28, 2022
1 parent 4be899e commit f8d0d9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/DKG.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ contract DKG is IThresholdNetwork {
// event emitted when the DKG is ready to start

event NewParticipant(address from, uint32 index, uint256 tmpKey);
// TODO change when this is fixed https://github.com/gakonst/ethers-rs/issues/1220
event DealBundleSubmitted(
uint256 dealerIdx, Bn128.G1Point random, uint32[] indices, uint256[] shares, Bn128.G1Point[] commitment
);
event DealBundleSubmitted(uint256 dealerIdx, DealBundle bundle);
event ValidComplaint(address from, uint32 evicted);

constructor(DKGFactory _factory) {
Expand Down Expand Up @@ -115,7 +112,7 @@ contract DKG is IThresholdNetwork {
}

function emitDealBundle(uint32 _index, DealBundle memory _bundle) private {
emit DealBundleSubmitted(_index, _bundle.random, _bundle.indices, _bundle.encryptedShares, _bundle.commitment);
emit DealBundleSubmitted(_index, _bundle);
}

// TODO
Expand Down
12 changes: 5 additions & 7 deletions src/EncryptionOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ interface IEncryptionOracle is IThresholdNetwork {
function requestReencryption(uint256 _cipherId, Bn128.G1Point memory _publickey) external returns (uint256);
// returns the ciphertext id
function submitCiphertext(Ciphertext memory _cipher) external returns (uint256);
// TODO Fix with a proper struct once
// https://github.com/gakonst/ethers-rs/issues/1219 is fixed

event NewCiphertext(uint256 indexed id, uint256 rx, uint256 ry, uint256 cipher, address client);
event ReencryptionRequest(uint256 indexed cipherId, uint256 requestId, uint256 pubx, uint256 puby, address client);
event NewCiphertext(uint256 indexed id, Ciphertext ciphertext, address client);
event ReencryptionRequest(uint256 indexed cipherId, uint256 requestId, Bn128.G1Point publicKey, address client);
}

error RequestDoesNotExist();
Expand Down Expand Up @@ -66,19 +64,19 @@ abstract contract EncryptionOracle is IEncryptionOracle {

function submitCiphertext(IEncryptionOracle.Ciphertext memory _cipher) external returns (uint256) {
uint256 id = newCipherId();
emit NewCiphertext(id, _cipher.random.x, _cipher.random.y, _cipher.cipher, msg.sender);
emit NewCiphertext(id, _cipher, msg.sender);
return id;
}

// TODO payable etc
// the public key is the public key of the recipient. Note the msg.sender
// MUST be the one that submitted the ciphertext in the first place
// otherwise the oracle will not reply
function requestReencryption(uint256 _cipherId, Bn128.G1Point memory _publickey) public returns (uint256) {
function requestReencryption(uint256 _cipherId, Bn128.G1Point memory _publicKey) public returns (uint256) {
// TODO check correct key
uint256 requestId = newRequestId();
pendingRequests[requestId] = PendingRequest(msg.sender);
emit ReencryptionRequest(_cipherId, requestId, _publickey.x, _publickey.y, msg.sender);
emit ReencryptionRequest(_cipherId, requestId, _publicKey, msg.sender);
return requestId;
}

Expand Down
6 changes: 2 additions & 4 deletions src/RoleACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ contract RoleACL is AccessControlEnumerable, IEncryptionClient {
oracle = IO(_oracleAddress);
}

// TODO Fix with a proper struct once
// https://github.com/gakonst/ethers-rs/issues/1219 is fixed
// request id
// TODO fix by giving the ciphertext ID AND the request ID
// we can't differentiate otherwise
event NewOracleResult(uint256 requestId, uint256 rx, uint256 ry, uint256 cipher);
event NewOracleResult(uint256 requestId, IO.Ciphertext ciphertext);

function oracleResult(uint256 _requestId, IO.Ciphertext memory _cipher) external {
require(msg.sender == address(oracle), "only oracle can submit results");
// TODO : some checks ? do we handle pending requests here etc ?
emit NewOracleResult(_requestId, _cipher.random.x, _cipher.random.y, _cipher.cipher);
emit NewOracleResult(_requestId, _cipher);
}

// TODO add different roles, payable etc
Expand Down

0 comments on commit f8d0d9c

Please sign in to comment.