-
Notifications
You must be signed in to change notification settings - Fork 26
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
Signature not always the same #399
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -492,4 +492,41 @@ class ClientTests: XCTestCase { | |
let newState = try await alixClient3.inboxState(refreshFromNetwork: true) | ||
XCTAssertEqual(newState.installationIds.count, 1) | ||
} | ||
|
||
func testSignMessage() async throws { | ||
let key = try Crypto.secureRandomBytes(count: 32) | ||
let alix = try PrivateKey.generate() | ||
let options = ClientOptions.init( | ||
api: .init(env: .local, isSecure: false), | ||
enableV3: true, | ||
encryptionKey: key | ||
) | ||
|
||
let alixClient = try await Client.create( | ||
account: alix, | ||
options: options | ||
) | ||
let privateKey = try PrivateKey(alixClient.keys.identityKey) | ||
|
||
let stringToSign1 = "TEST_STRING_TO_SIGN" | ||
|
||
let signature1_1 = try await privateKey.sign(stringToSign1.data(using: .utf8)!) | ||
let uint1_1 = try [UInt8](signature1_1.serializedData()) | ||
|
||
let signature1_2 = try await privateKey.sign(stringToSign1.data(using: .utf8)!) | ||
let uint1_2 = try [UInt8](signature1_2.serializedData()) | ||
|
||
XCTAssertEqual(uint1_1, uint1_2) | ||
|
||
let stringToSign2 = "short" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at first I thought it was because the string was short but I managed to make it fail with longer strings also… maybe a byte length thing? |
||
|
||
let signature2_1 = try await privateKey.sign(stringToSign2.data(using: .utf8)!) | ||
let uint2_1 = try [UInt8](signature2_1.serializedData()) | ||
|
||
let signature2_2 = try await privateKey.sign(stringToSign2.data(using: .utf8)!) | ||
let uint2_2 = try [UInt8](signature2_2.serializedData()) | ||
|
||
XCTAssertEqual(uint2_1, uint2_2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one fails There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems strange. Will add it to the backlog for investigation. |
||
} | ||
|
||
} |
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.
this one passes