Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use proof instead of root in signUserOpHash #264

Conversation

protodev-rage
Copy link

Description

As per https://github.com/bcnmy/scw-contracts/blob/SCW-V2-Modular-SA/contracts/smart-account/modules/SessionKeyManagerModule.sol#L79-L86 merkleProof should be getHexProof of keccack256 of leaf

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

not test extensively, just matched specs with contract

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

@livingrockrises livingrockrises left a comment

Choose a reason for hiding this comment

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

reviewed

@@ -142,6 +142,15 @@ export class SessionKeyManagerModule extends BaseValidationModule {
throw new Error('sessionID or sessionValidationModule should be provided.')
}

const leafDataHex = ethers.utils.keccak256(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be like below,

const leafData = hexConcat([
        hexZeroPad(ethers.utils.hexlify(validUntil), 6),
        hexZeroPad(ethers.utils.hexlify(validAfter), 6),
        hexZeroPad(mockSessionValidationModule.address, 20),
        sessionKeyData,
      ]);

Copy link
Contributor

@livingrockrises livingrockrises Aug 25, 2023

Choose a reason for hiding this comment

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

const leafDataHex = hexConcat([
      hexZeroPad(ethers.utils.hexlify(sessionSignerData.validUntil), 6),
      hexZeroPad(ethers.utils.hexlify(sessionSignerData.validAfter), 6),
      hexZeroPad(sessionSignerData.sessionValidationModule, 20),
      sessionSignerData.sessionKeyData
    ])

    // Generate the padded signature with (validUntil,validAfter,sessionVerificationModuleAddress,validationData,merkleProof,signature)
    let paddedSignature = defaultAbiCoder.encode(
      ['uint48', 'uint48', 'address', 'bytes', 'bytes32[]', 'bytes'],
      [
        sessionSignerData.validUntil,
        sessionSignerData.validAfter,
        sessionSignerData.sessionValidationModule,
        sessionSignerData.sessionKeyData,
        this.merkleTree.getHexProof(ethers.utils.keccak256(leafDataHex)),
        signature
      ]
    )

Copy link
Contributor

Choose a reason for hiding this comment

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

edited above code.

Copy link
Author

Choose a reason for hiding this comment

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

fixed in b3da05f

@livingrockrises
Copy link
Contributor

can you also change the base to main feat branch - feat/modular-SA-V2-integration

@protodev-rage protodev-rage changed the base branch from feat/update-signing-methods-and-flows to feat/modular-SA-V2-integration August 26, 2023 02:50
Copy link
Contributor

@livingrockrises livingrockrises left a comment

Choose a reason for hiding this comment

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

LGTM

@livingrockrises livingrockrises merged commit 6510f64 into bcnmy:feat/modular-SA-V2-integration Aug 26, 2023
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