// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { StreetCredV3 } from "../../contracts/reputation/StreetCredV3.sol";
import { V3Fixtures } from "../helpers/V3Fixtures.sol";

/// @title Inv13_PrivatePublicParity
/// @notice Private/ZK evidence has the same maximum weight as equivalent public evidence.
contract Inv13_PrivatePublicParity is V3Fixtures {
    StreetCredV3 internal cred;
    address internal attester = address(0xA77E57);
    bytes32 internal publicSubject = keccak256("public-subject");
    bytes32 internal privateSubject = keccak256("private-subject");

    function setUp() public {
        _setUpDependencies();
        cred = new StreetCredV3(owner);
        vm.prank(owner);
        cred.setAttester(attester, true);
    }

    function test_opaque_private_commitment_has_the_same_verified_weight_as_public_evidence() external {
        StreetCredV3.Signal memory publicEvidence = StreetCredV3.Signal({
            schemaVersion: 1,
            weightBps: 10_000,
            evidenceCommitment: keccak256("public evidence body"),
            classification: 2,
            attester: attester,
            observedAt: uint64(block.timestamp),
            expiresAt: 0,
            negative: false
        });
        StreetCredV3.Signal memory privateEvidence = publicEvidence;
        privateEvidence.evidenceCommitment = keccak256("zk proof commitment only");

        vm.startPrank(attester);
        cred.addSignal(publicSubject, publicEvidence);
        cred.addSignal(privateSubject, privateEvidence);
        cred.recompute(publicSubject, 1);
        cred.recompute(privateSubject, 1);
        vm.stopPrank();

        (, uint32 publicScore,,,,) = cred.scoreOf(publicSubject);
        (, uint32 privateScore,,,,) = cred.scoreOf(privateSubject);
        assertEq(privateScore, publicScore, "private verified evidence received a lower weight");
        assertEq(privateScore, 10_000, "verified evidence did not retain its maximum score");
    }
}
