An advanced Ethereum/EVM mobile wallet
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
alpha-wallet-ios/Trust/Redeem/Helpers/SignatureHelper.swift

29 lines
879 B

//
// SignatureHelper.swift
// Alpha-Wallet
//
// Created by Oguzhan Gungor on 3/8/18.
// Copyright © 2018 Alpha-Wallet. All rights reserved.
//
import Foundation
import TrustKeystore
import BigInt
class SignatureHelper {
class func signatureAsHex(for message: String, account: Account) -> String? {
let keystore = try! EtherKeystore()
let signature = keystore.signMessageData(message.data(using: String.Encoding.utf8), for: account)
let signatureHex = try? signature.dematerialize().hex(options: .upperCase)
guard let data = signatureHex else {
return nil
}
return data
}
class func signatureAsDecimal(for message: String, account: Account) -> String? {
let signatureHex = signatureAsHex(for: message, account: account)!
return BigInt(signatureHex, radix: 16)!.description
}
}