constant "Lead_Mint_V1" {
	EcFixedPointShort VALUE_COMMIT_VALUE,
	EcFixedPoint VALUE_COMMIT_RANDOM,
	EcFixedPointBase NULLIFIER_K,
}

contract "Lead_Mint_V1" {
	Base c1_sk,
	Base c1_sk_root,
	Base c1_slot,
	Base c1_rho,
	Scalar c1_opening,
	Base value,
	Scalar value_blind,
}

circuit "Lead_Mint_V1" {
	ZERO = witness_base(0);
	PREFIX_CM = witness_base(4);
	PREFIX_PK = witness_base(5);

	# value commitment
	# necessary anonymously validading value state transition
	vcv = ec_mul_short(value, VALUE_COMMIT_VALUE);
	vcr = ec_mul(value_blind, VALUE_COMMIT_RANDOM);
	value_commit = ec_add(vcv, vcr);
	constrain_instance(ec_get_x(value_commit));
	constrain_instance(ec_get_y(value_commit));

	# coin (1) pk
	pk = poseidon_hash(PREFIX_PK, c1_sk_root, c1_slot, ZERO);
	constrain_instance(pk);

	# coin (1) cm/commitment
	c1_cm_msg = poseidon_hash(PREFIX_CM, pk, value, c1_rho);
	c1_cm_v = ec_mul_base(c1_cm_msg, NULLIFIER_K);
	c1_cm_r = ec_mul(c1_opening, VALUE_COMMIT_RANDOM);
	c1_cm = ec_add(c1_cm_v, c1_cm_r);
	c1_cm_x = ec_get_x(c1_cm);
	c1_cm_y = ec_get_y(c1_cm);
	c1_cm_hash = poseidon_hash(c1_cm_x, c1_cm_y);
	constrain_instance(c1_cm_hash);
}
