Skip to content

Commit

Permalink
fix: update Package
Browse files Browse the repository at this point in the history
Signed-off-by: Ricky Saechao <ricky@launchbadge.com>
  • Loading branch information
RickyLB committed Apr 30, 2024
1 parent 6c57705 commit 75c3668
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 40 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/swift-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
format:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install swift-format
run: brew install swift-format
- name: Format
Expand All @@ -22,21 +22,21 @@ jobs:

runs-on: ${{ matrix.os }}
steps:
- uses: swift-actions/setup-swift@v1
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: sdk/swift/.build
path: .build
key: ${{ runner.os }}-${{ matrix.swift }}-spm-${{ github.job }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ matrix.swift }}-spm-
- name: Build
run: swift build
run: swift build -v

test:
strategy:
Expand All @@ -47,14 +47,14 @@ jobs:
needs: [build]
runs-on: ${{ matrix.os }}
steps:
- uses: swift-actions/setup-swift@v1
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: sdk/swift/.build
path: .build
key: ${{ runner.os }}-${{ matrix.swift }}-spm-${{ github.job }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ matrix.swift }}-spm-
Expand Down
72 changes: 45 additions & 27 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "db51c407d3be4a051484a141bf0bff36c43d3b1e",
"version" : "1.8.0"
"revision" : "c9c3df6ab812de32bae61fc0cd1bf6d45170ebf0",
"version" : "1.8.2"
}
},
{
"identity" : "grpc-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift.git",
"state" : {
"revision" : "84bac657e9930d26e9124bac082f26586dc2d209",
"version" : "1.19.1"
"revision" : "6a90b7e77e29f9bda6c2b3a4165a40d6c02cfda1",
"version" : "1.23.0"
}
},
{
Expand Down Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "a902f1823a7ff3c9ab2fba0f992396b948eda307",
"version" : "1.0.5"
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
Expand Down Expand Up @@ -90,94 +90,112 @@
"version" : "1.2.0"
}
},
{
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "12358d55a3824bd5fed310b999ea8cf83a9a1a65",
"version" : "1.0.3"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "3db5c4aeee8100d2db6f1eaf3864afdad5dc68fd",
"version" : "2.59.0"
"revision" : "359c461e5561d22c6334828806cc25d759ca7aa6",
"version" : "2.65.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "fb70a0f5e984f23be48b11b4f1909f3bee016178",
"version" : "1.19.1"
"revision" : "a3b640d7dc567225db7c94386a6e71aded1bfa63",
"version" : "1.22.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "a8ccf13fa62775277a5d56844878c828bbb3be1a",
"version" : "1.27.0"
"revision" : "c6afe04165c865faaa687b42c32ed76dfcc91076",
"version" : "1.31.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9",
"version" : "2.25.0"
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version" : "2.26.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "e7403c35ca6bb539a7ca353b91cc2d8ec0362d58",
"version" : "1.19.0"
"revision" : "6cbe0ed2b394f21ab0d46b9f0c50c6be964968ce",
"version" : "1.20.1"
}
},
{
"identity" : "swift-numberkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/objecthub/swift-numberkit.git",
"state" : {
"revision" : "0f9c918dcea73f6ff4ff762b8e83a0991ca668d9",
"version" : "2.4.2"
"revision" : "38c649a58989ae80f8b0694b0b9826130df5c18f",
"version" : "2.5.1"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "3c54ab05249f59f2c6641dd2920b8358ea9ed127",
"version" : "1.24.0"
"revision" : "9f0c76544701845ad98716f3f6a774a892152bcb",
"version" : "1.26.0"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : {
"revision" : "5b356adceabff6ca027f6574aac79e9fee145d26",
"version" : "1.14.1"
"revision" : "625ccca8570773dd84a34ee51a81aa2bc5a4f97a",
"version" : "1.16.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"location" : "https://github.com/apple/swift-syntax",
"state" : {
"revision" : "fa8f95c2d536d6620cc2f504ebe8a6167c9fc2dd",
"version" : "510.0.1"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
"revision" : "025bcb1165deab2e20d4eaba79967ce73013f496",
"version" : "1.2.1"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
```swift
// Package.swift
dependencies: [
.package(url: "https://github.com/hashgraph/hedera-sdk-swift.git", from: "0.1.0")
.package(url: "https://github.com/hashgraph/hedera-sdk-swift.git", from: "0.27.0")
]
```

Expand Down
39 changes: 37 additions & 2 deletions Sources/Hedera/PublicKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ public struct PublicKey: LosslessStringConvertible, ExpressibleByStringLiteral,
default:
try self.init(derBytes: bytes)
}

do {
self.init(.ecdsa(try .init(dataRepresentation: bytes, format: .compressed)))
} catch {
throw HError.keyParse(String(describing: error))
}

}

public static func fromBytesEcdsa(_ bytes: Data) throws -> Self {
Expand Down Expand Up @@ -284,7 +291,7 @@ public struct PublicKey: LosslessStringConvertible, ExpressibleByStringLiteral,

public func toBytesRaw() -> Data {
switch kind {
case .ecdsa(let key): return key.toBytes(format: .compressed)
case .ecdsa(let key): return key.dataRepresentation
case .ed25519(let key): return key.rawRepresentation
}
}
Expand Down Expand Up @@ -364,7 +371,35 @@ public struct PublicKey: LosslessStringConvertible, ExpressibleByStringLiteral,
return nil
}

let output = key.toBytes(format: .uncompressed)
// when the bindings aren't enough :/
var pubkey = secp256k1_pubkey()

key.dataRepresentation.withUnsafeTypedBytes { bytes in
let result = secp256k1_bindings.secp256k1_ec_pubkey_parse(
secp256k1.Context.rawRepresentation,
&pubkey,
bytes.baseAddress!,
bytes.count
)

precondition(result == 1)
}

var output = Data(repeating: 0, count: 65)

output.withUnsafeMutableTypedBytes { output in
var outputLen = output.count

let result = secp256k1_ec_pubkey_serialize(
secp256k1.Context.rawRepresentation, output.baseAddress!,
&outputLen,
&pubkey,
secp256k1.Format.uncompressed.rawValue
)

precondition(result == 1)
precondition(outputLen == output.count)
}

// note(important): sec1 uncompressed point
let hash = Crypto.Sha3.keccak256(output[1...])
Expand Down

0 comments on commit 75c3668

Please sign in to comment.