feat: params crate [skip-line-limit]#1197
Conversation
📝 WalkthroughWalkthroughReplaces the single Changes
Sequence Diagram(s)sequenceDiagram
actor UI
participant SDK
participant FHE_PARAMS as "fhe-params"
participant ENCLAVE
UI->>SDK: request computation
SDK->>FHE_PARAMS: getThresholdBfvParamsSet()
FHE_PARAMS-->>SDK: BfvParams (preset)
SDK->>SDK: encodeBfvParams(BfvParams)
SDK->>ENCLAVE: submit encoded params + payload
ENCLAVE-->>SDK: ack / result
SDK-->>UI: result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
e3-fhe-params cratee3-fhe-params crate [skip-line-limit]
e3-fhe-params crate [skip-line-limit]e3f9d1b to
3fb850f
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
templates/default/client/src/utils/env-config.ts (1)
13-38: Avoid insecure default preset in production. Defaulting toINSECURE_THRESHOLD_BFV_512risks silently shipping weak crypto if the env var is omitted. Consider requiring an explicit preset for production (or failing fast when an insecure preset is detected).🔧 Suggested guard in validation
export function validateEnvVars(): void { if (HAS_MISSING_ENV_VARS) { throw new Error( `Missing required environment variables: ${MISSING_ENV_VARS.join(', ')}\n` + 'Please check your .env file and ensure all required variables are set.', ) } + if (import.meta.env.PROD && THRESHOLD_BFV_PARAMS_PRESET_NAME.startsWith('INSECURE_')) { + throw new Error( + 'THRESHOLD_BFV_PARAMS_PRESET_NAME must be a secure preset in production.', + ) + } }packages/enclave-react/src/useEnclaveSDK.ts (1)
99-121: IncludethresholdBfvParamsPresetNameininitializeSDKdeps.
initializeSDKcloses overconfig.thresholdBfvParamsPresetNamebut the dependency array omits it, so preset updates won’t be picked up (stale params). Add the missing dependency.🔧 Suggested fix
- }, [publicClient, walletClient, config.contracts, config.chainId]) + }, [ + publicClient, + walletClient, + config.contracts, + config.chainId, + config.thresholdBfvParamsPresetName, + ])
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/tests/tests/integration.rs`:
- Around line 126-127: The comment above the parameter construction incorrectly
states "128bits of security"; update it to accurately reflect that
BfvPreset::InsecureThresholdBfv512 is insecure (or indicate its actual security
level) so it doesn't contradict the lambda warning—locate the params_raw
creation (let params_raw =
BfvParamSet::from(BfvPreset::InsecureThresholdBfv512).build_arc()) and change
the comment to note that this preset is insecure (or remove the 128-bit claim).
🧹 Nitpick comments (1)
crates/tests/tests/integration.rs (1)
421-426: Good correctness fix for FHE modular arithmetic.The addition of modulo
plaintext_modulusensures expected results correctly reflect FHE computation semantics.Minor nit: the
.clone()on line 422 is unnecessary sinceArc<T>implementsDeref<Target=T>, allowing direct method calls.Suggested simplification
// Show summation result (mod plaintext modulus) - let plaintext_modulus = params_raw.clone().plaintext(); + let plaintext_modulus = params_raw.plaintext();
|
we currently have the insecure parameters for threshold (TRBFV) to support 10 as plaintext mod. Therefore, I have updated all examples to use values that do not exceed 10 or just checking the result mod the plaintext. This workaround will be fixed when using prod params. |
closes #1204
Removed bfv-helpers by splitting functionality into focused crates:
Summary by CodeRabbit
New Features
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.