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

'signatureVerificationFailed' while implementing one-click Auth in iOS App #1395

Open
MuhammadWahab0896 opened this issue Aug 2, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@MuhammadWahab0896
Copy link

Describe the bug
i want to implement one-Click Auth in my iOS app, i am following this documentation
https://docs.walletconnect.com/walletkit/ios/one-click-auth
i have also checked the example app and followed that too, in all the cases i found 'signatureVerificationFailed' as a response
this is the code i'm using

let walletAccount = Account(
chainIdentifier: "eip155:1",
address: "0x724d0D2DaD3fbB0C168f947B87Fa5DBe36F1A8bf"
)!
let prvKey = Data(hex: "462c1dad6832d7d96ccf87bd6a686a4110e114aaaebd5512e552c0e3a87b480f")
public func acceptOneAuthRequestNew() {
guard let request = oneAuthRequest else {
return
}
let requestedChains = Set(request.payload.chains.compactMap { Blockchain($0) })
let supportedChainsArray = [Blockchain("eip155:1")!,
Blockchain("eip155:11155111")!,
Blockchain("eip155:137")!,
Blockchain("eip155:80001")!,
Blockchain("eip155:43114")!,
Blockchain("eip155:43113")!,
Blockchain("eip155:56")!]

let supportedChains = Set(supportedChainsArray)
let commonChains = requestedChains.intersection(supportedChains)
let supportedMethods = ["personal_sign", "eth_sendTransaction"]

Task(priority: .high) {
    var authObjects = [AuthObject]()
    for chain in commonChains {
        let accountForChain = Account(blockchain: chain, address: walletAccount.address)!
        let supportedAuthPayload = try Web3Wallet.instance.buildAuthPayload(
            payload: request.payload,
            supportedEVMChains: Array(commonChains),
            supportedMethods: supportedMethods
        )
        let formattedMessage = try Web3Wallet.instance.formatAuthMessage(
            payload: supportedAuthPayload,
            account: walletAccount
        )

        let signerFactory = DefaultSignerFactory()
        let signer = MessageSignerFactory(signerFactory: signerFactory).create()

        let signature = try signer.sign(
            message: formattedMessage,
            privateKey: prvKey,
            type: .eip191
        )

        let authObject = try Web3Wallet.instance.buildSignedAuthObject(
            authPayload: supportedAuthPayload,
            signature: signature,
            account: walletAccount
        )
        authObjects.append(authObject)
    }
    do {
        let sessions = try await Web3Wallet.instance.approveSessionAuthenticate(
            requestId: request.id,
            auths: authObjects
        )
        print("sessions:", sessions)
    } catch {
        print("oneAuth:failed: \(error)")
    }
}

}

@MuhammadWahab0896 MuhammadWahab0896 added the bug Something isn't working label Aug 2, 2024
@tuonght93
Copy link

Same, getting error "Message verification failed" for me.

@tuonght93
Copy link

@MuhammadWahab0896 did you fix this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants