Skip to content

feat:testing implementation of AppEncryptionRequest handler and vali…#230

Open
iamahmedshahh wants to merge 7 commits intoVerusCoin:generic-request-changesfrom
iamahmedshahh:generic_request_changes
Open

feat:testing implementation of AppEncryptionRequest handler and vali…#230
iamahmedshahh wants to merge 7 commits intoVerusCoin:generic-request-changesfrom
iamahmedshahh:generic_request_changes

Conversation

@iamahmedshahh
Copy link

  • 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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove changes to this file

* @throws {Error} If ESK cannot be retrieved
*/
const getExtendedSpendingKey = async (systemID) => {
const coinId = systemID === 'i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?.()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is a more general util, maybe best placed in a new utils/account/ folder

* @param {Object} request
* @returns {boolean}
*/
const hasEncryptResponseToAddress = (request) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just use the hasEncryptResponseToAddress function on the class, no need to define a new function

return null;
}

if (typeof request.encryptResponseToAddress === 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will never be a string

* @param {Object} request
* @returns {string|null}
*/
const getEncryptResponseToAddress = (request) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add epk

…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
@iamahmedshahh iamahmedshahh force-pushed the generic_request_changes branch from b8cd77f to 4a51dbd Compare February 20, 2026 18:25
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants