Skip to content

Commit

Permalink
feat: make encryption separate product
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Jan 23, 2024
1 parent 59122b7 commit 783fece
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
14 changes: 12 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ let package = Package(
.library(
name: "secp256k1.swift",
targets: ["secp256k1.swift"]),

.library(
name: "encryption_aes_cbc_sha512.swift",
targets: ["encryption_aes_cbc_sha512.swift"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand All @@ -32,10 +36,16 @@ let package = Package(
.target(
name: "secp256k1.swift",
dependencies: ["curvelib"],
path: "Sources/curvelib"
path: "Sources/curvelib/secp256k1"
),
.target(
name: "encryption_aes_cbc_sha512.swift",
dependencies: ["curvelib", "secp256k1.swift"],
path: "Sources/curvelib/encryption"
),

.testTarget(
name: "curvelibTests",
dependencies: ["secp256k1.swift"]),
dependencies: ["secp256k1.swift", "encryption_aes_cbc_sha512.swift"]),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
#if canImport(curvelib)
import curvelib
#endif
import secp256k1_swift

public final class EncryptedMessage {
private(set) var pointer: OpaquePointer?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
#if canImport(curvelib)
import curvelib
#endif
import secp256k1_swift

public final class Encryption {
public static func encrypt(pk: PublicKey, plainText: String) throws -> EncryptedMessage {
Expand Down
4 changes: 2 additions & 2 deletions Sources/curvelib/secp256k1/CurveError.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public struct CurveError: Error, LocalizedError {
enum ErrorType {
public enum ErrorType {
case null
case convert
case parse
Expand All @@ -17,7 +17,7 @@ public struct CurveError: Error, LocalizedError {

private(set) var type: ErrorType

init(code: Int32) {
public init(code: Int32) {
switch code {
case 1: type = .null
case 2: type = .convert
Expand Down
4 changes: 2 additions & 2 deletions Sources/curvelib/secp256k1/PublicKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import Foundation
#endif

public final class PublicKey {
private(set) var pointer: OpaquePointer?
private(set) public var pointer: OpaquePointer?

internal init(ptr: OpaquePointer) {
public init(ptr: OpaquePointer) {
pointer = ptr
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/curvelib/secp256k1/SecretKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Foundation
#endif

public final class SecretKey {
private(set) var pointer: OpaquePointer?
private(set) public var pointer: OpaquePointer?

public init() {
pointer = curve_secp256k1_private_key_generate()
Expand Down
1 change: 1 addition & 0 deletions Tests/curvelibTests/curvelibTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import XCTest
import secp256k1_swift
import encryption_aes_cbc_sha512_swift

final class curvelibTests: XCTestCase {
func testSecretKey() throws {
Expand Down

0 comments on commit 783fece

Please sign in to comment.