spb/os-vault Public
Self-custody, multi-chain crypto wallet for macOS. One recovery phrase, six chain families, zero API keys — nothing leaves your Mac.
Swift 96%
Shell 3.4%
Makefile 0.6%
1import WalletCoreC2import Foundation3// SPDX-License-Identifier: Apache-2.04//5// Copyright © 2017 Trust Wallet.6//7// This is a GENERATED FILE, changes made here WILL BE LOST.8//910import Foundation1112/// Tron message signing and verification.13///14/// Tron and some other wallets support a message signing & verification format, to create a proof (a signature)15/// that someone has access to the private keys of a specific address.16public struct TronMessageSigner {1718 /// Sign a message.19 ///20 /// - Parameter privateKey:: the private key used for signing21 /// - Parameter message:: A custom message which is input to the signing.22 /// - Returns:s the signature, Hex-encoded. On invalid input empty string is returned. Returned object needs to be deleted after use.23 public static func signMessage(privateKey: PrivateKey, message: String) -> String {24 let messageString = TWStringCreateWithNSString(message)25 defer {26 TWStringDelete(messageString)27 }28 return TWStringNSString(TWTronMessageSignerSignMessage(privateKey.rawValue, messageString))29 }3031 /// Verify signature for a message.32 ///33 /// - Parameter pubKey:: pubKey that will verify and recover the message from the signature34 /// - Parameter message:: the message signed (without prefix)35 /// - Parameter signature:: in Hex-encoded form.36 /// - Returns:s false on any invalid input (does not throw), true if the message can be recovered from the signature37 public static func verifyMessage(pubKey: PublicKey, message: String, signature: String) -> Bool {38 let messageString = TWStringCreateWithNSString(message)39 defer {40 TWStringDelete(messageString)41 }42 let signatureString = TWStringCreateWithNSString(signature)43 defer {44 TWStringDelete(signatureString)45 }46 return TWTronMessageSignerVerifyMessage(pubKey.rawValue, messageString, signatureString)47 }484950 init() {51 }525354}55