Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Peer Snitching Contract #248

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Emit submissions in events rather than storing them
theref committed Mar 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit cc8df57b3415749c849fac561db0d434ea3066e4
18 changes: 10 additions & 8 deletions contracts/contracts/TACoEvidence.sol
Original file line number Diff line number Diff line change
@@ -16,15 +16,18 @@ contract TACoEvidence {
uint256 nonce
);

struct Submission {
address operator;
bytes32 evidence;
}
event SubmissionSubmitted(
uint32 indexed id,
address indexed operator,
bytes[] evidence,
address[] peers
);

struct Collection {
uint32 initTimestamp;
uint32 endTimestamp;
uint256 nonce;
mapping(address => Submission[]) submissions;
mapping(address => mapping(address => bool)) submissions;
}

ITACoChildApplication public immutable application;
@@ -71,6 +74,7 @@ contract TACoEvidence {
"Submission period closed"
);
require(signatures.length == peers.length, "Mismatched inputs");
emit SubmissionSubmitted(id, msg.sender, signatures, peers);

// Verify each signature
for (uint256 i = 0; i < signatures.length; i++) {
@@ -84,9 +88,7 @@ contract TACoEvidence {
.toEthSignedMessageHash();
address signer = message.recover(signatures[i]);
if (signer == peers[i]) {
collection.submissions[msg.sender].push(
Submission({operator: peers[i], evidence: signatures[i]})
);
collection.submissions[msg.sender][peers[i]] = true;
}
}
}