k = 13;
field = "pallas";

constant "DeriveContractID" {
    EcFixedPointBase NULLIFIER_K,
}

witness "DeriveContractID" {
    # Deploy key used for signing and contract ID derivation
    Base deploy_key,
}

circuit "DeriveContractID" {
    # ContractID derivation path (See darkfi_sdk::crypto::ContractId)
    derivation_path = witness_base(42);

    # Derive the public key used for the signature
    signature_public = ec_mul_base(deploy_key, NULLIFIER_K);
    signature_x = ec_get_x(signature_public);
    signature_y = ec_get_y(signature_public);
    constrain_instance(signature_x);
    constrain_instance(signature_y);

    # Derive the Contract ID
    contract_id = poseidon_hash(derivation_path, signature_x, signature_y);
    constrain_instance(contract_id);
}
