Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Jun 23, 2022
1 parent 51405d6 commit 3c1e052
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 88 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ jobs:
with:
xcode-version: '13.2'

- uses: actions/cache@v2
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-

# Package builds
- name: Build Package
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,82 @@
import Foundation
import CryptoKit

extension Curve25519.Signing.PublicKey: Equatable {
public static func == (lhs: Curve25519.Signing.PublicKey, rhs: Curve25519.Signing.PublicKey) -> Bool {
lhs.rawRepresentation == rhs.rawRepresentation
}
}

extension Curve25519.Signing.PrivateKey: Equatable {
public static func == (lhs: Curve25519.Signing.PrivateKey, rhs: Curve25519.Signing.PrivateKey) -> Bool {
lhs.rawRepresentation == rhs.rawRepresentation
}
}

// MARK: - Public Key

public struct SigningPublicKey: GenericPasswordConvertible, Equatable {
fileprivate let key: Curve25519.Signing.PublicKey

fileprivate init(publicKey: Curve25519.Signing.PublicKey) {
self.key = publicKey
}

public init<D>(rawRepresentation data: D) throws where D: ContiguousBytes {
self.key = try Curve25519.Signing.PublicKey(rawRepresentation: data)
}

public init(hex: String) throws {
let data = Data(hex: hex)
try self.init(rawRepresentation: data)
}

public var rawRepresentation: Data {
key.rawRepresentation
}

public var hexRepresentation: String {
key.rawRepresentation.toHexString()
}
}

extension SigningPublicKey: Codable {

public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(key.rawRepresentation)
}

public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let buffer = try container.decode(Data.self)
try self.init(rawRepresentation: buffer)
}
}

// MARK: - Private Key

public struct SigningPrivateKey: GenericPasswordConvertible, Equatable {
private let key: Curve25519.Signing.PrivateKey

public init() {
self.key = Curve25519.Signing.PrivateKey()
}

public init<D>(rawRepresentation data: D) throws where D: ContiguousBytes {

self.key = try Curve25519.Signing.PrivateKey(rawRepresentation: data)
}

public var rawRepresentation: Data {
key.rawRepresentation
}

public var publicKey: SigningPublicKey {
SigningPublicKey(publicKey: key.publicKey)
}

public func signature(for data: Data) throws -> Data {
try key.signature(for: data)
}
}

This file was deleted.

0 comments on commit 3c1e052

Please sign in to comment.