// // MTConformanceVectors.swift // MontanaTests // // Port of `mt-conformance` crate vectors для cross-implementation // byte-exact verification iOS ↔ Rust reference. См. Rust crate // `Протокол/Код/crates/mt-conformance/src/vectors.rs` — single source. // // Любое изменение этих vectors должно sync-нуться с Rust crate. // import Foundation public struct MTVectorEnvelope { public let name: String public let msgType: UInt8 public let msgVersion: UInt8 public let requestId: UInt64 public let payload: Data public let expectedBytes: Data } public enum MTConformanceVectors { // MARK: - Envelope vectors (group A) public static let envelopeA1Ping = MTVectorEnvelope( name: "A1: Ping empty payload", msgType: 0xF0, msgVersion: 0x01, requestId: 0, payload: Data(), expectedBytes: Data([ 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ]) ) public static let envelopeA2Transfer1024: MTVectorEnvelope = { var expected = Data([ 0x01, 0x01, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, ]) expected.append(Data(repeating: 0xAB, count: 1024)) return MTVectorEnvelope( name: "A2: Transfer 1024B payload, request_id=42", msgType: 0x01, msgVersion: 0x01, requestId: 42, payload: Data(repeating: 0xAB, count: 1024), expectedBytes: expected ) }() public static let envelopeA3FastSyncMaxRequestId = MTVectorEnvelope( name: "A3: FastSyncResponse header-only, request_id=u64::MAX", msgType: 0x41, msgVersion: 0x01, requestId: UInt64.max, payload: Data(), expectedBytes: Data([ 0x41, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, ]) ) public static let allEnvelopeVectors: [MTVectorEnvelope] = [ envelopeA1Ping, envelopeA2Transfer1024, envelopeA3FastSyncMaxRequestId, ] // MARK: - IBT seed vectors (group B) public struct MTVectorIbtSeed { public let name: String public let seedLabel: String public let seed: Data public let pkSha256: Data public let proofSha256: Data } public static let ibtB1OnlineProof = MTVectorIbtSeed( name: "B1: IBT online proof, server [0x42;32], window=1000", seedLabel: "vector-B1", seed: Data([ 0xf6, 0x40, 0x57, 0x69, 0xec, 0xbf, 0x3d, 0x1f, 0x5b, 0x65, 0x93, 0xc9, 0x71, 0xf1, 0x41, 0x09, 0xef, 0x9d, 0x57, 0x62, 0x8b, 0xfc, 0x46, 0xb8, 0xf4, 0xd5, 0xc0, 0xb6, 0x6d, 0x0f, 0xf1, 0xb9, ]), pkSha256: Data([ 0xee, 0x74, 0x16, 0x1e, 0xee, 0xdc, 0xf4, 0x61, 0x89, 0x73, 0x96, 0xbb, 0xe6, 0x55, 0xbc, 0x9c, 0x35, 0x39, 0xf6, 0x15, 0xa3, 0xed, 0xce, 0xf9, 0xf8, 0x7a, 0x9e, 0x58, 0x82, 0xb3, 0x00, 0xc2, ]), proofSha256: Data([ 0xac, 0x26, 0xa9, 0xca, 0x84, 0xa9, 0xae, 0xba, 0x3a, 0xaf, 0x2f, 0x3f, 0xc9, 0xba, 0x2f, 0x0b, 0xe9, 0x0c, 0x6d, 0x98, 0xf6, 0x55, 0xad, 0xdb, 0x0f, 0x87, 0x5b, 0xca, 0xad, 0xff, 0xef, 0xda, ]) ) // MARK: - Bootstrap PoW vectors (group F) public struct MTVectorPow { public let name: String public let difficulty: UInt32 public let target: Data } public static let powF1Difficulty65536: MTVectorPow = { var target = Data(repeating: 0, count: 32) target[1] = 0x01 return MTVectorPow( name: "F1: Bootstrap PoW target derivation, difficulty = 2^16", difficulty: 65_536, target: target ) }() public static let powF2Difficulty1024: MTVectorPow = { var target = Data(repeating: 0, count: 32) target[1] = 0x40 return MTVectorPow( name: "F2: Bootstrap PoW target derivation, difficulty = 2^10", difficulty: 1024, target: target ) }() public static let allPowVectors: [MTVectorPow] = [ powF1Difficulty65536, powF2Difficulty1024, ] }