#zero-knowledge #near-protocol #cryptography #smart-contracts #mi-mc

near_mimc

MiMC hash function implementation in wasm32_unknown_unknown architecture, compatible with NEAR Protocol Smart Contracts. Inspired by snarky.js' implementation.

1 stable release

1.0.0 Dec 1, 2022

#9 in #near-protocol

23 downloads per month

MIT license

4.5MB
4.5K SLoC

near-mimc

Rust library to use MiMC Hash function in NEAR Protocol Smart Contract development.

Use cases

This library was created as an implementation of the MiMC Hash function that can run within a NEAR Protocol Smart Cotnract.

It is fully compatible (i.e. implemented in the exact same way) as in circom2 sample circuits. This allows the hash function to be used within zkSNARK schemes based on snarky.js and circom.

Supported near-sdk versions

near-bigint is built on top of near-sdk 4.0.0 and will be updated periodically to reflect updates on near-sdk. Previous near-sdk versions are not compatible with this library.

Additionally, the function interfaces utilize big integer types from the near-bigint library version 1.0.0.

How to use it

The lbrary exposes 2 different hash functions, one taking 2 input values and the other taking a single value.

pub fn u256_mimc_sponge(k: U256, inputs: [U256; INPUTS]) -> [U256; OUTPUTS]

pub fn u256_mimc_sponge_single(k: U256, inputs: [U256; 1]) -> [U256; 1]

Dependencies

~6MB
~115K SLoC