Precompiled Contracts

The WEMIX3.0 Blockchain provides pre-compiled contracts.

There are precompiled contracts in WEMIX smart contracts. The compiled contract provides contracts deployed in Ethereum and newly supported by WEMIX.

Recovery of ECDSA signature

The 0x01 address provides a function to recover the public key of the elliptic curve digital signature algorithm. The hash value of the transaction and the v, r, s signature value are entered, and the address is returned.

The contract address distributed on the WEMIX3.0 testnet is 0xD37d47514f46efaCa967fc191D040B3ee713110A, which can be found through testnet explorer.

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.10;

contract Ecrecover {
    address addressTest = 0x12Cb274aAD8251C875c0bf6872b67d9983E53fDd;
    bytes32 msgHash = 0xc51dac836bc7841a01c4b631fa620904fc8724d7f9f1d3c420f0e02adf229d50;
    uint8 v = 0x1b;
    bytes32 r = 0x44287513919034a471a7dc2b2ed121f95984ae23b20f9637ba8dff471b6719ef;
    bytes32 s = 0x7d7dc30309a3baffbfd9342b97d0e804092c0aeb5821319aa732bc09146eafb4;


    function verify() public view returns(bool) {
        // Use ECRECOVER to verify address
        return (ecrecover(msgHash, v, r, s) == (addressTest));
    }
}

SHA256 Hash function

The 0x02 address provides an SHA-256 hash function. When the data is entered, the corresponding SHA-256 hash value is returned.

The contract address distributed on the WEMIX3.0 testnet is 0xdbec92984EE8508e3A47C150C5BDBF02B8928A72, which can be found through testnet explorer.

RIPEMD160 Hash function

The 0x03 address provides a RIPEMD-160 hash function. When data is entered, the corresponding RIPEMD-160 hash value is returned.

The contract address distributed on the WEMIX3.0 testnet is 0x39b2CB921353097993e72e811A5FC4992b72e926, which can be found through testnet explorer.

Data Copy function

The 0x04 address provides a data copy function. This feature is used as a more reasonable way to copy data to memory.

Currently, Solidity does not support the dataCopy function, so it must be called in-line assembly.

The contract address distributed on the WEMIX3.0 testnet is 0x709Ba0DD7055BC61B781Ddda31F5Df0018F33391, which can be found through testnet explorer.

Modular Exponentiation function

The 0x05 address provides a function to raise the integer b (base) to e-square (exponential) and calculate the remainder when divided by a positive integer m (modulus).

The Solidity Compiler does not support this and must be called an inline assembly.

The contract address distributed on the WEMIX3.0 testnet is 0x370AF3a491f1D7cc08D7cc590bB2a746E612a216, which can be found through testnet explorer.

Point addition on Elliptic curve

The 0x06 address provides a function that implements an addition operation for points on an elliptic curve. This operation receives two valid points(ax,ay) and(bx,by) on the elliptic curve bn256 and returns the point(ax,ay)+(bx,by) on the elliptic curve as a result.

The Solidity Compiler does not support this function and must be called an inline assembly.

The contract address distributed on the WEMIX3.0 testnet is 0x557359e169E56aAcb0d1E5FA9A7E8717967FcEbD, which can be found through testnet explorer.

Point multiplication on Elliptic curve

The 0x07 address provides a function that implements a multiplication operation for points on an elliptic curve expressed as scalar values. This operation takes a valid point(x,y) on the elliptic curve bn256 and returns the point scalar * (x,y) on the elliptic curve.

The Solidity Compiler does not support this function and must be called as inline assembly.

Elliptic curve pairing function for zkSNARK validation

The 0x08 address provides a function for elliptic curve peering operations to validate the zkSNARK proposed in EIP-197.

The Solidity Compiler does not support this function and must be called as inline assembly.