Skip to content

Problem to understand how to retrieve signature #857

Open
@ghost

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions