Skip to content

Commit

Permalink
Deps updated
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Oct 28, 2024
1 parent 395d665 commit 3bb2bbc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
"state": {
"branch": null,
"revision": "78424be314842833c04bc3bef5b72e85fff99204",
"version": "5.6.4"
"revision": "e16d3481f5ed35f0472cb93350085853d754913f",
"version": "5.10.1"
}
},
{
"package": "secp256k1",
"package": "swift-secp256k1",
"repositoryURL": "https://github.com/GigaBitcoin/secp256k1.swift.git",
"state": {
"branch": null,
"revision": "48fb20fce4ca3aad89180448a127d5bc16f0e44c",
"version": "0.10.0"
"revision": "57ce9af6db14e0114af631ace25231a9d0ccccbd",
"version": "0.18.0"
}
}
]
Expand Down
12 changes: 6 additions & 6 deletions Sources/XyoClient/Address/XyoAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class XyoAddress {
private var _privateKey: secp256k1.Signing.PrivateKey?

public init(_ privateKey: Data? = generateRandomBytes()) {
self._privateKey = try? secp256k1.Signing.PrivateKey(rawRepresentation: privateKey ?? generateRandomBytes(32), format: .uncompressed)
self._privateKey = try? secp256k1.Signing.PrivateKey(dataRepresentation: privateKey ?? generateRandomBytes(32), format: .uncompressed)
}

convenience init(privateKey: String) {
Expand All @@ -21,7 +21,7 @@ public class XyoAddress {

public var privateKeyBytes: Data? {
get {
return _privateKey?.rawRepresentation
return _privateKey?.dataRepresentation
}
}

Expand All @@ -39,7 +39,7 @@ public class XyoAddress {

public var publicKeyBytes: Data? {
get {
return _privateKey?.publicKey.rawRepresentation.subdata(in: 1..<(_privateKey?.publicKey.rawRepresentation.count ?? 0))
return _privateKey?.publicKey.dataRepresentation.subdata(in: 1..<(_privateKey?.publicKey.dataRepresentation.count ?? 0))
}
}

Expand Down Expand Up @@ -80,7 +80,7 @@ public class XyoAddress {
let message = hash.hexToData()
guard (message != nil) else { return nil }
let sig = self.signature(message!)
return sig?.rawRepresentation.toHex()
return sig?.dataRepresentation.toHex()
}

public func signature(_ hash: Data) -> secp256k1.Signing.ECDSASignature? {
Expand All @@ -92,7 +92,7 @@ public class XyoAddress {
var signature = secp256k1_ecdsa_signature()

let arrayHash = Array(hash)
let privKey = Array(self._privateKey!.rawRepresentation)
let privKey = Array(self._privateKey!.dataRepresentation)

guard secp256k1_ecdsa_sign(context, &signature, arrayHash, privKey, nil, nil) == 1 else {
throw secp256k1Error.underlyingCryptoError
Expand All @@ -110,7 +110,7 @@ public class XyoAddress {

let rawRepresentation = Data(bytes: &signature2.data, count: MemoryLayout.size(ofValue: signature2.data))

return try secp256k1.Signing.ECDSASignature(rawRepresentation: rawRepresentation)
return try secp256k1.Signing.ECDSASignature(dataRepresentation: rawRepresentation)
} catch {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XyoClient/ArchivistApi/ArchivistApiClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class XyoArchivistApiClient {
method: .post,
parameters: body,
encoder: JSONParameterEncoder.default
).responseJSON(queue: XyoArchivistApiClient.queue) { response in
).responseData(queue: XyoArchivistApiClient.queue) { response in
switch response.result {
case .failure( _):
XyoArchivistApiClient.mainQueue.async {
Expand Down
11 changes: 9 additions & 2 deletions Sources/XyoClient/extensions/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import Foundation
import keccak

extension Data {
var pointer: UnsafePointer<UInt8>! { return withUnsafeBytes { $0 } }
var pointer: UnsafePointer<UInt8>! {
return withUnsafeBytes { (bytes: UnsafeRawBufferPointer) -> UnsafePointer<UInt8>? in
bytes.baseAddress?.assumingMemoryBound(to: UInt8.self)
}
}

mutating func mutablePointer() -> UnsafeMutablePointer<UInt8>! {
return withUnsafeMutableBytes { $0 }
return withUnsafeMutableBytes { (bytes: UnsafeMutableRawBufferPointer) -> UnsafeMutablePointer<UInt8>? in
bytes.baseAddress?.assumingMemoryBound(to: UInt8.self)
}
}

func sha256() -> Data {
Expand Down
2 changes: 1 addition & 1 deletion Tests/XyoClientTests/Address.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class AddressTests: XCTestCase {

func testKnownPrivateKey() {
let address = XyoAddress(privateKey: testVectorPrivateKey)
let signature = try? address.sign(testVectorHash)
//let signature = try? address.sign(testVectorHash)
XCTAssertNotNil(address)
XCTAssertEqual(address.privateKeyHex, testVectorPrivateKey)
XCTAssertEqual(address.publicKeyHex, testVectorPublicKey)
Expand Down

0 comments on commit 3bb2bbc

Please sign in to comment.