pub fn mock_ecdsa_signatures_are_supported(handle: IcHandle, ctx: &ic_fondue::pot::Context) {
    let rt = tokio::runtime::Runtime::new().expect("Could not create tokio runtime.");
    let mut rng = ctx.rng.clone();

    rt.block_on(async move {
        let endpoint = get_random_node_endpoint(&handle, &mut rng);
        endpoint.assert_ready(ctx).await;
        let agent = assert_create_agent(endpoint.url.as_str()).await;

        let message_hash = [0xabu8; 32];
        let request = SignWithECDSAArgs::new(message_hash.to_vec(), [0u8; 32].to_vec());

        // Ask for a signature:
        let uni_can = UniversalCanister::new(&agent).await;
        let res = uni_can
            .forward_to(
                &Principal::management_canister(),
                "sign_with_mock_ecdsa",
                Encode!(&request).unwrap(),
            )
            .await;

        let response_signature =
            Signature::from_compact(&res.expect("sign_with_mock_ecdsa returned an error}"))
                .expect("Response is not a valid signature");

        // Ask for the public key:
        let uni_can = UniversalCanister::new(&agent).await;
        let res = uni_can
            .forward_to(
                &Principal::management_canister(),
                "get_mock_ecdsa_public_key",
                Encode!(&[0u8; 0]).unwrap(),
            )
            .await;

        let public_key =
            PublicKey::from_slice(&res.expect("get_mock_ecdsa_public_key returned an error}"))
                .expect("Response is not a valid public key");

        // Verify the signature:
        let secp = Secp256k1::new();
        let message = Message::from_slice(&message_hash).expect("32 bytes");
        assert!(secp
            .verify(&message, &response_signature, &public_key)
            .is_ok());
    });
}
/// Tests whether a call to `sign_with_mock_ecdsa` is responded with a signature
/// that is valid under the mock public key.
Tests whether a call to `sign_with_mock_ecdsa` is responded with a signature
that is valid under the mock public key.
Tests whether a call to ` sign_with_mock_ecdsa ` is responded with a signature that is valid under the mock public key .
pub fn mock_ecdsa_signatures_are_supported(handle: IcHandle, ctx: &ic_fondue::pot::Context) {
    let rt = tokio::runtime::Runtime::new().expect("Could not create tokio runtime.");
    let mut rng = ctx.rng.clone();
    rt.block_on(async move {
        let endpoint = get_random_node_endpoint(&handle, &mut rng);
        endpoint.assert_ready(ctx).await;
        let agent = assert_create_agent(endpoint.url.as_str()).await;
        let message_hash = [0xabu8; 32];
        let request = SignWithECDSAArgs::new(message_hash.to_vec(), [0u8; 32].to_vec());
        // Ask for a signature:
        let uni_can = UniversalCanister::new(&agent).await;
        let res = uni_can
            .forward_to(
                &Principal::management_canister(),
                "sign_with_mock_ecdsa",
                Encode!(&request).unwrap(),
            )
            .await;
        let response_signature =
            Signature::from_compact(&res.expect("sign_with_mock_ecdsa returned an error}"))
                .expect("Response is not a valid signature");
        // Ask for the public key:
        let uni_can = UniversalCanister::new(&agent).await;
        let res = uni_can
            .forward_to(
                &Principal::management_canister(),
                "get_mock_ecdsa_public_key",
                Encode!(&[0u8; 0]).unwrap(),
            )
            .await;
        let public_key =
            PublicKey::from_slice(&res.expect("get_mock_ecdsa_public_key returned an error}"))
                .expect("Response is not a valid public key");
        // Verify the signature:
        let secp = Secp256k1::new();
        let message = Message::from_slice(&message_hash).expect("32 bytes");
        assert!(secp
            .verify(&message, &response_signature, &public_key)
            .is_ok());
    });
}
pub fn mock_ecdsa_signatures_are_supported ( handle : IcHandle , ctx : & ic_fondue :: pot :: Context ) { let rt = tokio :: runtime :: Runtime :: new ( ) . expect ( " " ) ; let mut rng = ctx . rng . clone ( ) ; rt . block_on ( async move { let endpoint = get_random_node_endpoint ( & handle , & mut rng ) ; endpoint . assert_ready ( ctx ) . await ; let agent = assert_create_agent ( endpoint . url . as_str ( ) ) . await ; let message_hash = [ 0xabu8 ; 32 ] ; let request = SignWithECDSAArgs :: new ( message_hash . to_vec ( ) , [ 0u8 ; 32 ] . to_vec ( ) ) ; // Ask for a signature: let uni_can = UniversalCanister :: new ( & agent ) . await ; let res = uni_can . forward_to ( & Principal :: management_canister ( ) , " " , Encode ! ( request ) . unwrap ( ) , ) . await ; let response_signature = Signature :: from_compact ( & res . expect ( " " ) ) . expect ( " " ) ; // Ask for the public key: let uni_can = UniversalCanister :: new ( & agent ) . await ; let res = uni_can . forward_to ( & Principal :: management_canister ( ) , " " , Encode ! ( [ 0u8 0 ] ) . unwrap ( ) , ) . await ; let public_key = PublicKey :: from_slice ( & res . expect ( " " ) ) . expect ( " " ) ; // Verify the signature: let secp = Secp256k1 :: new ( ) ; let message = Message :: from_slice ( & message_hash ) . expect ( " " ) ; assert ! ( secp verify ( message response_signature public_key ) is_ok ( ) ) ; } ) ; }
Tests whether a call to `sign_with_mock_ecdsa` is responded with a signature
that is valid under the mock public key.
Tests whether a call to ` sign_with_mock_ecdsa ` is responded with a signature that is valid under the mock public key .
handle
IcHandle
ctx
&ic_fondue::pot::Context
handle
IcHandle
ctx
&ic_fondue::pot::Context