mirror of
https://github.com/luxwallet/ios.git
synced 2026-10-30 20:33:27 +00:00
45 lines
3.4 KiB
Swift
45 lines
3.4 KiB
Swift
import HsExtensions
|
|
@testable import Unstoppable
|
|
@testable import WalletCore
|
|
import XCTest
|
|
|
|
final class Secp256r1VerificationFacetTests: XCTestCase {
|
|
func testEncodeInitializeSigner() {
|
|
let data = Secp256r1VerificationFacet.encodeInitializeSigner(publicKey: ownerPublicKey())
|
|
|
|
XCTAssertEqual(
|
|
data.hs.hex,
|
|
"cd9b47e400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000041041111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000000000000000000000000000000000000000000000000000000000000"
|
|
)
|
|
}
|
|
|
|
func testPackSignatureRoundTrip() throws {
|
|
let data = try Secp256r1VerificationFacet.packSignature(
|
|
r: Data(repeating: 0x11, count: 32),
|
|
s: Data(repeating: 0x22, count: 32),
|
|
authenticatorData: Data(repeating: 0x33, count: 37),
|
|
clientDataJSONPre: #"{"type":"webauthn.get","challenge":""#,
|
|
clientDataJSONPost: #"","origin":"https://unstoppable.money","crossOrigin":false}"#
|
|
)
|
|
|
|
XCTAssertEqual(
|
|
data.hs.hex,
|
|
"1111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000253333333333333333333333333333333333333333333333333333333333333333333333333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000247b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003b222c226f726967696e223a2268747470733a2f2f756e73746f707061626c652e6d6f6e6579222c2263726f73734f726967696e223a66616c73657d0000000000"
|
|
)
|
|
}
|
|
|
|
func testDummySignatureSize() {
|
|
let signature = Secp256r1VerificationFacet.dummySignature()
|
|
|
|
XCTAssertEqual(
|
|
signature.hs.hex,
|
|
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000247b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003b222c226f726967696e223a2268747470733a2f2f756e73746f707061626c652e6d6f6e6579222c2263726f73734f726967696e223a66616c73657d0000000000"
|
|
)
|
|
XCTAssertEqual(signature.count, 448)
|
|
}
|
|
|
|
private func ownerPublicKey() -> Data {
|
|
Data("0411111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222".hs.hexData!)
|
|
}
|
|
}
|