Free4All

Difficulty

Discrete Logs are Ez! Free4All wut?
Author: Razzor
Type: ZK
DSL: Circom

pragma circom 2.0.0;

include "./poseidon.circom";

template Free4All () {
signal input guess; // Exponent to Guess
signal discreteLog; 
signal input flagHash; // Final hash or flag hash

// Discrete Log 
var value = pow(55700804933307086171,guess,60255149254991687993);
discreteLog <-- value;
// Asserting mutable value. Should be equal to 19620536319507236049. Guess the correct exponent
value = 19620536319507236049;
// Poseidon hash with 3 inputs 
component hash = Poseidon(3);   
hash.inputs[0] <== discreteLog;
hash.inputs[1] <== 60984605486407224445;
hash.inputs[2] <== 73487464576294498364;
// Asserting immutable signal. Input signal should be equal to the calculated hash.
flagHash === hash.out;

}

function pow(g , x , p ){
        var ans = 1;
        g = g % p ;
        while(x!=0){
            if ((x & 1) == 1){
                ans = ((ans % p ) * (g % p)) % p;
            }
            x = x>>1;
            g=(g*g)%p;
        }
        return ans;
    }

component main { public [ guess, flagHash] } = Free4All();