Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions crates/evm-helpers/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ sol! {
bytes32 committeePublicKey;
bytes32 ciphertextOutput;
bytes plaintextOutput;
address requester;
}

#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions crates/evm-helpers/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sol! {
bytes32 committeePublicKey;
bytes32 ciphertextOutput;
bytes plaintextOutput;
address requester;
}

#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions crates/indexer/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ impl<S: DataStore, R: ProviderType> EnclaveIndexer<S, R> {
seed,
start_window,
threshold: e3.threshold,
requester: e3.requester.to_string(),
};

let mut repo = E3Repository::new(db, e3_id);
Expand Down
1 change: 1 addition & 0 deletions crates/indexer/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ pub struct E3 {
pub seed: [u8; 32],
pub start_window: [u64; 2],
pub threshold: [u32; 2],
pub requester: String,
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ contract MockEnclave {
decryptionVerifier: IDecryptionVerifier(address(0)),
committeePublicKey: committeePublicKey,
ciphertextOutput: bytes32(0),
plaintextOutput: plaintextOutput
plaintextOutput: plaintextOutput,
requester: address(0)
});
}
}
6 changes: 5 additions & 1 deletion examples/CRISP/server/src/server/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ pub async fn register_e3_requested(
let e3_id = event.e3Id.to::<u64>();
let mut repo = CrispE3Repository::new(store.clone(), e3_id);

let contract = ctx.contract();

info!("[e3_id={}] E3Requested: {:?}", e3_id, event);

async move {
let e3 = contract.get_e3(event.e3Id).await?;

// Convert custom params bytes back to token address and balance threshold.

// Use sol_data types instead of primitives
Expand All @@ -71,7 +75,7 @@ pub async fn register_e3_requested(
.with_context(|| "Invalid token address")?;

// save the e3 details
repo.initialize_round(custom_params.token_address, custom_params.balance_threshold)
repo.initialize_round(custom_params.token_address, custom_params.balance_threshold, e3.requester.to_string())
.await?;

// Get token holders from Etherscan API or mocked data.
Expand Down
6 changes: 6 additions & 0 deletions examples/CRISP/server/src/server/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ pub struct E3StateLite {

pub token_address: String,
pub balance_threshold: String,

pub requester: String,
}

#[derive(Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -212,6 +214,9 @@ pub struct E3 {

// Custom Parameters
pub custom_params: CustomParams,

// The address that requested the E3
pub requester: String,
}

#[derive(Debug, Deserialize, Serialize)]
Expand All @@ -227,6 +232,7 @@ pub struct E3Crisp {
pub token_address: String,
pub balance_threshold: String,
pub ciphertext_inputs: Vec<(Vec<u8>, u64)>,
pub requester: String,
}

impl From<E3> for WebResultRequest {
Expand Down
4 changes: 3 additions & 1 deletion examples/CRISP/server/src/server/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl<S: DataStore> CrispE3Repository<S> {
&mut self,
token_address: String,
balance_threshold: String,
requester: String,
) -> Result<()> {
self.set_crisp(E3Crisp {
has_voted: vec![],
Expand All @@ -147,6 +148,7 @@ impl<S: DataStore> CrispE3Repository<S> {
token_address,
balance_threshold,
ciphertext_inputs: vec![],
requester
})
.await
}
Expand Down Expand Up @@ -237,6 +239,7 @@ impl<S: DataStore> CrispE3Repository<S> {
committee_public_key: e3.committee_public_key,
token_address: e3_crisp.token_address,
balance_threshold: e3_crisp.balance_threshold,
requester: e3_crisp.requester,
})
}

Expand Down Expand Up @@ -315,7 +318,6 @@ impl<S: DataStore> CrispE3Repository<S> {

pub async fn set_eligible_addresses(&mut self, holders: Vec<TokenHolder>) -> Result<()> {
let key = self.crisp_key();
// Placeholder for future implementation

self.store
.modify(&key, |e3_obj: Option<E3Crisp>| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
"internalType": "bytes",
"name": "plaintextOutput",
"type": "bytes"
},
{
"internalType": "address",
"name": "requester",
"type": "address"
}
],
"indexed": false,
Expand Down Expand Up @@ -525,6 +530,11 @@
"internalType": "bytes",
"name": "plaintextOutput",
"type": "bytes"
},
{
"internalType": "address",
"name": "requester",
"type": "address"
}
],
"internalType": "struct E3",
Expand Down Expand Up @@ -796,6 +806,11 @@
"internalType": "bytes",
"name": "plaintextOutput",
"type": "bytes"
},
{
"internalType": "address",
"name": "requester",
"type": "address"
}
],
"internalType": "struct E3",
Expand Down Expand Up @@ -932,5 +947,5 @@
"deployedLinkReferences": {},
"immutableReferences": {},
"inputSourceName": "project/contracts/interfaces/IEnclave.sol",
"buildInfoId": "solc-0_8_28-88174d36ce3bdcc25dc9fa934311dccaec8cde55"
"buildInfoId": "solc-0_8_28-723f70610433e7159eeb1220688bb4d784c9ed3e"
}
1 change: 1 addition & 0 deletions packages/enclave-contracts/contracts/Enclave.sol
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
e3.committeePublicKey = hex"";
e3.ciphertextOutput = hex"";
e3.plaintextOutput = hex"";
e3.requester = msg.sender;

bytes32 encryptionSchemeId = requestParams.e3Program.validate(
e3Id,
Expand Down
2 changes: 2 additions & 0 deletions packages/enclave-contracts/contracts/interfaces/IE3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { IDecryptionVerifier } from "./IDecryptionVerifier.sol";
* @param committeePublicKey Hash of the public key of the selected committee for this computation
* @param ciphertextOutput Hash of the encrypted output data produced by the computation
* @param plaintextOutput Decrypted output data after committee decryption
* @param requester Address of the entity that requested the E3 computation
*/
struct E3 {
uint256 seed;
Expand All @@ -43,4 +44,5 @@ struct E3 {
bytes32 committeePublicKey;
bytes32 ciphertextOutput;
bytes plaintextOutput;
address requester;
}
Loading