feat:testing implementation of AppEncryptionRequest handler and vali…#230
feat:testing implementation of AppEncryptionRequest handler and vali…#230iamahmedshahh wants to merge 7 commits intoVerusCoin:generic-request-changesfrom
Conversation
iamahmedshahh
commented
Feb 18, 2026
- Add handler for AppEncryptionRequest VDXF object
- Add validator for AppEncryptionRequest VDXF object
- Derive encryption channel keys via z_getencryptionaddress
- Support encrypted (DataDescriptor) and unencrypted responses
- Validate responseSignerID is controlled by wallet
- Mock z_functions for testing (USE_MOCK_Z_FUNCTIONS flag)
- Register handler in GenericRequestHome.js
- Added Validator in envelopeValidator
There was a problem hiding this comment.
Please remove changes to this file
| * @throws {Error} If ESK cannot be retrieved | ||
| */ | ||
| const getExtendedSpendingKey = async (systemID) => { | ||
| const coinId = systemID === 'i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV' |
There was a problem hiding this comment.
For this use CoinDirectory.getBasicCoinObj and then get the .id from the coin object it returns
| */ | ||
| const getAppOrDelegatedID = (request) => { | ||
| if (request.hasAppOrDelegatedID && request.hasAppOrDelegatedID()) { | ||
| return request.appOrDelegatedID?.toIAddress?.() |
There was a problem hiding this comment.
hasAppOrDelegatedID is a CompactIAddressObject, it cannot/should not be anything else, if it is not null, please call the appropriate function (toAddress), and don't do checks for different functions
There was a problem hiding this comment.
This comment applies to other places in this file as well, e.g. request.derivationNumber.toNumber || request.derivationNumber (not a CompactIAddressObject but same concept)
| * @param {GenericRequest} request | ||
| * @returns {string|null} | ||
| */ | ||
| const getAppOrDelegatedID = (request) => { |
There was a problem hiding this comment.
Functions like this can be used in other places are best put into the utils/ folder outside of this file, maybe utils/deeplink/helpers
| * @param {Object} activeAccount | ||
| * @returns {string[]} | ||
| */ | ||
| const getAccountAddresses = (activeAccount) => { |
There was a problem hiding this comment.
This function is a more general util, maybe best placed in a new utils/account/ folder
| * @param {Object} request | ||
| * @returns {boolean} | ||
| */ | ||
| const hasEncryptResponseToAddress = (request) => { |
There was a problem hiding this comment.
Please just use the hasEncryptResponseToAddress function on the class, no need to define a new function
| return null; | ||
| } | ||
|
|
||
| if (typeof request.encryptResponseToAddress === 'string') { |
There was a problem hiding this comment.
It will never be a string
| * @param {Object} request | ||
| * @returns {string|null} | ||
| */ | ||
| const getEncryptResponseToAddress = (request) => { |
There was a problem hiding this comment.
Please do not try to account for the encryptResponseToAddress not being a SaplingPaymentAddress, if it somehow is this should be a fatal runtime error, no need to account for those scenarios
| toId: appID, | ||
| hdIndex: request.derivationNumber?.toNumber?.() || request.derivationNumber || 0, | ||
| encryptionIndex: request.derivationID | ||
| ? (typeof request.derivationID.toNumber === "function" |
There was a problem hiding this comment.
Do not check if this is a function, see what type it is supposed to be, and only account for it being that type
| objectdata: Buffer.from(encryptResult.result, 'hex') | ||
| }); | ||
|
|
||
| return new DataDescriptorOrdinalVDXFObject({ |
…ator - Add handler for AppEncryptionRequest VDXF object - Add validator for AppEncryptionRequest VDXF object - Derive encryption channel keys via z_getencryptionaddress - Support encrypted (DataDescriptor) and unencrypted responses - Validate responseSignerID is controlled by wallet - Mock z_functions for testing (USE_MOCK_Z_FUNCTIONS flag) - Register handler in GenericRequestHome.js - Added Validator in envelopeValidator
- created getAppOrDelegatedID as a helper function. - added getAccountAddresses as a helper function - fixed hdIndex in parameters to 0 because we are using a spendingKey and encryptionIndex to derivationNumber for the encryption channel - fixed typo in const eskFlag property name -fixed typo in conversion function is called toAddress -removed unnessary validation functions - removeed ValidateResponseSignerID check - removed activeAccount entirely
b8cd77f to
4a51dbd
Compare
created getAppOrDelegatedID as a helper function. added getAccountAddresses as a helper function fixed hdIndex in parameters to 0 because we are using a spendingKey and encryptionIndex to derivationNumber for the encryption channel fixed typo in const eskFlag property name tested implementation testing real functions more efficient removed unused imports
- added getAccountAddress as a utility function - fixed validation from returnESK if not returned and is requested it should throw an error
-- renamed functions -- changed params to string that goes in react-native-verus -- response converted to Buffer