Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make multiple products from package #3

Merged
merged 6 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
with:
platform: ${{ matrix.platform }}
action: test
scheme: curvelib.swift
scheme: curvelib.swift-Package
code-coverage: true
upload-logs: always
66 changes: 66 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/curveSecp256k1.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "curveSecp256k1"
BuildableName = "curveSecp256k1"
BlueprintName = "curveSecp256k1"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "curveSecp256k1"
BuildableName = "curveSecp256k1"
BlueprintName = "curveSecp256k1"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
106 changes: 106 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/curvelib.swift-Package.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "curveSecp256k1"
BuildableName = "curveSecp256k1"
BlueprintName = "curveSecp256k1"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "encryption_aes_cbc_sha512"
BuildableName = "encryption_aes_cbc_sha512"
BlueprintName = "encryption_aes_cbc_sha512"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "curvelibTests"
BuildableName = "curvelibTests"
BlueprintName = "curvelibTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "curvelibTests"
BuildableName = "curvelibTests"
BlueprintName = "curvelibTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "curveSecp256k1"
BuildableName = "curveSecp256k1"
BlueprintName = "curveSecp256k1"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "encryption_aes_cbc_sha512"
BuildableName = "encryption_aes_cbc_sha512"
BlueprintName = "encryption_aes_cbc_sha512"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "encryption_aes_cbc_sha512"
BuildableName = "encryption_aes_cbc_sha512"
BlueprintName = "encryption_aes_cbc_sha512"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
20 changes: 15 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ let package = Package(
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "curvelib.swift",
targets: ["curvelib.swift"]),
name: "curveSecp256k1",
targets: ["curveSecp256k1"]),

.library(
name: "encryption_aes_cbc_sha512",
targets: ["encryption_aes_cbc_sha512"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand All @@ -30,12 +34,18 @@ let package = Package(
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "curvelib.swift",
name: "curveSecp256k1",
dependencies: ["curvelib"],
path: "Sources/curvelib"
path: "Sources/curvelib/secp256k1"
),
.target(
name: "encryption_aes_cbc_sha512",
dependencies: ["curvelib", "curveSecp256k1"],
path: "Sources/curvelib/encryption"
),

.testTarget(
name: "curvelibTests",
dependencies: ["curvelib.swift"]),
dependencies: ["curveSecp256k1", "encryption_aes_cbc_sha512"]),
]
)
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 curveSecp256k1

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 curveSecp256k1

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
2 changes: 1 addition & 1 deletion Tests/curvelibTests/curvelibErrorTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import XCTest
@testable import curvelib_swift
@testable import curveSecp256k1

final class curvelibErrorTests: XCTestCase {
func testCurveError() {
Expand Down
3 changes: 2 additions & 1 deletion Tests/curvelibTests/curvelibTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import XCTest
import curvelib_swift
@testable import curveSecp256k1
@testable import encryption_aes_cbc_sha512

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