-
Notifications
You must be signed in to change notification settings - Fork 167
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
Make Curve25519 PublicKey
s conform to Hashable
#175
base: main
Are you sure you want to change the base?
Conversation
return try self.baseKey.keyBytes.withUnsafeBytes(body) | ||
} | ||
|
||
public static func ==(lhs: Self, rhs: Self) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -54,6 +54,14 @@ extension Curve25519 { | |||
private func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R { | |||
return try self.baseKey.keyBytes.withUnsafeBytes(body) | |||
} | |||
|
|||
public static func ==(lhs: Self, rhs: Self) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -75,4 +75,54 @@ class EdDSATests: XCTestCase { | |||
// This signature should be invalid | |||
XCTAssertFalse(privateKey.publicKey.isValidSignature(DispatchData.empty, for: DispatchData.empty)) | |||
} | |||
|
|||
func testCurve25519SigningPublicKeyEquatable() throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curve25519.Signing.PrivateKey().publicKey | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delaying for future release of CryptoKit.
Make Curve25519 PublicKeys conform to
Hashable
N.B. Merge open PR #173 first (or if #173 is closed, close this one too), since this PR builds on top of that.
Checklist
If you've made changes to
gyb
files.script/generate_boilerplate_files_with_gyb
and included updated generated files in a commit of this pull requestMotivation:
PublicKey's are fundamental building blocks within EC-oriented code bases. They can act as a natural key in Dictionaries and otherwise important property of larger structs, which us developers often would like to make
Hashable
. Today, Curve25519 public keys prevent auto-synthesis ofHashable
for any structs they are members of, thus Curve25519 keys ought to beHashable
!This poses no security risk nor any performance downgrade.
This PR is an addition of open PR #173.
Modifications:
Curve25519.KeyAgreement.PublicKey
andCurve25519.Signing.PublicKey
have been madeHashable
and unit tests have been added.Result:
Curve25519.KeyAgreement.PublicKey
andCurve25519.Signing.PublicKey
are nowHashable