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

Problem to understand how to retrieve signature #857

Open
luesp15 opened this issue May 20, 2024 · 0 comments
Open

Problem to understand how to retrieve signature #857

luesp15 opened this issue May 20, 2024 · 0 comments

Comments

@luesp15
Copy link

luesp15 commented May 20, 2024

HI,
having used web3.js on the web, I'm using these libraries in the hope of finding the same functions.
However, I'm having trouble finding the equivalent for this code:

const hash = Web3.utils.soliditySha3(...message)
const signature = Web3.eth.accounts.sign(hash, privateKey).

My message is an array of String and Int.

I've tried with this :

let web3Rinkeby = Web3.InfuraRinkebyWeb3()
// discarded this part since I already have an address

    let keystore = try! EthereumKeystoreV3(password: "")
    let keystoreManager = KeystoreManager([keystore!])
    web3Rinkeby.addKeystoreManager(keystoreManager)
    let address = keystoreManager.addresses![0]
//

let data = message.data(using: .utf8)
let ethAddress = EthereumAddress(from: address)!
let signMsg = web3Rinkeby.wallet.signPersonalMessage(data!, account: ethAddress, password: "");

But the signature I receive at the end is nil.
Do you have any idea how I can do it? Considering that I already have a valid address and the privateKey.

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

No branches or pull requests

1 participant