Precompiles

The precompiles in zytron kit

Precompiles

Currently zytron provides the following precompilers, which are placed at different addresses:

  • anemoi
  • ed_on_bn254
  • shuffle
  • matchmaking
  • shuffle

anemoi

Contract NameAddress
AnemoiJive2540x00000000000000000000000000000000000000014

Input parameters are encoded in the following form:

bytes32[] memory data = /* .. */
bytes memory input = abi.encode(data)

address precompile = 0x00000000000000000000000000000000000000014;
precompile.staticcall(input);

ed_on_bn254

Contract NameAddress
EdOnBN254PointAdd0x00000000000000000000000000000000000000015
EdOnBN254ScalarMul0x00000000000000000000000000000000000000016

EdOnBN254PointAdd:

uint256 x1 = /* */;
uint256 y1 = /* */;
uint256 x2 = /* */;
uint256 y2 = /* */;

address precompile = 0x00000000000000000000000000000000000000015;
bytes memory output = precompile.staticcall(abi.encode(x1, y1, x2, y2));
(uint256 x, uint256 y) = abi.decode(output, (uint256 ,uint256));

EdOnBN254PointMul:

uint256 x = /* */;
uint256 y = /* */;
uint256 s = /* */;

address precompile = 0x00000000000000000000000000000000000000016;
bytes memory output = precompile.staticcall(abi.encode(x, y, s));
(uint256 x, uint256 y) = abi.decode(output, (uint256 ,uint256));

matchmaking

Contract NameAddress
VerifyMatchmaking0x00000000000000000000000000000000000000017

Input parameters are encoded in the following form:

bytes memory verifier_params = /*  */;
bytes[] memory inputs = /*  */;
bytes[] memory outputs = /*  */;
bytes memory commitment = /*  */;
bytes memory random_number = /*  */;
bytes memory proof = /*  */;

address precompile = 0x00000000000000000000000000000000000000017;

require(precompile.staticcall(abi.encode(verifier_params, inputs, outputs, commitment, random_number, proof)));

shuffle

Contract NameAddress
Shuffle0x00000000000000000000000000000000000000018

Input parameters are encoded in the following form:

bytes memory verifier_params = /*  */;
bytes[] memory input_cards = /*  */;
bytes[] memory output_cards = /*  */;
bytes memory proof = /*  */;

address precompile = 0x00000000000000000000000000000000000000018;

require(precompile.staticcall(abi.encode(verifier_params, input_cards, output_cards, proof)));