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 struct WebAuthn {1415 /// Converts attestation object to the public key on P256 curve16 ///17 /// - Parameter attestationObject: Attestation object retrieved from webuthn.get method18 /// - Returns: Public key.19 public static func getPublicKey(attestationObject: Data) -> PublicKey? {20 let attestationObjectData = TWDataCreateWithNSData(attestationObject)21 defer {22 TWDataDelete(attestationObjectData)23 }24 guard let value = TWWebAuthnGetPublicKey(attestationObjectData) else {25 return nil26 }27 return PublicKey(rawValue: value)28 }2930 /// Uses ASN parser to extract r and s values from a webauthn signature31 ///32 /// - Parameter signature: ASN encoded webauthn signature: https://www.w3.org/TR/webauthn-2/#sctn-signature-attestation-types33 /// - Returns: Concatenated r and s values.34 public static func getRSValues(signature: Data) -> Data? {35 let signatureData = TWDataCreateWithNSData(signature)36 defer {37 TWDataDelete(signatureData)38 }39 guard let result = TWWebAuthnGetRSValues(signatureData) else {40 return nil41 }42 return TWDataNSData(result)43 }4445 /// Reconstructs the original message that was signed via P256 curve. Can be used for signature validation.46 ///47 /// - Parameter authenticatorData: Authenticator Data: https://www.w3.org/TR/webauthn-2/#authenticator-data48 /// - Parameter clientDataJSON: clientDataJSON: https://www.w3.org/TR/webauthn-2/#dom-authenticatorresponse-clientdatajson49 /// - Returns: original messages.50 public static func reconstructOriginalMessage(authenticatorData: Data, clientDataJSON: Data) -> Data {51 let authenticatorDataData = TWDataCreateWithNSData(authenticatorData)52 defer {53 TWDataDelete(authenticatorDataData)54 }55 let clientDataJSONData = TWDataCreateWithNSData(clientDataJSON)56 defer {57 TWDataDelete(clientDataJSONData)58 }59 return TWDataNSData(TWWebAuthnReconstructOriginalMessage(authenticatorDataData, clientDataJSONData))60 }616263 init() {64 }656667}68