{"id":20459592,"url":"https://github.com/ticesoftware/x3dh","last_synced_at":"2025-04-13T05:51:42.966Z","repository":{"id":56927676,"uuid":"185930112","full_name":"TICESoftware/X3DH","owner":"TICESoftware","description":"X3DH key agreement protocol in Swift based on libsodium","archived":false,"fork":false,"pushed_at":"2021-06-01T13:46:32.000Z","size":27,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T05:51:42.124Z","etag":null,"topics":["tice-app","tice-crypto"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TICESoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-10T06:19:49.000Z","updated_at":"2024-02-11T18:02:29.000Z","dependencies_parsed_at":"2022-08-21T04:20:56.513Z","dependency_job_id":null,"html_url":"https://github.com/TICESoftware/X3DH","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TICESoftware%2FX3DH","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TICESoftware%2FX3DH/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TICESoftware%2FX3DH/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TICESoftware%2FX3DH/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TICESoftware","download_url":"https://codeload.github.com/TICESoftware/X3DH/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670504,"owners_count":21142901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tice-app","tice-crypto"],"created_at":"2024-11-15T12:16:44.372Z","updated_at":"2025-04-13T05:51:42.943Z","avatar_url":"https://github.com/TICESoftware.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# X3DH\n\nThis package implements the \u003ca href=\"https://signal.org/docs/specifications/x3dh/\"\u003eX3DH\u003c/a\u003e key agreement protocol in Swift. The cryptographic operations are provided by \u003ca href=\"https://github.com/jedisct1/libsodium\"\u003elibsodium\u003c/a\u003e entirely.\n\n## Installation\n### SPM\n`.package(url: \"https://github.com/TICESoftware/X3DH.git\", .upToNextMajor(from: \"2.0.0\"))`\n\nIn order to build the library it is necessary to link libsodium. The \u003ca href=\"https://github.com/jedisct1/libsodium\"\u003eofficial repository\u003c/a\u003e includes scripts to build binaries for specific platforms.\n\n`swift build -Xcc -I[header search path] -Xlinker -L[binary path]`\n\nWhen using Xcode you can set the header search path manually to include the libsodium header files and link the static libsodium library.\n\n### CodoaPods\n`pod 'X3DH'`\n\nThis uses \u003ca href=\"https://github.com/jedisct1/swift-sodium\"\u003e`Sodium`\u003c/a\u003e as a dependency which includes the pre-compiled libsodium library. No further setup necessary.\n\n## Usage\n\nAlice needs to retrieve some public keys from Bob that he has made public previously. She then calculates a shared secret and sends some information to Bob so that he can calculcate the shared secret on his side as well.\n\n```swift\nlet preKeySigner = // ... Signing the key is not part of this library\nlet prekeySignatureVerifier = // ... and neither is verification\n\nlet bob = X3DH()\nlet bobIdentityKeyPair = try bob.generateIdentityKeyPair()\nlet bobSignedPrekey = try bob.generateSignedPrekeyPair(signer: { ... })\nlet bobOneTimePrekey = try bob.generateOneTimePrekeyPairs(count: 2)\n\nlet alice = X3DH()\nlet aliceIdentityKeyPair = try alice.generateIdentityKeyPair()\nlet aliceSignedPrekey = try alice.generateSignedPrekeyPair(signer: { ... })\n// [Alice fetches bob's prekey bundle]\nlet keyAgreementInitiation = try alice.initiateKeyAgreement(remoteIdentityKey: bobIdentityKeyPair.publicKey, remotePrekey: bobSignedPrekey.keyPair.publicKey, prekeySignature: bobSignedPrekey.signature, remoteOneTimePrekey: bobOneTimePrekey.first!.publicKey, identityKeyPair: aliceIdentityKeyPair, prekey: aliceSignedPrekey.keyPair.publicKey, prekeySignatureVerifier: { ... }, info: \"Example\")\n\n// [Alice sends identity key, ephemeral key and used one-time prekey to bob]\nlet sharedSecret = try bob.sharedSecretFromKeyAgreement(remoteIdentityKey: aliceIdentityKeyPair.publicKey, remoteEphemeralKey: keyAgreementInitiation.ephemeralPublicKey, usedOneTimePrekeyPair: bobOneTimePrekey.first!, identityKeyPair: bobIdentityKeyPair, prekeyPair: bobSignedPrekey.keyPair, info: \"Example\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fticesoftware%2Fx3dh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fticesoftware%2Fx3dh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fticesoftware%2Fx3dh/lists"}