-
Notifications
You must be signed in to change notification settings - Fork 24
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
Bug: func createIdentity() always fails #132
Comments
Thanks for the bug report @rommex I'm not able to reproduce this on my end. We test |
Hi @nplasterer thanks for your response. I had to take some time to investigate and found out that it's not the signing process itself that was causing the problem, but the fact that I omitted this line of code which seems to be present in your code:
Basically your code alters the last byte of the signature to 0 or 1 depending on the last byte of the original signature. As I understand your code alters all signatures, even coming from external wallets like MetaMask etc Thanks! |
The last byte of the signature is the ECDSA recoveryID. It's used to tell which EC point to use during recovery. Individual projects sometimes choose to use special encodings of this value( e.g: EIP-155, and BIP-137 ) XMTP uses the canonical values [0,1] as the protocol is chain agnostic. Since signers make different assumptions about how the V value should be encoded, our SDKS force all signatures it into the base range for maximum interop. |
Describe the bug
We are trying to integrate the SDK with our app and we find that the method
createIdentity()
constantly fails in line 41 of theSigningKey.swift
file:let recoveredKey = try KeyUtilx.recoverPublicKeyKeccak256(from: signature.rawData, message: message)
Expected behavior
I tried to replicate this flow with the standard SECP256K1 library (signing + recovery) and it works with one condition:
Signing as well as recovery is done with the keccak hash of the message, not the message itself (as you have currently in the line 41)
Steps to reproduce the bug
Just try to create an identity
The text was updated successfully, but these errors were encountered: