near_mimc

Crates.ionear_mimc
lib.rsnear_mimc
version1.0.0
sourcesrc
created_at2022-12-01 20:10:09.66217
updated_at2022-12-01 20:10:09.66217
descriptionMiMC hash function implementation in wasm32_unknown_unknown architecture, compatible with NEAR Protocol Smart Contracts. Inspired by snarky.js' implementation.
homepage
repositoryhttps://github.com/hideyour-cash/monorepo/packages/contract-libraries/near_mimc
max_upload_size
id727871
size8,856,771
João Veiga (veigajoao)

documentation

README

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]
Commit count: 653

cargo fmt