Skip to content

Commit 5b6960f

Browse files
committed
WIP
1 parent 645c15d commit 5b6960f

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Sources/K1/K1/ECDSA/ECDSASignatureNonRecoverable.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public struct ECDSASignatureNonRecoverable: Sendable, Hashable, ECSignature {
1212

1313
internal let _rawRepresentation: Data
1414

15+
/// Accepts `R||S` format
16+
public init(p1364: Data) throws {
17+
try self.init(rawRepresentation: swapSignatureByteOrder(p1364))
18+
}
19+
1520
public init<D: DataProtocol>(rawRepresentation: D) throws {
1621
guard
1722
rawRepresentation.count == Self.byteCount

Tests/K1Tests/TestCases/ECDSA/ECDSAWycheproofIEEEP1364RSEncodedSignaturesTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ private struct SignatureWycheproofP1364TestVector: WycheproofTestVector {
4848
struct TooFewBytes: Swift.Error {}
4949
throw TooFewBytes()
5050
}
51-
let signature = try Signature(rawRepresentation: swapSignatureByteOrder(raw))
51+
let signature = try Signature(p1364: raw)
52+
if self.result == "valid" {
53+
try XCTAssertEqual(sig, signature.compactRepresentation().hex)
54+
}
5255
return signature
5356
}
5457

0 commit comments

Comments
 (0)