mirror of
https://github.com/luxfi/fhe.git
synced 2026-09-24 00:27:17 +00:00
- data-seal: Verifiable Data Integrity Seal (PIP-0010/LP-0535) FHE-encrypted tamper-proof sealing with Public/ZK/Private modes, batch sealing, homomorphic verification - content-provenance: AI & Media Content Provenance (PIP-0011/LP-7110) Model manifests, output attestation via homomorphic comparison, media derivation DAGs - encrypted-crdt: Encrypted CRDT (PIP-0013/LP-6500) LWW-Register with FHE values, OR-Set with tag-based add/remove, Lamport timestamp conflict resolution, deterministic merge - shadow-governance: Shadow Government Protocol (PIP-7010) Anonymous ministries, encrypted voting with homomorphic tallying, nullifier-based anti-fraud, quorum enforcement Each example includes Solidity contracts, Hardhat tests, CLI tasks, and README linking to corresponding PIP and LP specifications.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { task } from "hardhat/config";
|
|
import { fhe, Encryptable } from "@luxfhe/sdk/node";
|
|
|
|
task("task:verify-seal", "Verify a data integrity seal")
|
|
.addParam("contract", "DataSeal contract address")
|
|
.addParam("id", "Seal ID to verify")
|
|
.addParam("tag", "Integrity tag (the secret used at seal creation)")
|
|
.setAction(async ({ contract, id, tag }, hre) => {
|
|
const [signer] = await hre.ethers.getSigners();
|
|
const dataSeal = await hre.ethers.getContractAt("DataSeal", contract);
|
|
|
|
const seal = await dataSeal.getSeal(parseInt(id));
|
|
console.log("Seal:", {
|
|
contentHash: seal.contentHash,
|
|
creator: seal.creator,
|
|
timestamp: seal.timestamp.toString(),
|
|
mode: ["Public", "ZK", "Private"][Number(seal.mode)],
|
|
revoked: seal.revoked,
|
|
});
|
|
|
|
const [encChallenge] = await fhe.encrypt([Encryptable.uint32(BigInt(tag))]);
|
|
const tx = await dataSeal.connect(signer).verifySeal(parseInt(id), encChallenge);
|
|
await tx.wait();
|
|
|
|
// Poll for decryption result
|
|
let attempts = 0;
|
|
while (attempts < 10) {
|
|
const result = await dataSeal.getVerificationResult(parseInt(id));
|
|
if (result.ready) {
|
|
console.log(result.matched ? "PASS: Seal verified." : "FAIL: Seal mismatch.");
|
|
return;
|
|
}
|
|
await new Promise((r) => setTimeout(r, 2000));
|
|
attempts++;
|
|
}
|
|
console.log("Decryption pending. Check later.");
|
|
});
|