feat(blockchain): signer mode + signer_address pass-through (DEV-132)#7
Merged
Conversation
Adds an alternative signer mode that accepts a viem `Account` and sends a regular EOA transaction via `WalletClient` instead of a ZeroDev UserOperation. Designed for backend-caller patterns where the backend (e.g. KMS-backed) creates invoices and pays gas itself, while the user's main wallet is the encrypted owner. Public surface: - `BlockchainConfig.signer?: Account` (legacy `serializedSessionKey` stays optional and continues to work) - `createWalletClientFromSigner(config)` factory - Constructor of `PrivaraBlockchain` requires exactly one of `signer` or `serializedSessionKey`; throws on conflict or missing config Calldata encoding and `Privara.transactions.report` reporting are unchanged across modes. Unit tests cover signer happy path, legacy backwards-compat, constructor validation, identical-calldata across modes, lazy client cache. Version bumped 0.1.0 -> 0.2.0. Note on E2E: an end-to-end on-chain confirmation against the current /dev backend is blocked by an upstream backend issue. `ConfidentialEscrow.create` calls `verifyInput(input, msg.sender)` and the backend's FHE worker currently encrypts with `userAddress = walletAddress` taken from the auth context. Either path (legacy session-key or signer mode) reverts with `InvalidSigner` when the actual `msg.sender` differs from that auth-bound `walletAddress`. The SDK side is verified at unit-test level and by simulation; the on-chain green path requires the backend to use the actual caller (backend EOA) as the FHE sender. See ReineiraOS/tasks/agents-backend-frontend.md for the required backend change.
…132) When `PrivaraBlockchain` is configured in signer mode, `createAndSubmit` now sends the signer EOA's address as `signer_address` in the body of `POST /api/v1/invoices`. The backend (DEV-132 backend change) uses this as the FHE sender bound into the Fhenix verifier signature. Without it the on-chain transaction reverts with `InvalidSigner` because the actual msg.sender (backend EOA) does not match the address baked into the signature (which would default to walletAddress from auth context). In legacy session-key mode `signer_address` is omitted — behavior unchanged. Adds `PrivaraBlockchain.getSignerAddress(): string | undefined`. Bumped 0.2.0 -> 0.2.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two commits combined:
feat(blockchain): add signer mode to PrivaraBlockchain (DEV-132)(e36b90d)BlockchainConfig.signer?: Account— alternative signer mode that sends a regular EOA tx viaWalletClientinstead of a ZeroDev UserOperation.PrivaraBlockchainrequires exactly one ofsignerorserializedSessionKey; throws on conflict or missing config.Privara.transactions.reportreporting are unchanged across modes.feat(blockchain): pass signer_address to backend in signer mode (DEV-132)(555401b)BlockchainInvoices.createAndSubmitforwards the signer EOA's address assigner_addresstoPOST /api/v1/invoices. Required so the backend uses that address as the FHE sender (matching the on-chainmsg.sender); otherwise the contract reverts withInvalidSigner.PrivaraBlockchain.getSignerAddress(): string | undefined.Why
Phase 1 of the "Drop Session Keys via Backend-Caller Pattern" plan. Backend pays gas with its own KMS-backed EOA; the user's main passkey wallet is the encrypted owner (sole entity that can
redeem). No contract changes — seetasks/agents-sdk.mdfor context.Test plan
npm run typecheck— cleannpm test— 57/57 ✅ (signer happy path, legacy backwards-compat, conflict throw, missing-config throw, identical-calldata, lazy-cache, signer_address pass-through, legacy-mode omit, getSignerAddress)npm run build— clean dts/cjs/esm0xa064357...,from= signer EOA,to= ConfidentialEscrow, statussuccessLinked