Skip to content

Commit d005e48

Browse files
committed
chore(gateway-contracts): rename counterShares to indexShare and make it start at 0
1 parent 087c1b8 commit d005e48

File tree

6 files changed

+37
-29
lines changed

6 files changed

+37
-29
lines changed

gateway-contracts/contracts/Decryption.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,15 @@ contract Decryption is
549549
txSenderAddresses.push(msg.sender);
550550

551551
// Store the user decrypted share for the user decryption response.
552-
emit UserDecryptionResponse(decryptionId, txSenderAddresses.length, userDecryptedShare, signature, extraData);
552+
// The index of the share is the length of the txSenderAddresses - 1 so that the first response
553+
// associated to this decryptionId has an index of 0.
554+
emit UserDecryptionResponse(
555+
decryptionId,
556+
txSenderAddresses.length - 1,
557+
userDecryptedShare,
558+
signature,
559+
extraData
560+
);
553561

554562
// Send the event if and only if the consensus is reached in the current response call.
555563
// This means a "late" response will not be reverted, just ignored and no event will be emitted

gateway-contracts/contracts/interfaces/IDecryption.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ interface IDecryption {
7878
/**
7979
* @notice Emitted when an public decryption response is made.
8080
* @param decryptionId The decryption request ID associated with the response.
81-
* @param counterShares The counter of shares associated with the response.
82-
* @param userDecryptedShare The of decryption share reencrypted with the user's public key.
81+
* @param indexShare The index of the share associated with the decryption.
82+
* @param userDecryptedShare The decryption share reencrypted with the user's public key.
8383
* @param signature The signature of the KMS connector that responded.
8484
* @param extraData Generic bytes metadata for versioned payloads. First byte is for the version.
8585
*/
8686
event UserDecryptionResponse(
8787
uint256 indexed decryptionId,
88-
uint256 counterShares,
88+
uint256 indexShare,
8989
bytes userDecryptedShare,
9090
bytes signature,
9191
bytes extraData

gateway-contracts/contracts/mocks/DecryptionMock.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ contract DecryptionMock {
3636

3737
event UserDecryptionResponse(
3838
uint256 indexed decryptionId,
39-
uint256 counterShares,
39+
uint256 indexShare,
4040
bytes userDecryptedShare,
4141
bytes signature,
4242
bytes extraData
@@ -104,9 +104,9 @@ contract DecryptionMock {
104104
bytes calldata signature,
105105
bytes calldata extraData
106106
) external {
107-
uint256 counterShares;
107+
uint256 indexShare;
108108

109-
emit UserDecryptionResponse(decryptionId, counterShares, userDecryptedShare, signature, extraData);
109+
emit UserDecryptionResponse(decryptionId, indexShare, userDecryptedShare, signature, extraData);
110110

111111
emit UserDecryptionResponseThresholdReached(decryptionId);
112112
}

gateway-contracts/rust_bindings/src/decryption.rs

Lines changed: 10 additions & 10 deletions
Large diffs are not rendered by default.

gateway-contracts/rust_bindings/src/i_decryption.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface IDecryption {
4747
event PublicDecryptionRequest(uint256 indexed decryptionId, SnsCiphertextMaterial[] snsCtMaterials, bytes extraData);
4848
event PublicDecryptionResponse(uint256 indexed decryptionId, bytes decryptedResult, bytes[] signatures, bytes extraData);
4949
event UserDecryptionRequest(uint256 indexed decryptionId, SnsCiphertextMaterial[] snsCtMaterials, address userAddress, bytes publicKey, bytes extraData);
50-
event UserDecryptionResponse(uint256 indexed decryptionId, uint256 counterShares, bytes userDecryptedShare, bytes signature, bytes extraData);
50+
event UserDecryptionResponse(uint256 indexed decryptionId, uint256 indexShare, bytes userDecryptedShare, bytes signature, bytes extraData);
5151
event UserDecryptionResponseThresholdReached(uint256 indexed decryptionId);
5252
5353
function checkDecryptionDone(uint256 decryptionId) external view;
@@ -614,7 +614,7 @@ interface IDecryption {
614614
"internalType": "uint256"
615615
},
616616
{
617-
"name": "counterShares",
617+
"name": "indexShare",
618618
"type": "uint256",
619619
"indexed": false,
620620
"internalType": "uint256"
@@ -4046,7 +4046,7 @@ event UserDecryptionRequest(uint256 indexed decryptionId, SnsCiphertextMaterial[
40464046
#[derive(Default, Debug, PartialEq, Eq, Hash)]
40474047
/**Event with signature `UserDecryptionResponse(uint256,uint256,bytes,bytes,bytes)` and selector `0x7fcdfb5381917f554a717d0a5470a33f5a49ba6445f05ec43c74c0bc2cc608b2`.
40484048
```solidity
4049-
event UserDecryptionResponse(uint256 indexed decryptionId, uint256 counterShares, bytes userDecryptedShare, bytes signature, bytes extraData);
4049+
event UserDecryptionResponse(uint256 indexed decryptionId, uint256 indexShare, bytes userDecryptedShare, bytes signature, bytes extraData);
40504050
```*/
40514051
#[allow(
40524052
non_camel_case_types,
@@ -4059,7 +4059,7 @@ event UserDecryptionResponse(uint256 indexed decryptionId, uint256 counterShares
40594059
#[allow(missing_docs)]
40604060
pub decryptionId: alloy::sol_types::private::primitives::aliases::U256,
40614061
#[allow(missing_docs)]
4062-
pub counterShares: alloy::sol_types::private::primitives::aliases::U256,
4062+
pub indexShare: alloy::sol_types::private::primitives::aliases::U256,
40634063
#[allow(missing_docs)]
40644064
pub userDecryptedShare: alloy::sol_types::private::Bytes,
40654065
#[allow(missing_docs)]
@@ -4105,7 +4105,7 @@ event UserDecryptionResponse(uint256 indexed decryptionId, uint256 counterShares
41054105
) -> Self {
41064106
Self {
41074107
decryptionId: topics.1,
4108-
counterShares: data.0,
4108+
indexShare: data.0,
41094109
userDecryptedShare: data.1,
41104110
signature: data.2,
41114111
extraData: data.3,
@@ -4131,7 +4131,7 @@ event UserDecryptionResponse(uint256 indexed decryptionId, uint256 counterShares
41314131
(
41324132
<alloy::sol_types::sol_data::Uint<
41334133
256,
4134-
> as alloy_sol_types::SolType>::tokenize(&self.counterShares),
4134+
> as alloy_sol_types::SolType>::tokenize(&self.indexShare),
41354135
<alloy::sol_types::sol_data::Bytes as alloy_sol_types::SolType>::tokenize(
41364136
&self.userDecryptedShare,
41374137
),

gateway-contracts/test/Decryption.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,13 +1431,13 @@ describe("Decryption", function () {
14311431
// Check UserDecryptionResponse events are emitted for each response
14321432
await expect(responseTx1)
14331433
.to.emit(decryption, "UserDecryptionResponse")
1434-
.withArgs(decryptionId, 1, userDecryptedShares[0], kmsSignatures[0], extraDataV0);
1434+
.withArgs(decryptionId, 0n, userDecryptedShares[0], kmsSignatures[0], extraDataV0);
14351435
await expect(responseTx2)
14361436
.to.emit(decryption, "UserDecryptionResponse")
1437-
.withArgs(decryptionId, 2, userDecryptedShares[1], kmsSignatures[1], extraDataV0);
1437+
.withArgs(decryptionId, 1n, userDecryptedShares[1], kmsSignatures[1], extraDataV0);
14381438
await expect(responseTx3)
14391439
.to.emit(decryption, "UserDecryptionResponse")
1440-
.withArgs(decryptionId, 3, userDecryptedShares[2], kmsSignatures[2], extraDataV0);
1440+
.withArgs(decryptionId, 2n, userDecryptedShares[2], kmsSignatures[2], extraDataV0);
14411441

14421442
// Threshold should be reached at the third response (reconstruction threshold)
14431443
// Check 3rd response event: it should emit the threshold reached event
@@ -2265,13 +2265,13 @@ describe("Decryption", function () {
22652265
// Check UserDecryptionResponse events are emitted for each response
22662266
await expect(responseTx1)
22672267
.to.emit(decryption, "UserDecryptionResponse")
2268-
.withArgs(decryptionId, 1, userDecryptedShares[0], kmsSignatures[0], extraDataV0);
2268+
.withArgs(decryptionId, 0n, userDecryptedShares[0], kmsSignatures[0], extraDataV0);
22692269
await expect(responseTx2)
22702270
.to.emit(decryption, "UserDecryptionResponse")
2271-
.withArgs(decryptionId, 2, userDecryptedShares[1], kmsSignatures[1], extraDataV0);
2271+
.withArgs(decryptionId, 1n, userDecryptedShares[1], kmsSignatures[1], extraDataV0);
22722272
await expect(responseTx3)
22732273
.to.emit(decryption, "UserDecryptionResponse")
2274-
.withArgs(decryptionId, 3, userDecryptedShares[2], kmsSignatures[2], extraDataV0);
2274+
.withArgs(decryptionId, 2n, userDecryptedShares[2], kmsSignatures[2], extraDataV0);
22752275

22762276
// Threshold should be reached at the third response (reconstruction threshold)
22772277
// Check 3rd response event: it should emit the threshold reached event

0 commit comments

Comments
 (0)