import {euint256, e, ebool, inco} from "@inco/lightning/src/Lib.sol";
import {DecryptionAttestation} from "@inco/lightning/src/lightning-parts/DecryptionAttester.types.sol";
import {asBool} from "@inco/lightning/src/shared/TypeUtils.sol";
contract TestAttestedCompute {
euint256 hiddenCreditScore;
constructor(address owner) payable {
require(msg.value == inco.getFee(), "Fee not paid");
hiddenCreditScore = e.asEuint256(800);
e.allow(hiddenCreditScore, address(this));
e.allow(hiddenCreditScore, owner);
}
function GetHandle() external returns (euint256) {
return hiddenCreditScore;
}
function SubmitCreditCheck(
DecryptionAttestation memory decryption,
bytes[] memory signatures
) external {
// Verify covalidator signatures over the attested result
require(
inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures),
"Invalid signature"
);
// Recompute the expected "creditScore >= 700" handle on-chain
require(
ebool.unwrap(e.ge(hiddenCreditScore, 700)) == decryption.handle,
"Computed handle mismatch"
);
// Check that the decrypted boolean is true
require(asBool(decryption.value) == true, "Credit check failed");
// Credit check passed - proceed with loan approval
}
}