SPB Git

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%
1.4 KB · 57 lines swift
Raw Blame History
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 CryptoBoxPublicKey {1415    /// Determines if the given public key is valid or not.16    /// 17    /// - Parameter data: *non-null* byte array.18    /// - Returns: true if the public 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 TWCryptoBoxPublicKeyIsValid(dataData)25    }2627    /// Returns the raw data of a given public-key.28    /// 29    /// - Parameter public_key: *non-null* pointer to a public key.30    /// - Returns: C-compatible result with a C-compatible byte array.31    public var data: Data {32        return TWDataNSData(TWCryptoBoxPublicKeyData(rawValue))33    }3435    let rawValue: OpaquePointer3637    init(rawValue: OpaquePointer) {38        self.rawValue = rawValue39    }4041    public init?(data: Data) {42        let dataData = TWDataCreateWithNSData(data)43        defer {44            TWDataDelete(dataData)45        }46        guard let rawValue = TWCryptoBoxPublicKeyCreateWithData(dataData) else {47            return nil48        }49        self.rawValue = rawValue50    }5152    deinit {53        TWCryptoBoxPublicKeyDelete(rawValue)54    }5556}57