Skip to content

Commit 0548cff

Browse files
authored
UInt256 type for Swift (#561)
Initial UInt256 type for Swift
1 parent 0ab0329 commit 0548cff

File tree

9 files changed

+1853
-3
lines changed

9 files changed

+1853
-3
lines changed

.github/workflows/xcframework-release.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ jobs:
9696
-e 's/[[:<:]]P256K\.HashDigest[[:>:]]/HashDigest/g' \
9797
-e 's/[[:<:]]P256K\.SharedSecret[[:>:]]/SharedSecret/g' \
9898
-e 's/[[:<:]]P256K\.PublicKeyImplementation[[:>:]]/PublicKeyImplementation/g' \
99-
-e 's/[[:<:]]P256K\.PrivateKeyImplementation[[:>:]]/PrivateKeyImplementation/g'
99+
-e 's/[[:<:]]P256K\.PrivateKeyImplementation[[:>:]]/PrivateKeyImplementation/g' \
100+
-e 's/[[:<:]]P256K\.UInt256[[:>:]]/UInt256/g' \
101+
-e 's/[[:<:]]P256K\.Int256[[:>:]]/Int256/g' \
102+
-e 's/[[:<:]]P256K\.UInt128[[:>:]]/UInt128/g' \
103+
-e 's/[[:<:]]P256K\.Int128[[:>:]]/Int128/g' \
104+
-e 's/[[:<:]]P256K\.SIMDWordsInteger[[:>:]]/SIMDWordsInteger/g' \
105+
-e 's/[[:<:]]P256K\.SIMDWrapper[[:>:]]/SIMDWrapper/g' \
106+
-e 's/[[:<:]]P256K\.Vector[[:>:]]/Vector/g'
100107
- name: 7z XCFramework
101108
run: |
102109
# Copy COPYING file to current directory to avoid including folder structure
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Sources/ZKP/UInt256.swift

Sources/P256K/UInt256.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ZKP/UInt256.swift

Sources/ZKP/Asymmetric.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ public extension P256K {
108108
}
109109
}
110110

111+
/// Creates a secp256k1 private key for signing from a data representation.
112+
///
113+
/// - Parameter data: A raw representation of the key.
114+
/// - Parameter format: The key format, default is .compressed.
115+
/// - Throws: An error if the raw representation does not create a private key for signing.
116+
@available(macOS 13.3, *) public init(_ staticInt: UInt256, format: P256K.Format = .compressed) throws {
117+
self.baseKey = try PrivateKeyImplementation(dataRepresentation: staticInt.rawValue, format: format)
118+
}
119+
111120
/// Determines if two private keys are equal.
112121
///
113122
/// - Parameters:

0 commit comments

Comments
 (0)