k = 13;
field = "pallas";

constant "ConsensusMint_V1" {
    EcFixedPointShort VALUE_COMMIT_VALUE,
    EcFixedPoint VALUE_COMMIT_RANDOM,
}

witness "ConsensusMint_V1" {
    # X coordinate for public key
    Base pub_x,
    # Y coordinate for public key
    Base pub_y,
    # The value of this coin
    Base value,
    # The epoch this coin was minted on
    Base epoch,
    # Unique serial number corresponding to this coin
    Base serial,
    # Random blinding factor for the value commitment
    Scalar value_blind,
}

circuit "ConsensusMint_V1" {
    # Constrain the epoch this coin was minted on
    constrain_instance(epoch);

    # Poseidon hash of the coin
    C = poseidon_hash(
        pub_x,
        pub_y,
        value,
        epoch,
        serial,
    );
    constrain_instance(C);

    # Pedersen commitment for coin's value
    vcv = ec_mul_short(value, VALUE_COMMIT_VALUE);
    vcr = ec_mul(value_blind, VALUE_COMMIT_RANDOM);
    value_commit = ec_add(vcv, vcr);
    # Since the value commit is a curve point, we fetch its coordinates
    # and constrain them:
    constrain_instance(ec_get_x(value_commit));
    constrain_instance(ec_get_y(value_commit));

    # At this point we've enforced all of our public inputs.
}
