/// This function creates responses to the SignWithMockECDSA system calls with
/// the computed MOCK(!) signature.
This function creates responses to the SignWithMockECDSA system calls with
the computed MOCK(!) signature.
This function creates responses to the SignWithMockECDSA system calls with the computed MOCK ( ! ) signature .
pub fn generate_responses_to_sign_with_mock_ecdsa_calls(
    contexts: &BTreeMap<CallbackId, SignWithEcdsaContext>,
    batch_time: Time,
) -> Vec<Response> {
    let mut consensus_responses = Vec::<Response>::new();
    if contexts.is_empty() {
        return consensus_responses;
    }
    let secp = Secp256k1::new();
    let secret_key = SecretKey::from_slice(&[0xcd; 32]).expect("32 bytes, within curve order");
    for (callback_id, context) in contexts.iter() {
        if batch_time > context.batch_time + Duration::from_millis(MOCK_ECDSA_DELAY_MILLIS) {
            let hash = Message::from_slice(&context.message_hash).unwrap();
            let sig = secp.sign(&hash, &secret_key);
            let response_payload = messages::Payload::Data(sig.serialize_compact().to_vec());
            consensus_responses.push(Response {
                originator: CanisterId::ic_00(),
                respondent: CanisterId::ic_00(),
                originator_reply_callback: *callback_id,
                refund: Cycles::zero(),
                response_payload,
            });
        }
    }
    consensus_responses
}
pub fn generate_responses_to_sign_with_mock_ecdsa_calls ( contexts : & BTreeMap < CallbackId , SignWithEcdsaContext > , batch_time : Time , ) -> Vec < Response > { let mut consensus_responses = Vec :: < Response > :: new ( ) ; if contexts . is_empty ( ) { return consensus_responses ; } let secp = Secp256k1 :: new ( ) ; let secret_key = SecretKey :: from_slice ( & [ 0xcd ; 32 ] ) . expect ( " " ) ; for ( callback_id , context ) in contexts . iter ( ) { if batch_time > context . batch_time + Duration :: from_millis ( MOCK_ECDSA_DELAY_MILLIS ) { let hash = Message :: from_slice ( & context . message_hash ) . unwrap ( ) ; let sig = secp . sign ( & hash , & secret_key ) ; let response_payload = messages :: Payload :: Data ( sig . serialize_compact ( ) . to_vec ( ) ) ; consensus_responses . push ( Response { originator : CanisterId :: ic_00 ( ) , respondent : CanisterId :: ic_00 ( ) , originator_reply_callback : * callback_id , refund : Cycles :: zero ( ) , response_payload , } ) ; } } consensus_responses }
This function creates responses to the SignWithMockECDSA system calls with
the computed MOCK(!)
This function creates responses to the SignWithMockECDSA system calls with the computed MOCK ( ! )
contexts
&BTreeMap<CallbackId, SignWithEcdsaContext>
batch_time
Time