Commit Graph
6 Commits
Author SHA1 Message Date
zeekay b4cd2d6109 feat(policy): re-point fhe_threshold_decryptor at canonical tfhe home
The phantom luxfi/fhe/threshold and luxfi/fhe/pkg/threshold APIs the
RealThresholdDecryptor referenced (FHECiphertext, FHEThresholdShare,
KeyShare, ShareAggregator, PartialDecrypter, ...) were never built.
The canonical home for threshold-FHE primitives is
luxfi/threshold/protocols/tfhe — one and only one place.

Repoint the import; add the local replace directive until
luxfi/threshold cuts a release tag containing the new committee
surface; pkg/policy now compiles and 7/7 RealThresholdDecryptor tests
pass.
2025-12-28 17:00:24 -08:00
zeekay 8f09d162a6 feat(policy): RealThresholdDecryptor wires committee to FHEVerifier
Implements the ThresholdDecryptor interface against the t-of-n
threshold-FHE service layer in luxfi/fhe/threshold.

RealThresholdDecryptor fans PartialDecrypt requests across configured
PartyClient peers, collects shares, and aggregates >=threshold valid
ones via the local ShareAggregator. The plaintext is rounded to a
boolean for the FHE policy verdict path.

Failure modes (insufficient quorum, peer errors, status non-OK) all
propagate as errors — the verifier wraps them as ErrFHEThresholdDec
and fails the policy gate closed.

go.mod adds a local replace for luxfi/fhe pending a release tag that
includes the threshold/ package.

Tests: 7/7 pass (2-of-3, 3-of-5, insufficient peers, two-peers-err
quorum-fail, one-peer-err quorum-pass, zero-threshold, roundToBool).
Full pkg/policy regression: 37/37 pass.
2025-12-28 16:40:32 -08:00
zeekay 779e6237ef feat(policy): PlanProvider path on FHEVerifier
Adds a PlanProvider interface alongside the existing FChainClient.
When wired, the verifier prefers it: a precompiled, cached RulePlan
(see luxfi/fhe/policy) is evaluated locally against the per-intent
encrypted inputs and returns the same opaque verdict bytes the
ThresholdDecryptor already accepts.

The remote F-Chain path stays the default. Both can be wired
simultaneously; Plan wins if set. NewFHEVerifierWithPlan is the
factory for the local path.

Tests: PlanPathPrefersPlan (Plan beats FChain when both wired),
PlanPathDeny (encrypted-false -> ErrFHEVerdictDeny), PlanPathFailClosed
(eval error -> ErrFHEPolicyEval, decryptor untouched). All existing
FHEVerifier tests still pass unchanged.
2025-12-28 16:33:54 -08:00
zeekay e699d1013a feat(policy): FHE-policy verifier alongside LocalVerifier
Adds FHEVerifier — the encrypted-policy counterpart to the existing
LocalVerifier. FHEVerifier reads an FHE-encoded policy from F-Chain,
homomorphically evaluates it against the encrypted intent, and gates
signing on a threshold-decrypted boolean verdict.

Dependencies are interfaces (FChainClient, ThresholdDecryptor,
VelocityProvider) so the verifier is testable without the full crypto
stack and so the F-Chain transport layer can evolve independently.

Fail-closed semantics: missing deps, expired intent, unknown wallet,
F-Chain eval error, and threshold-decrypt error all reject.

- New file: pkg/policy/fhe_verifier.go (188 LOC)
- Tests: pkg/policy/fhe_verifier_test.go — 8/8 passing in <1s
- No changes to LocalVerifier or any existing code path.
2025-12-28 16:14:02 -08:00
zeekay de7c8a76e2 mpc: per-node policy gate for non-bypassable signing
CanonicalIntent + LocalVerifier + SignGate. The MPC node signs only
if it independently verifies the policy bundle. Closes the bypassable
single point of failure where each node trusted the coordinator.

pkg/intent: CBOR-encoded intent, RFC 8949 Sec 4.2 deterministic
encoding. Approvals + node attestations excluded from digest.

pkg/policy/local_verifier: six-check gate (wallet, expiry, policy
hash, approval threshold, allowlist+limits, risk). Fails CLOSED.
Signed NodeAttestation for both approve and reject.

pkg/risk: Provider interface. InternalAllowlist (always available),
Chainalysis HTTP client + httptest coverage, TRM/Elliptic NOTIMPL
with documented endpoint shapes. CompositeProvider AND/OR.

pkg/mpc/sign_orchestrator: SignGate wraps verifier as
protocol-agnostic gate. AuthorizeSign returns ErrSignBlocked wrapping
the cause. AuthorizeAndDigest returns the digest the threshold
scheme must sign over.

e2e/policy_gate_test (tag policygate; pre-existing zapdb break) +
pkg/mpc/sign_orchestrator_e2e_test (runs in normal test suite):
3-node simulation proves non-bypassable.

56 tests, 4 packages, all passing.

go.sum: corrects luxfi/edwards25519 v0.1.0 /go.mod hash.
2025-12-28 16:07:25 -08:00
zeekay dd35222450 Merge hanzo/mpc additions: ConsensusKV, HSM providers, policy engine, rename CLI to mpc-cli
- pkg/infra: Add abstract KV interface, ConsensusKV (dual-cert BFT with
  Ed25519 + ML-DSA-65), NatsKV, ConsulKVAdapter, HybridKV, SQLiteMeta
  with full test coverage
- pkg/hsm: Add Provider interface and implementations for AWS KMS,
  GCP Cloud KMS, Azure Key Vault, Zymbit HSM, Hanzo KMS, and file-based
  providers with registry and tests. Rename existing FileProvider to
  FilePasswordProvider to avoid collision with new Provider interface
- pkg/policy: Add transaction governance engine with signers, roles,
  spending limits, whitelist/blacklist, time windows, rate limiting,
  approval workflow, audit log, and FHE private policy evaluation
- contracts: Add ThresholdPolicy.sol for on-chain policy enforcement
- cmd: Rename lux-mpc-cli to mpc-cli
- Makefile: Update build targets for mpc-cli
2025-12-28 03:12:38 -08:00