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%
2.4 KB · 68 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 WebAuthnSolidity {1415    /// Computes WebAuthn message hash to be signed with secp256p1 private key.16    /// 17    /// - Parameter authenticator_data: The authenticator data in hex format.18    /// - Parameter client_data_json: The client data JSON string with a challenge.19    /// - Returns: WebAuthn message hash.20    public static func getMessageHash(authenticatorData: String, clientDataJson: String) -> Data? {21        let authenticatorDataString = TWStringCreateWithNSString(authenticatorData)22        defer {23            TWStringDelete(authenticatorDataString)24        }25        let clientDataJsonString = TWStringCreateWithNSString(clientDataJson)26        defer {27            TWStringDelete(clientDataJsonString)28        }29        guard let result = TWWebAuthnSolidityGetMessageHash(authenticatorDataString, clientDataJsonString) else {30            return nil31        }32        return TWDataNSData(result)33    }3435    /// Converts the original ASN-encoded signature from webauthn to the format accepted by Barz36    /// 37    /// - Parameter authenticator_data: The authenticator data in hex format.38    /// - Parameter client_data_json: The client data JSON string with a challenge.39    /// - Parameter der_signature: original ASN-encoded signature from webauthn.40    /// - Returns: WebAuthn ABI-encoded data.41    public static func getFormattedSignature(authenticatorData: String, clientDataJson: String, derSignature: Data) -> Data? {42        let authenticatorDataString = TWStringCreateWithNSString(authenticatorData)43        defer {44            TWStringDelete(authenticatorDataString)45        }46        let clientDataJsonString = TWStringCreateWithNSString(clientDataJson)47        defer {48            TWStringDelete(clientDataJsonString)49        }50        let derSignatureData = TWDataCreateWithNSData(derSignature)51        defer {52            TWDataDelete(derSignatureData)53        }54        guard let result = TWWebAuthnSolidityGetFormattedSignature(authenticatorDataString, clientDataJsonString, derSignatureData) else {55            return nil56        }57        return TWDataNSData(result)58    }5960    let rawValue: OpaquePointer6162    init(rawValue: OpaquePointer) {63        self.rawValue = rawValue64    }656667}68