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 Foundation111213public final class CryptoBoxSecretKey {1415 /// Determines if the given secret key is valid or not.16 /// 17 /// - Parameter data: *non-null* byte array.18 /// - Returns: true if the secret key is valid, false otherwise.19 public static func isValid(data: Data) -> Bool {20 let dataData = TWDataCreateWithNSData(data)21 defer {22 TWDataDelete(dataData)23 }24 return TWCryptoBoxSecretKeyIsValid(dataData)25 }2627 /// Returns the raw data of a given secret-key.28 /// 29 /// - Parameter secret_key: *non-null* pointer to a secret key.30 /// - Returns: C-compatible result with a C-compatible byte array.31 public var data: Data {32 return TWDataNSData(TWCryptoBoxSecretKeyData(rawValue))33 }3435 let rawValue: OpaquePointer3637 init(rawValue: OpaquePointer) {38 self.rawValue = rawValue39 }4041 public init() {42 rawValue = TWCryptoBoxSecretKeyCreate()43 }4445 public init?(data: Data) {46 let dataData = TWDataCreateWithNSData(data)47 defer {48 TWDataDelete(dataData)49 }50 guard let rawValue = TWCryptoBoxSecretKeyCreateWithData(dataData) else {51 return nil52 }53 self.rawValue = rawValue54 }5556 deinit {57 TWCryptoBoxSecretKeyDelete(rawValue)58 }5960 /// Returns the public key associated with the given `key`.61 /// 62 /// - Parameter key: *non-null* pointer to the private key.63 /// - Returns: *non-null* pointer to the corresponding public key.64 public func getPublicKey() -> CryptoBoxPublicKey {65 return CryptoBoxPublicKey(rawValue: TWCryptoBoxSecretKeyGetPublicKey(rawValue))66 }6768}69