{"id":18835221,"url":"https://github.com/tesseract-one/sr25519.swift","last_synced_at":"2025-04-14T04:33:06.657Z","repository":{"id":48698055,"uuid":"351487345","full_name":"tesseract-one/Sr25519.swift","owner":"tesseract-one","description":"Swift wrapper for sr25519-donna C library","archived":false,"fork":false,"pushed_at":"2023-08-29T15:58:33.000Z","size":1174,"stargazers_count":2,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T00:46:04.602Z","etag":null,"topics":["cocoapods","linux","swift","swift-wrapper"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tesseract-one.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-25T15:34:30.000Z","updated_at":"2023-08-29T15:09:21.000Z","dependencies_parsed_at":"2024-11-08T02:25:15.436Z","dependency_job_id":null,"html_url":"https://github.com/tesseract-one/Sr25519.swift","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tesseract-one%2FSr25519.swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tesseract-one%2FSr25519.swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tesseract-one%2FSr25519.swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tesseract-one%2FSr25519.swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tesseract-one","download_url":"https://codeload.github.com/tesseract-one/Sr25519.swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248822328,"owners_count":21167040,"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":["cocoapods","linux","swift","swift-wrapper"],"created_at":"2024-11-08T02:15:04.241Z","updated_at":"2025-04-14T04:33:01.642Z","avatar_url":"https://github.com/tesseract-one.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sr25519.swift\n\n![🐧 linux: ready](https://img.shields.io/badge/%F0%9F%90%A7%20linux-ready-red.svg)\n[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-lightgrey.svg)](LICENSE)\n[![Build Status](https://github.com/tesseract-one/sr25519.swift/workflows/Build%20\u0026%20Tests/badge.svg?branch=main)](https://github.com/tesseract-one/sr25519.swift/actions/workflows/build.yml?query=branch%3Amain)\n[![GitHub release](https://img.shields.io/github/release/tesseract-one/sr25519.swift.svg)](https://github.com/tesseract-one/sr25519.swift/releases)\n[![SPM compatible](https://img.shields.io/badge/SwiftPM-Compatible-brightgreen.svg)](https://swift.org/package-manager/)\n[![CocoaPods version](https://img.shields.io/cocoapods/v/Sr25519.svg)](https://cocoapods.org/pods/Sr25519)\n![Platform macOS | iOS | tvOS | watchOS | Linux](https://img.shields.io/badge/platform-Linux%20%7C%20macOS%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS-orange.svg)\n\nSwift wrapper for [shnorrkel](https://github.com/w3f/schnorrkel) [C library](https://github.com/TerenceGe/sr25519-donna).\n\n## Installation\n\nSr25519.swift deploys to macOS, iOS, tvOS, watchOS and Linux. It has been tested on the latest OS releases only however, as the module uses very few platform-provided APIs, there should be very few issues with earlier versions.\n\nSetup instructions:\n\n- **Swift Package Manager:**\n  Add this to the dependency section of your `Package.swift` manifest:\n\n    ```Swift\n    .package(url: \"https://github.com/tesseract-one/Sr25519.swift.git\", from: \"0.2.0\")\n    ```\n\n- **CocoaPods:** Put this in your `Podfile`:\n\n    ```Ruby\n    pod 'Sr25519', '~\u003e 0.2'\n    ```\n  \n- **CocoaPods with Ed25519:**\n  \n  If you want to build Ed25519 part from sources add this in your `Podfile`:\n    ```Ruby\n    pod 'Sr25519/Sr25519', '~\u003e 0.2'\n    pod 'Sr25519/Ed25519', '~\u003e 0.2'\n    ```\n\n## Usage Examples\n\nFollowing are some examples to demonstrate usage of the library.\n\n### Sign and Validate with key pair\n\n```Swift\nimport Sr25519\n\n// Creating new KeyPair from random seed\nlet keypair = Sr25519KeyPair(seed: Sr25519Seed())\n// Our message Data\nlet message = \"Hello, World!\".data(using: .utf8)!\n\n// Signing\nlet signature = keypair.sign(message: message)\nprint(\"Signature:\" signature)\n\n// Validating signature\nlet valid = keypair.validate(message: message, signature: signature)\nprint(\"Is valid:\", valid)\n```\n\n#### Validate with public key\n\n```Swift\nimport Sr25519\n\n// Creating PublicKey from Data\nlet pkey = try! Sr25519PublicKey(data: Data(repeating: 0, count: Sr25519PublicKey.size))\n// Our message Data\nlet message = \"Hello, World!\".data(using: .utf8)!\n// Signature\nlet signature = try! Sr25519Signature(data: Data(repeating: 0, count: Sr25519Signature.size))\n\n// Validating\nlet valid = pkey.verify(message: message, signature: signature)\nprint(\"Is valid:\", valid)\n```\n\n#### Key derivation\n\n```Swift\nimport Sr25519\n\n// Creating new KeyPair from random seed\nlet keypair = Sr25519KeyPair(seed: Sr25519Seed())\n// It's PublicKey\nlet pkey = keypair.publicKey\n\n// Creating ChainCode for derivation from Data\nlet chaincode = try! Sr25519ChainCode(code: Data(repeating: 0, count: Sr25519ChainCode.size))\n\n// Derive\nlet derived = keypair.derive(chainCode: chaincode, hard: true)\nprint(\"Hard derived PublicKey\", derived.publicKey)\n\n// Also soft derivation can be performed on PrivateKey directly\nlet pderived = pkey.derive(chainCode: chaincode)\nprint(\"Soft derived PublicKey\", pderived)\n```\n\n#### Verifiable random function\n\n```Swift\nimport Sr25519\n\n// Creating new KeyPair from random seed\nlet keypair = Sr25519KeyPair(seed: Sr25519Seed())\n// Our message Data\nlet message = \"Hello, World!\".data(using: .utf8)!\n\n// Default 0xFF filled threshold\nlet limit = Sr25519VrfThreshold()\n\n// Signing\nlet (signature, isLess) = try! keypair.vrfSign(message: message, ifLessThan: limit)\nprint(\"Signature:\", signature, \"is less:\", isLess)\n\n// Verification\nlet valid = keypair.vrfVerify(message: message, signature: signature, threshold: limit)\nprint(\"Is valid:\", valid)\n```\n\n## License\n\nSr25519.swift can be used, distributed and modified under [the Apache 2.0 license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftesseract-one%2Fsr25519.swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftesseract-one%2Fsr25519.swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftesseract-one%2Fsr25519.swift/lists"}