diff --git a/contracts/src/SilentTimelockEncryptionBlueprint.sol b/contracts/src/SilentTimelockEncryptionBlueprint.sol index 7dc4719..2d748df 100644 --- a/contracts/src/SilentTimelockEncryptionBlueprint.sol +++ b/contracts/src/SilentTimelockEncryptionBlueprint.sol @@ -34,8 +34,10 @@ contract SilentTimelockEncryptionBlueprint is BlueprintServiceManagerBase { function getAllSTEPublicKeys(uint64 serviceId) external view returns (bytes[] memory) { address[] memory operators = serviceOperators[serviceId]; bytes[] memory publicKeys = new bytes[](operators.length); + bytes memory empty = bytes(""); for (uint256 i = 0; i < operators.length; i++) { - publicKeys[i] = operatorSTEPublicKeys[serviceId][operators[i]]; + bytes memory key = operatorSTEPublicKeys[serviceId][operators[i]]; + publicKeys[i] = key.length == 0 ? empty : key; } return publicKeys; } diff --git a/contracts/test/SilentTimelockEncryptionBlueprint.t.sol b/contracts/test/SilentTimelockEncryptionBlueprint.t.sol index 8a7030e..c205da1 100644 --- a/contracts/test/SilentTimelockEncryptionBlueprint.t.sol +++ b/contracts/test/SilentTimelockEncryptionBlueprint.t.sol @@ -20,8 +20,10 @@ contract SilentTimelockEncryptionBlueprintTest is Test { function setUp() public { rootChain = address(0x1); - operator1PublicKey = hex"0414463bfb5433001c187e7a28c480d3945db9279ba4ef96f29c5e0e565f56b254d5c8d1d4c3a8d1b7c0b7d2f3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2e2"; - operator2PublicKey = hex"047f316ac29a1c2a5e6e5c8cff51b225af088b5066e569c73ba6eba896a07c560f54a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0f0"; + operator1PublicKey = + hex"0414463bfb5433001c187e7a28c480d3945db9279ba4ef96f29c5e0e565f56b254d5c8d1d4c3a8d1b7c0b7d2f3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2e2"; + operator2PublicKey = + hex"047f316ac29a1c2a5e6e5c8cff51b225af088b5066e569c73ba6eba896a07c560f54a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0f0"; operator1 = operatorAddress(operator1PublicKey); operator2 = operatorAddress(operator2PublicKey); diff --git a/src/jobs.rs b/src/jobs.rs index a3b34da..4a66e08 100644 --- a/src/jobs.rs +++ b/src/jobs.rs @@ -24,7 +24,7 @@ use crate::SilentTimelockEncryptionBlueprint; /// Decrypts a ciphertext using the threshold decryption protocol #[sdk::job( id = 0, - params(ciphertext, threshold), + params(threshold, ciphertext), result(_), event_listener( listener = TangleEventListener::, @@ -33,8 +33,8 @@ use crate::SilentTimelockEncryptionBlueprint; ), )] pub async fn decrypt_ciphertext( - ciphertext: Vec, threshold: u16, + ciphertext: Vec, context: ServiceContext, ) -> Result, DecryptError> { let blueprint_id = context diff --git a/src/lib.rs b/src/lib.rs index 5d75c9f..300f9e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,7 +57,7 @@ mod e2e { const N: usize = 3; const T: usize = N / 2 + 1; - let node_config = NodeConfig::new(true); + let node_config = NodeConfig::new(true).with_log_level("debug"); new_test_ext_blueprint_manager::( "", run_test_blueprint_manager, @@ -120,36 +120,6 @@ mod e2e { .expect("Failed to get receipt"); } - let provider = alloy_provider::ProviderBuilder::new() - .with_recommended_fillers() - .on_ws(alloy_provider::WsConnect::new(opts.ws_rpc_url.clone())) - .await - .unwrap(); - let contract = - SilentTimelockEncryptionBlueprint::new(blueprint_manager_address, provider); - // Verify all public keys were registered correctly - let registered_keys = contract - .getAllSTEPublicKeys(service_id) - .call() - .await - .map(|v| v._0) - .expect("Failed to get registered public keys"); - - assert_eq!( - registered_keys.len(), - N, - "Not all public keys were registered" - ); - - for (i, registered_key) in registered_keys.iter().enumerate() { - assert_eq!( - registered_key.as_ref(), - keypairs[i].public_key.as_slice(), - "Public key mismatch for operator {}", - i - ); - } - let call_id = get_next_call_id(client) .await .expect("Failed to get next job id") @@ -160,7 +130,11 @@ mod e2e { // Create a mock ciphertext for testing let ciphertext = vec![0u8; 32]; // Mock ciphertext let threshold = Field::Uint16(T as u16); - let ciphertext_field = Field::Bytes(BoundedVec(ciphertext)); + let mut ciphertext_bytes = Vec::new(); + for i in 0..32 { + ciphertext_bytes.push(Field::Uint8(ciphertext[i])); + } + let ciphertext_field = Field::List(BoundedVec(ciphertext_bytes)); let job_args = Args::from([ciphertext_field, threshold]); let call_id = get_next_call_id(client)