js-sdk icon indicating copy to clipboard operation
js-sdk copied to clipboard

auth method id for eth wallet is just the wallet address

Open glitch003 opened this issue 10 months ago • 1 comments

The encoding for the EthWallet auth method type was wrong. It should just be the raw address. You can see this in the PKPPermissions facet here: https://github.com/LIT-Protocol/lit-assets/blob/8d26f49faf8d1648fb50deb9ff8d45a68ed49f80/blockchain/contracts/contracts/lit-node/PKPPermissions/PKPPermissionsFacet.sol#L506

Note that there is not ":lit" appended, no keccak256, etc. it's just the address bytes.

For context, this is the function where the changed line is:

public static async authMethodId(authMethod: AuthMethod): Promise<string> {
    let address: string;

    try {
      address = JSON.parse(authMethod.accessToken).address;
    } catch (err) {
      throw new Error(
        `Error when parsing auth method to generate auth method ID for Eth wallet: ${err}`
      );
    }

    return address;
  }

glitch003 avatar Apr 25 '24 01:04 glitch003

@glitch003 We need to hold off merging this until the below ticket is ready on the nodes: https://linear.app/litprotocol/issue/LIT-3035/fix-check-for-raw-address-when-verifying-the-eth-authmethod

joshLong145 avatar Apr 25 '24 12:04 joshLong145

Is this still valid @glitch003 @joshLong145 @DashKash54 ?

Ansonhkg avatar Jul 15 '24 15:07 Ansonhkg

Closing for now.

Ansonhkg avatar Jul 17 '24 09:07 Ansonhkg

i looked into this - it's done already on the node side https://github.com/LIT-Protocol/lit-assets/pull/1077

the node accepts either format - this is the function that checks if you're curious - https://github.com/LIT-Protocol/lit-assets/blob/74fcbfa0aa4425a94e264168a2290c8fe8826267/rust/lit-node/src/pkp/auth/mod.rs#L548

glitch003 avatar Jul 25 '24 00:07 glitch003