fn keccak256_hash(
        &self,
        contract: &Contract,
        src: PointerValue,
        length: IntValue,
        dest: PointerValue,
    ) {
        let balance = contract
            .builder
            .build_alloca(contract.value_type(), "balance");

        contract
            .builder
            .build_store(balance, contract.value_type().const_zero());

        let keccak256_pre_compile_address: [u8; 20] =
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20];

        let address = contract.emit_global_string(
            "keccak256_precompile",
            &keccak256_pre_compile_address,
            true,
        );

        contract.builder.build_call(
            contract.module.get_function("call").unwrap(),
            &[
                contract
                    .context
                    .i64_type()
                    .const_int(i64::MAX as u64, false)
                    .into(),
                contract
                    .builder
                    .build_pointer_cast(
                        address,
                        contract.context.i8_type().ptr_type(AddressSpace::Generic),
                        "address",
                    )
                    .into(),
                contract
                    .builder
                    .build_pointer_cast(
                        balance,
                        contract.context.i8_type().ptr_type(AddressSpace::Generic),
                        "balance",
                    )
                    .into(),
                contract
                    .builder
                    .build_pointer_cast(
                        src,
                        contract.context.i8_type().ptr_type(AddressSpace::Generic),
                        "source",
                    )
                    .into(),
                length.into(),
            ],
            "",
        );

        // We're not checking return value or returnDataSize;
        // assuming precompiles always succeed
        contract.builder.build_call(
            contract.module.get_function("returnDataCopy").unwrap(),
            &[
                contract
                    .builder
                    .build_pointer_cast(
                        dest,
                        contract.context.i8_type().ptr_type(AddressSpace::Generic),
                        "dest",
                    )
                    .into(),
                contract.context.i32_type().const_zero().into(),
                contract.context.i32_type().const_int(32, false).into(),
            ],
            "",
        );
    }
/// ewasm has no keccak256 host function, so call our implementation
ewasm has no keccak256 host function, so call our implementation
ewasm has no keccak256 host function so call our implementation
fn keccak256_hash(
        &self,
        contract: &Contract,
        src: PointerValue,
        length: IntValue,
        dest: PointerValue,
    ) {
        let balance = contract
            .builder
            .build_alloca(contract.value_type(), "balance");
        contract
            .builder
            .build_store(balance, contract.value_type().const_zero());
        let keccak256_pre_compile_address: [u8; 20] =
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20];
        let address = contract.emit_global_string(
            "keccak256_precompile",
            &keccak256_pre_compile_address,
            true,
        );
        contract.builder.build_call(
            contract.module.get_function("call").unwrap(),
            &[
                contract
                    .context
                    .i64_type()
                    .const_int(i64::MAX as u64, false)
                    .into(),
                contract
                    .builder
                    .build_pointer_cast(
                        address,
                        contract.context.i8_type().ptr_type(AddressSpace::Generic),
                        "address",
                    )
                    .into(),
                contract
                    .builder
                    .build_pointer_cast(
                        balance,
                        contract.context.i8_type().ptr_type(AddressSpace::Generic),
                        "balance",
                    )
                    .into(),
                contract
                    .builder
                    .build_pointer_cast(
                        src,
                        contract.context.i8_type().ptr_type(AddressSpace::Generic),
                        "source",
                    )
                    .into(),
                length.into(),
            ],
            "",
        );
        // We're not checking return value or returnDataSize;
        // assuming precompiles always succeed
        contract.builder.build_call(
            contract.module.get_function("returnDataCopy").unwrap(),
            &[
                contract
                    .builder
                    .build_pointer_cast(
                        dest,
                        contract.context.i8_type().ptr_type(AddressSpace::Generic),
                        "dest",
                    )
                    .into(),
                contract.context.i32_type().const_zero().into(),
                contract.context.i32_type().const_int(32, false).into(),
            ],
            "",
        );
    }
fn keccak256_hash ( & self , contract : & Contract , src : PointerValue , length : IntValue , dest : PointerValue , ) { let balance = contract . builder . build_alloca ( contract . value_type ( ) , " " ) ; contract . builder . build_store ( balance , contract . value_type ( ) . const_zero ( ) ) ; let keccak256_pre_compile_address : [ u8 ; 20 ] = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 20 ] ; let address = contract . emit_global_string ( " " , & keccak256_pre_compile_address , true , ) ; contract . builder . build_call ( contract . module . get_function ( " " ) . unwrap ( ) , & [ contract . context . i64_type ( ) . const_int ( i64 :: MAX as u64 , false ) . into ( ) , contract . builder . build_pointer_cast ( address , contract . context . i8_type ( ) . ptr_type ( AddressSpace :: Generic ) , " " , ) . into ( ) , contract . builder . build_pointer_cast ( balance , contract . context . i8_type ( ) . ptr_type ( AddressSpace :: Generic ) , " " , ) . into ( ) , contract . builder . build_pointer_cast ( src , contract . context . i8_type ( ) . ptr_type ( AddressSpace :: Generic ) , " " , ) . into ( ) , length . into ( ) , ] , " " , ) ; // We're not checking return value or returnDataSize; // assuming precompiles always succeed contract . builder . build_call ( contract . module . get_function ( " " ) . unwrap ( ) , & [ contract . builder . build_pointer_cast ( dest , contract . context . i8_type ( ) . ptr_type ( AddressSpace :: Generic ) , " " , ) . into ( ) , contract . context . i32_type ( ) . const_zero ( ) . into ( ) , contract . context . i32_type ( ) . const_int ( 32 , false ) . into ( ) , ] , " " , ) ; }
ewasm has no keccak256 host function, so call our implementation
ewasm has no keccak256 host function so call our implementation
&self
contract
&Contract
src
PointerValue
length
IntValue
dest
PointerValue
&self
contract
&Contract
src
PointerValue
length
IntValue
dest
PointerValue