Coder Social home page Coder Social logo

poseidon's Introduction

poseidon

poseidon is built to be used in SNARK and non native recursion friendly transcript for appliedzkp/halo2.

Poseidon hash function implmenetation is in line with the reference and the test vectors. It also uses optimized constants and sparse MDS matrices to reduce number of multiplications. For now constants are calculated in construction time they are planned to be hardcoded once transcript design matures. Currently only supports variable length hashing with $\alpha = 5$ sbox. Some parts of Poseidon implementation are adapted or ported from:

Example usage

// Initialize a mutable hasher with constant capacity parameters 
// and number of rounds arguments. This will also generate matrices 
// and constants according to the specification
let mut hasher = Poseidon::<Fr, T, RATE>::new(number_of_full_rounds, number_of_half_rounds);

// In sake of the example we generate some dummy scalar inputs
let inputs = (0..number_of_inputs_0)
    .map(|_| Fr::random(&mut rng))
    .collect::<Vec<Fr>>();

// Feed inputs to the Absorption line
hasher.update(&inputs[..]);

// Yield your challange with squeeze function
let challenge_alpha = hasher.squeeze();

// Then again ...
let inputs = (0..number_of_inputs_1)
    .map(|_| Fr::random(&mut rng))
    .collect::<Vec<Fr>>();
hasher.update(&inputs[..]);
let challenge_beta = hasher.squeeze();

poseidon's People

Contributors

davidnevadoc avatar han0110 avatar kilic avatar lispc avatar vuvoth avatar zhenfeizhang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.