From 9dca818020962f1f76f1d98e71e3d80c7d527bd6 Mon Sep 17 00:00:00 2001 From: Michael Bisgaard Olesen Date: Thu, 25 Jan 2024 15:16:48 +0100 Subject: [PATCH] Integrate Rust bindings as library (#11) Add Rust binding library `ConcordiumWalletCrypto` which implements the functions currently exposed in the `ConcordiumHdWallet` in the JavaScript SDK. The functions are made available from the SDK via `ConcordiumHdWallet` as well. The unit tests have been ported from the other SDK also. The bindings are generated by [UniFFI](https://mozilla.github.io/uniffi-rs/Overview.html) via [`cargo-swift`](https://github.com/antoniusnaumann/cargo-swift/). That tool was mainly helpful for setting up the structure of the project, it probably isn't really required for actually building the lib. As it's ability to compile seems a little flaky and because we might want to build fewer variants for the purpose of CI, it seems reasonable that we'd replace this dependency with a simple script that does the same thing. Resolves https://concordium.atlassian.net/browse/CBW-1552. References: - JS SDK: https://github.com/Concordium/concordium-node-sdk-js/blob/main/packages/sdk/src/wasm/HdWallet.ts - Unit tests ported: https://github.com/Concordium/concordium-node-sdk-js/blob/main/packages/sdk/test/ci/HdWallet.test.ts#L186 --- .github/workflows/build+test.yml | 13 +- .gitmodules | 3 + .../ExampleWallet.xcodeproj/project.pbxproj | 10 +- .../ExampleWallet/Views/MainView.swift | 10 +- Makefile | 4 + Package.swift | 2 + README.md | 54 +- .../ConcordiumHdWallet.swift | 114 + .../ConcordiumNodeClient.swift | 1 + .../ConcordiumHdWalletTest.swift | 187 ++ lib/crypto/.gitignore | 3 + lib/crypto/Cargo.lock | 2106 +++++++++++++++++ lib/crypto/Cargo.toml | 16 + lib/crypto/build.rs | 3 + lib/crypto/build.sh | 6 + lib/crypto/concordium-base | 1 + lib/crypto/src/lib.rs | 155 ++ lib/crypto/src/lib.udl | 27 + 18 files changed, 2697 insertions(+), 18 deletions(-) create mode 100644 Sources/ConcordiumSwiftSdk/ConcordiumHdWallet.swift create mode 100644 Tests/ConcordiumSwiftSdkTests/ConcordiumHdWalletTest.swift create mode 100644 lib/crypto/.gitignore create mode 100644 lib/crypto/Cargo.lock create mode 100644 lib/crypto/Cargo.toml create mode 100644 lib/crypto/build.rs create mode 100755 lib/crypto/build.sh create mode 160000 lib/crypto/concordium-base create mode 100644 lib/crypto/src/lib.rs create mode 100644 lib/crypto/src/lib.udl diff --git a/.github/workflows/build+test.yml b/.github/workflows/build+test.yml index 85cb96d..89c0e47 100644 --- a/.github/workflows/build+test.yml +++ b/.github/workflows/build+test.yml @@ -6,6 +6,7 @@ on: pull_request: env: + rust_version: "1.72" swift_version: "5.9" jobs: @@ -16,9 +17,19 @@ jobs: - name: Setup Swift uses: swift-actions/setup-swift@v1 with: - swift-version: "${{ env.swift_version }}" + swift-version: "${{env.swift_version}}" + - name: Setup Rust + run: | + rustup default "${{env.rust_version}}" + rustup target install aarch64-apple-darwin x86_64-apple-darwin + cargo install cargo-swift - name: Check out sources uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build rust bindings (macOS only) + run: cargo swift package --name=ConcordiumWalletCrypto --platforms=macos --release + working-directory: ./lib/crypto - name: Check formatting run: swift package plugin --allow-writing-to-package-directory swiftformat --lint - name: Build project diff --git a/.gitmodules b/.gitmodules index 8aebd1f..5f7e101 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "concordium-grpc-api"] path = concordium-grpc-api url = https://github.com/Concordium/concordium-grpc-api.git +[submodule "lib/crypto/concordium-base"] + path = lib/crypto/concordium-base + url = https://github.com/Concordium/concordium-base.git diff --git a/ExampleWallet/ExampleWallet.xcodeproj/project.pbxproj b/ExampleWallet/ExampleWallet.xcodeproj/project.pbxproj index b8d1972..7a4064f 100644 --- a/ExampleWallet/ExampleWallet.xcodeproj/project.pbxproj +++ b/ExampleWallet/ExampleWallet.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ A10E85322B56A6110063B079 /* SeedPhraseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10E85312B56A6110063B079 /* SeedPhraseView.swift */; }; A16C9F8F2B5D2CAF0009AD77 /* SeedPhraseValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = A16C9F8E2B5D2CAF0009AD77 /* SeedPhraseValidator.swift */; }; A16C9FBC2B5D370C0009AD77 /* SeedPhraseValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A16C9FBB2B5D370C0009AD77 /* SeedPhraseValidatorTests.swift */; }; - CD0E4E142B6116CA00E62FF1 /* ConcordiumSwiftSdk in Frameworks */ = {isa = PBXBuildFile; productRef = CD0E4E132B6116CA00E62FF1 /* ConcordiumSwiftSdk */; }; A17E071D2B57E8DE00F7BFFC /* IssueIdentityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17E071C2B57E8DE00F7BFFC /* IssueIdentityView.swift */; }; A17E07202B57EE8E00F7BFFC /* BlueButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17E071F2B57EE8E00F7BFFC /* BlueButton.swift */; }; A17E07222B57F12400F7BFFC /* BlueTextStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17E07212B57F12400F7BFFC /* BlueTextStyle.swift */; }; @@ -20,6 +19,7 @@ A1CD79D82B556FD200F1CAA5 /* ExampleWalletApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1CD79D72B556FD200F1CAA5 /* ExampleWalletApp.swift */; }; A1CD79DC2B556FD300F1CAA5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A1CD79DB2B556FD300F1CAA5 /* Assets.xcassets */; }; A1CD79DF2B556FD300F1CAA5 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A1CD79DE2B556FD300F1CAA5 /* Preview Assets.xcassets */; }; + CD0E4E142B6116CA00E62FF1 /* ConcordiumSwiftSdk in Frameworks */ = {isa = PBXBuildFile; productRef = CD0E4E132B6116CA00E62FF1 /* ConcordiumSwiftSdk */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -541,15 +541,15 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - CD0E4E132B6116CA00E62FF1 /* ConcordiumSwiftSdk */ = { - isa = XCSwiftPackageProductDependency; - productName = ConcordiumSwiftSdk; - }; A1A6B3A02B5A893100EC1313 /* MnemonicSwift */ = { isa = XCSwiftPackageProductDependency; package = A1A6B39F2B5A893100EC1313 /* XCRemoteSwiftPackageReference "MnemonicSwift" */; productName = MnemonicSwift; }; + CD0E4E132B6116CA00E62FF1 /* ConcordiumSwiftSdk */ = { + isa = XCSwiftPackageProductDependency; + productName = ConcordiumSwiftSdk; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = A1CD79CC2B556FD200F1CAA5 /* Project object */; diff --git a/ExampleWallet/ExampleWallet/Views/MainView.swift b/ExampleWallet/ExampleWallet/Views/MainView.swift index 7b5cf8c..5f4ab8a 100644 --- a/ExampleWallet/ExampleWallet/Views/MainView.swift +++ b/ExampleWallet/ExampleWallet/Views/MainView.swift @@ -5,18 +5,18 @@ struct MainView: View { NavigationView { VStack { getNavigationLinkTo(destination: SeedPhraseView(), withLabel: "Seed phrase view") - + BlueButton("Identity recovery view") {} - + BlueButton("Identity view") {} - + BlueButton("Account view") {} - + Spacer() } } } - + private func getNavigationLinkTo(destination: Destination, withLabel label: String) -> some View { NavigationLink(destination: destination) { Text(label).modifier(BlueTextStyle()) diff --git a/Makefile b/Makefile index e55a1e8..01a6275 100644 --- a/Makefile +++ b/Makefile @@ -5,3 +5,7 @@ fmt: .PHONY: generate-grpc generate-grpc: protoc --proto_path=./concordium-grpc-api --grpc-swift_opt='Client=true,Server=false' --grpc-swift_out=./Sources/ConcordiumSwiftSdk/Generated/Grpc --swift_out=./Sources/ConcordiumSwiftSdk/Generated/Grpc ./concordium-grpc-api/v2/concordium/*.proto + +.PHONY: build-crypto +build-crypto: + cd ./lib/crypto && ./build.sh diff --git a/Package.swift b/Package.swift index accf990..be754ea 100644 --- a/Package.swift +++ b/Package.swift @@ -19,12 +19,14 @@ let package = Package( .package(url: "https://github.com/anquii/Base58Check.git", from: "1.0.0"), .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.15.0"), .package(url: "https://github.com/nicklockwood/SwiftFormat.git", exact: "0.53.0"), + .package(path: "./lib/crypto/ConcordiumWalletCrypto"), ], targets: [ .target( name: "ConcordiumSwiftSdk", dependencies: [ "Base58Check", + "ConcordiumWalletCrypto", .product(name: "GRPC", package: "grpc-swift"), "SwiftFormat", ] diff --git a/README.md b/README.md index 657ee58..a9d86b9 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,14 @@ **STATUS: EARLY DEVELOPMENT** An SDK for applications written in the [Swift Programming Language](https://www.swift.org/) to -interact with the Concordium Blockchain. +interact with the [Concordium Blockchain](https://concordium.com). The main purpose of the SDK is to facilitate development of mobile wallet apps for iOS devices. +Once the project is ready for production, it will replace the existing +[`ConcordiumWalletCrypto`](https://github.com/Concordium/concordium-wallet-crypto-swift) library +which is currently used in the [iOS reference wallet](https://github.com/Concordium/concordium-reference-wallet-ios/). + ### Supported platforms - iOS 15+ @@ -14,25 +18,59 @@ The main purpose of the SDK is to facilitate development of mobile wallet apps f ## Usage -*No tags have been added to "publish" a build yet. The following is unverified and is only going to work once v1.0 has been published.* +*No tags have been added to "publish" a build yet. The following is only going to work once v1.0 has been published. +To use it in the current, unfinished state, replace `"1.0"` with `"main"`.* -The SDK is available as a SwiftPM package hosted on GitHub as this repository. +The SDK is available as a [SwiftPM package](https://developer.apple.com/documentation/xcode/swift-packages) +hosted on GitHub as this repository. To include it as a dependency, add the following ```swift -.package(url: "https://github.com/Concordium/concordium-swift-sdk.git", from: "1.0"), +.package(url: "https://github.com/Concordium/concordium-swift-sdk.git", from: "1.0") ``` and adding ```swift -.product(name: "ConcordiumSwiftSDK", package: "concordium-swift-sdk"), +.product(name: "ConcordiumSwiftSDK", package: "concordium-swift-sdk") ``` to the `dependencies` list of the appropriate `target`. ## Development +### Build Rust bindings + +Concordium specific cryptographic functions are implemented in Rust and shared between all kinds of Concordium products. +This SDK includes a thin wrapper for providing bindings to the Rust library +[`wallet_library`](https://github.com/Concordium/concordium-base/tree/main/rust-src/wallet_library) +which exposes functions specifically relevant for wallets. + +These bindings are located in `./lib/crypto` and built using [`cargo-swift`](https://github.com/antoniusnaumann/cargo-swift/) +into a [XCFramework](https://developer.apple.com/documentation/xcode/distributing-binary-frameworks-as-swift-packages). +The SDK pulls in this framework from a local path, so the bindings have to built manually before the SDK can be used. + +Building is only a matter of installing `cargo-swift` and invoking a Make target: + +```shell +cargo install cargo-swift +make build-crypto +``` + +This will place the target framework at `./lib/crypto/ConcordiumWalletCrypto`. + +### Build and test SDK + +With the Rust bindings in place, the SDK is built and tests executed using `swift test`. +It's not necessary to build the project in order to use it in other projects: +Just declare a dependency as explained in [usage](#usage). +The SDK will get compiled as part of the build process of the executable. + +TODO: This means that we'll either have to add steps in `Package.swift` for automatically building the binaries (if possible) +or push them to some specific location +(like we did with [`concordium-wallet-crypto-swift`](https://github.com/Concordium/concordium-wallet-crypto-swift)). +This could be a GitHub release/package or S3. + ### Source code formatting The source code is formatted according to the default rules of [`SwiftFormat`](https://github.com/nicklockwood/SwiftFormat). @@ -40,7 +78,8 @@ The source code is formatted according to the default rules of [`SwiftFormat`](h The CI workflow [`Build and test`](https://github.com/Concordium/concordium-swift-sdk/blob/main/.github/workflows/build%2Btest.yml) checks that the code base is correctly formated before PRs are merged. -The formatter has been integrated as a [Swift Package Manger plugin](https://github.com/nicklockwood/SwiftFormat#swift-package-manager-plugin). +The formatter has been integrated as a +[Swift Package Manger plugin](https://github.com/nicklockwood/SwiftFormat#swift-package-manager-plugin). It's possible to run the tool in a variety of ways (see the previous link for all options). The easiest option is to run it on the command line via @@ -48,5 +87,6 @@ The easiest option is to run it on the command line via make fmt ``` -It may also be [invoked directly from XCode](https://github.com/nicklockwood/SwiftFormat#trigger-plugin-from-xcode) by right-clicking on package root (i.e. `concordium-swift-sdk`) in the Project Navigator pane. +It may also be [invoked directly from XCode](https://github.com/nicklockwood/SwiftFormat#trigger-plugin-from-xcode) +by right-clicking on package root (i.e. `concordium-swift-sdk`) in the Project Navigator pane. The tool is then listed under "SwiftFormat" as "SwiftFormatPlugin" in the context menu for formatting the entire project. diff --git a/Sources/ConcordiumSwiftSdk/ConcordiumHdWallet.swift b/Sources/ConcordiumSwiftSdk/ConcordiumHdWallet.swift new file mode 100644 index 0000000..7fd9f54 --- /dev/null +++ b/Sources/ConcordiumSwiftSdk/ConcordiumHdWallet.swift @@ -0,0 +1,114 @@ +import Foundation + +import ConcordiumWalletCrypto + +enum ConcordiumNetwork: String { + case mainnet = "Mainnet" + case testnet = "Testnet" +} + +class ConcordiumHdWallet { + let seedHex: String + let network: ConcordiumNetwork + + init(seedHex: String, network: ConcordiumNetwork) { + self.seedHex = seedHex + self.network = network + } + + func getAccountSigningKey(identityProviderIndex: UInt32, identityIndex: UInt32, credentialCounter: UInt32) throws -> String { + try ConcordiumWalletCrypto.getAccountSigningKey( + seedHex: seedHex, + network: network.rawValue, + identityProviderIndex: identityProviderIndex, + identityIndex: identityIndex, + credentialCounter: credentialCounter + ) + } + + func getAccountPublicKey(identityProviderIndex: UInt32, identityIndex: UInt32, credentialCounter: UInt32) throws -> String { + try ConcordiumWalletCrypto.getAccountPublicKey( + seedHex: seedHex, + network: network.rawValue, + identityProviderIndex: identityProviderIndex, + identityIndex: identityIndex, + credentialCounter: credentialCounter + ) + } + + func getCredentialId(identityProviderIndex: UInt32, identityIndex: UInt32, credentialCounter: UInt8, commitmentKey: String) throws -> String { + try ConcordiumWalletCrypto.getCredentialId( + seedHex: seedHex, + network: network.rawValue, + identityProviderIndex: identityProviderIndex, + identityIndex: identityIndex, + credentialCounter: credentialCounter, + commitmentKey: commitmentKey + ) + } + + func getPrfKey(identityProviderIndex: UInt32, identityIndex: UInt32) throws -> String { + try ConcordiumWalletCrypto.getPrfKey( + seedHex: seedHex, + network: network.rawValue, + identityProviderIndex: identityProviderIndex, + identityIndex: identityIndex + ) + } + + func getIdCredSec(identityProviderIndex: UInt32, identityIndex: UInt32) throws -> String { + try ConcordiumWalletCrypto.getIdCredSec( + seedHex: seedHex, + network: network.rawValue, + identityProviderIndex: identityProviderIndex, + identityIndex: identityIndex + ) + } + + func getSignatureBlindingRandomness(identityProviderIndex: UInt32, identityIndex: UInt32) throws -> String { + try ConcordiumWalletCrypto.getSignatureBlindingRandomness( + seedHex: seedHex, + network: network.rawValue, + identityProviderIndex: identityProviderIndex, + identityIndex: identityIndex + ) + } + + func getAttributeCommitmentRandomness(identityProviderIndex: UInt32, identityIndex: UInt32, credentialCounter: UInt32, attribute: UInt8) throws -> String { + try ConcordiumWalletCrypto.getAttributeCommitmentRandomness( + seedHex: seedHex, + network: network.rawValue, + identityProviderIndex: identityProviderIndex, + identityIndex: identityIndex, + credentialCounter: credentialCounter, + attribute: attribute + ) + } + + func getVerifiableCredentialSigningKey(issuerIndex: UInt64, issuerSubindex: UInt64, verifiableCredentialIndex: UInt32) throws -> String { + try ConcordiumWalletCrypto.getVerifiableCredentialSigningKey( + seedHex: seedHex, + network: network.rawValue, + issuerIndex: issuerIndex, + issuerSubindex: issuerSubindex, + verifiableCredentialIndex: verifiableCredentialIndex + ) + } + + func getVerifiableCredentialPublicKey(issuerIndex: UInt64, issuerSubindex: UInt64, verifiableCredentialIndex: UInt32) throws -> String { + try ConcordiumWalletCrypto.getVerifiableCredentialPublicKey( + seedHex: seedHex, + network: network.rawValue, + issuerIndex: issuerIndex, + issuerSubindex: issuerSubindex, + verifiableCredentialIndex: verifiableCredentialIndex + ) + } + + func getVerifiableCredentialBackupEncryptionKey() throws -> String { + try ConcordiumWalletCrypto.getVerifiableCredentialBackupEncryptionKey( + seedHex: seedHex, + network: network.rawValue + ) + } +} diff --git a/Sources/ConcordiumSwiftSdk/ConcordiumNodeClient.swift b/Sources/ConcordiumSwiftSdk/ConcordiumNodeClient.swift index 27fda70..79df501 100644 --- a/Sources/ConcordiumSwiftSdk/ConcordiumNodeClient.swift +++ b/Sources/ConcordiumSwiftSdk/ConcordiumNodeClient.swift @@ -1,3 +1,4 @@ +import ConcordiumWalletCrypto import Foundation import GRPC import NIOCore diff --git a/Tests/ConcordiumSwiftSdkTests/ConcordiumHdWalletTest.swift b/Tests/ConcordiumSwiftSdkTests/ConcordiumHdWalletTest.swift new file mode 100644 index 0000000..7b3c05a --- /dev/null +++ b/Tests/ConcordiumSwiftSdkTests/ConcordiumHdWalletTest.swift @@ -0,0 +1,187 @@ +@testable import ConcordiumSwiftSdk +import CryptoKit +import XCTest + +final class ConcordiumHdWalletTest: XCTestCase { + let TEST_SEED_1 = "efa5e27326f8fa0902e647b52449bf335b7b605adc387015ec903f41d95080eb71361cbc7fb78721dcd4f3926a337340aa1406df83332c44c1cdcfe100603860" + + func testMainnetSigningKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getAccountSigningKey(identityProviderIndex: 0, identityIndex: 55, credentialCounter: 7), + "e4d1693c86eb9438feb9cbc3d561fbd9299e3a8b3a676eb2483b135f8dbf6eb1" + ) + } + + func testMainnetPublicKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getAccountPublicKey(identityProviderIndex: 1, identityIndex: 341, credentialCounter: 9), + "d54aab7218fc683cbd4d822f7c2b4e7406c41ae08913012fab0fa992fa008e98" + ) + } + + func testMainnetPublicAndSigningKeyMetch() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + let privateKey = try wallet.getAccountSigningKey(identityProviderIndex: 0, identityIndex: 0, credentialCounter: 0) + let publicKey = try wallet.getAccountPublicKey(identityProviderIndex: 0, identityIndex: 0, credentialCounter: 0) + let message = "abcd1234abcd5678".data(using: .ascii)! + let signature = try Curve25519.Signing.PrivateKey( + rawRepresentation: Data(fromHexString: privateKey) + ).signature(for: message) + XCTAssertTrue( + try Curve25519.Signing.PublicKey(rawRepresentation: Data(fromHexString: publicKey)) + .isValidSignature(signature, for: message) + ) + } + + func testMainnetIdCredSec() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getIdCredSec(identityProviderIndex: 2, identityIndex: 115), + "33b9d19b2496f59ed853eb93b9d374482d2e03dd0a12e7807929d6ee54781bb1" + ) + } + + func testMainnetPrfKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getPrfKey(identityProviderIndex: 3, identityIndex: 35), + "4409e2e4acffeae641456b5f7406ecf3e1e8bd3472e2df67a9f1e8574f211bc5" + ) + } + + func testMainnetCredId() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getCredentialId(identityProviderIndex: 10, identityIndex: 50, credentialCounter: 5, commitmentKey: "b14cbfe44a02c6b1f78711176d5f437295367aa4f2a8c2551ee10d25a03adc69d61a332a058971919dad7312e1fc94c5a8d45e64b6f917c540eee16c970c3d4b7f3caf48a7746284878e2ace21c82ea44bf84609834625be1f309988ac523fac"), + "8a3a87f3f38a7a507d1e85dc02a92b8bcaa859f5cf56accb3c1bc7c40e1789b4933875a38dd4c0646ca3e940a02c42d8" + ) + } + + func testMainnetBlindingRandomness() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getSignatureBlindingRandomness(identityProviderIndex: 4, identityIndex: 5713), + "1e3633af2b1dbe5600becfea0324bae1f4fa29f90bdf419f6fba1ff520cb3167" + ) + } + + func testMainnetAttributeCommitmentRandomness() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getAttributeCommitmentRandomness(identityProviderIndex: 5, identityIndex: 0, credentialCounter: 4, attribute: 0), + "6ef6ba6490fa37cd517d2b89a12b77edf756f89df5e6f5597440630cd4580b8f" + ) + } + + func testTestnetSigningKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getAccountSigningKey(identityProviderIndex: 0, identityIndex: 55, credentialCounter: 7), + "aff97882c6df085e91ae2695a32d39dccb8f4b8d68d2f0db9637c3a95f845e3c" + ) + } + + func testTestnetPublicKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getAccountPublicKey(identityProviderIndex: 1, identityIndex: 341, credentialCounter: 9), + "ef6fd561ca0291a57cdfee896245db9803a86da74c9a6c1bf0252b18f8033003" + ) + } + + func testTestnetPublicAndSigningKeyMatch() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + let privateKey = try wallet.getAccountSigningKey(identityProviderIndex: 0, identityIndex: 0, credentialCounter: 0) + let publicKey = try wallet.getAccountPublicKey(identityProviderIndex: 0, identityIndex: 0, credentialCounter: 0) + let message = "abcd1234abcd5678".data(using: .ascii)! + let signature = try Curve25519.Signing.PrivateKey( + rawRepresentation: Data(fromHexString: privateKey) + ).signature(for: message) + XCTAssertTrue( + try Curve25519.Signing.PublicKey(rawRepresentation: Data(fromHexString: publicKey)) + .isValidSignature(signature, for: message) + ) + } + + func testTestnetIdCredSec() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getIdCredSec(identityProviderIndex: 2, identityIndex: 115), + "33c9c538e362c5ac836afc08210f4b5d881ba65a0a45b7e353586dad0a0f56df" + ) + } + + func testTestnetPrfKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getPrfKey(identityProviderIndex: 3, identityIndex: 35), + "41d794d0b06a7a31fb79bb76c44e6b87c63e78f9afe8a772fc64d20f3d9e8e82" + ) + } + + func testTestnetCredId() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getCredentialId(identityProviderIndex: 10, identityIndex: 50, credentialCounter: 5, commitmentKey: "b14cbfe44a02c6b1f78711176d5f437295367aa4f2a8c2551ee10d25a03adc69d61a332a058971919dad7312e1fc94c5a8d45e64b6f917c540eee16c970c3d4b7f3caf48a7746284878e2ace21c82ea44bf84609834625be1f309988ac523fac"), + "9535e4f2f964c955c1dd0f312f2edcbf4c7d036fe3052372a9ad949ff061b9b7ed6b00f93bc0713e381a93a43715206c" + ) + } + + func testTestnetBlindingRandomness() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getSignatureBlindingRandomness(identityProviderIndex: 4, identityIndex: 5713), + "079eb7fe4a2e89007f411ede031543bd7f687d50341a5596e015c9f2f4c1f39b" + ) + } + + func testTestnetAttributeCommitmentRandomness() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getAttributeCommitmentRandomness(identityProviderIndex: 5, identityIndex: 0, credentialCounter: 4, attribute: 0), + "409fa90314ec8fb4a2ae812fd77fe58bfac81765cad3990478ff7a73ba6d88ae" + ) + } + + func testTestnetCredIdMatchesCredDeployment() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getCredentialId(identityProviderIndex: 0, identityIndex: 0, credentialCounter: 1, commitmentKey: "b14cbfe44a02c6b1f78711176d5f437295367aa4f2a8c2551ee10d25a03adc69d61a332a058971919dad7312e1fc94c5a8d45e64b6f917c540eee16c970c3d4b7f3caf48a7746284878e2ace21c82ea44bf84609834625be1f309988ac523fac"), + "b317d3fea7de56f8c96f6e72820c5cd502cc0eef8454016ee548913255897c6b52156cc60df965d3efb3f160eff6ced4" + ) + } + + func testMainnetVerifiableCredentialSigningKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getVerifiableCredentialSigningKey(issuerIndex: 1, issuerSubindex: 2, verifiableCredentialIndex: 1), + "670d904509ce09372deb784e702d4951d4e24437ad3879188d71ae6db51f3301" + ) + } + + func testMainnetVerifiableCredentialPublicKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .mainnet) + XCTAssertEqual( + try wallet.getVerifiableCredentialPublicKey(issuerIndex: 3, issuerSubindex: 1232, verifiableCredentialIndex: 341), + "16afdb3cb3568b5ad8f9a0fa3c741b065642de8c53e58f7920bf449e63ff2bf9" + ) + } + + func testTestnetVerifiableCredentialSigningKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getVerifiableCredentialSigningKey(issuerIndex: 13, issuerSubindex: 0, verifiableCredentialIndex: 1), + "c75a161b97a1e204d9f31202308958e541e14f0b14903bd220df883bd06702bb" + ) + } + + func testTestnetVerifiableCredentialPublicKey() throws { + let wallet = ConcordiumHdWallet(seedHex: TEST_SEED_1, network: .testnet) + XCTAssertEqual( + try wallet.getVerifiableCredentialPublicKey(issuerIndex: 17, issuerSubindex: 0, verifiableCredentialIndex: 341), + "c52a30475bac88da9e65471cf9cf59f99dcce22ce31de580b3066597746b394a" + ) + } +} diff --git a/lib/crypto/.gitignore b/lib/crypto/.gitignore new file mode 100644 index 0000000..d4f0acb --- /dev/null +++ b/lib/crypto/.gitignore @@ -0,0 +1,3 @@ +/target +/generated +/ConcordiumWalletCrypto diff --git a/lib/crypto/Cargo.lock b/lib/crypto/Cargo.lock new file mode 100644 index 0000000..df59453 --- /dev/null +++ b/lib/crypto/Cargo.lock @@ -0,0 +1,2106 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" + +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "askama" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28" +dependencies = [ + "askama_derive", + "askama_escape", +] + +[[package]] +name = "askama_derive" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83" +dependencies = [ + "askama_parser", + "basic-toml", + "mime", + "mime_guess", + "proc-macro2", + "quote", + "serde", + "syn 2.0.48", +] + +[[package]] +name = "askama_escape" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" + +[[package]] +name = "askama_parser" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0" +dependencies = [ + "nom", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64ct" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" + +[[package]] +name = "basic-toml" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5" +dependencies = [ + "serde", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "borsh" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" +dependencies = [ + "once_cell", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.48", + "syn_derive", +] + +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "sha2", + "tinyvec", +] + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "bytecheck" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + +[[package]] +name = "chrono" +version = "0.4.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets", +] + +[[package]] +name = "concordium-contracts-common" +version = "9.0.0" +dependencies = [ + "base64", + "bs58", + "chrono", + "concordium-contracts-common-derive", + "fnv", + "hashbrown 0.11.2", + "hex", + "num-bigint", + "num-integer", + "num-traits", + "rust_decimal", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "concordium-contracts-common-derive" +version = "4.0.1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "concordium_base" +version = "4.0.0" +dependencies = [ + "anyhow", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "bs58", + "byteorder", + "chrono", + "concordium-contracts-common", + "concordium_base_derive", + "curve25519-dalek", + "derive_more", + "ed25519-dalek", + "either", + "ff 0.13.0", + "hex", + "itertools", + "leb128", + "libc", + "nom", + "num", + "num-bigint", + "num-traits", + "rand", + "rayon", + "rust_decimal", + "serde", + "serde_json", + "serde_with", + "sha2", + "sha3", + "subtle", + "thiserror", + "zeroize", +] + +[[package]] +name = "concordium_base_derive" +version = "1.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crypto" +version = "0.1.0" +dependencies = [ + "thiserror", + "uniffi", + "wallet_library", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "group", + "platforms", + "rand_core 0.6.4", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.48", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand_core 0.6.4", + "serde", + "sha2", + "subtle", + "zeroize", +] + +[[package]] +name = "ed25519_hd_key_derivation" +version = "1.0.0" +dependencies = [ + "ed25519-dalek", + "hex", + "hmac", + "regex", + "sha2", + "thiserror", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "ff" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4530da57967e140ee0b44e0143aa66b5cb42bd9c503dbe316a15d5b0be65713e" +dependencies = [ + "byteorder", + "rand_core 0.5.1", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "bitvec", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fs-err" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "goblin" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6b4de4a8eb6c46a8c77e1d3be942cb9a8bf073c22374578e5ba4b08ed0ff68" +dependencies = [ + "log", + "plain", + "scroll", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.7", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.7", +] + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", + "serde", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "js-sys" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "key_derivation" +version = "2.1.0" +dependencies = [ + "concordium_base", + "ed25519-dalek", + "ed25519_hd_key_derivation", + "hmac", + "keygen_bls", + "pbkdf2", + "serde", + "sha2", + "thiserror", +] + +[[package]] +name = "keygen_bls" +version = "2.0.0" +dependencies = [ + "concordium_base", + "ff 0.5.2", + "hex", + "hkdf", + "sha2", +] + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "oneshot-uniffi" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c548d5c78976f6955d72d0ced18c48ca07030f7a1d4024529fedd7c1c01b29c" + +[[package]] +name = "password-hash" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pbkdf2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +dependencies = [ + "digest", + "hmac", + "password-hash", + "sha2", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "platforms" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rend" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "rkyv" +version = "0.7.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rust_decimal" +version = "1.33.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "scroll" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04c565b551bafbef4157586fa379538366e4385d42082f255bfd96e4fe8519da" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "semver" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.195" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.195" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "serde_json" +version = "1.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58c3a1b3e418f61c25b2aeb43fc6c95eaa252b8cecdda67f401943e9e08d33f" +dependencies = [ + "base64", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.1.0", + "serde", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2068b437a31fc68f25dd7edc296b078f04b45145c199d8eed9866e45f1ff274" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "thiserror" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "time" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +dependencies = [ + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "uniffi" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21345172d31092fd48c47fd56c53d4ae9e41c4b1f559fb8c38c1ab1685fd919f" +dependencies = [ + "anyhow", + "uniffi_build", + "uniffi_core", + "uniffi_macros", +] + +[[package]] +name = "uniffi_bindgen" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd992f2929a053829d5875af1eff2ee3d7a7001cb3b9a46cc7895f2caede6940" +dependencies = [ + "anyhow", + "askama", + "camino", + "cargo_metadata", + "fs-err", + "glob", + "goblin", + "heck", + "once_cell", + "paste", + "serde", + "toml", + "uniffi_meta", + "uniffi_testing", + "uniffi_udl", +] + +[[package]] +name = "uniffi_build" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001964dd3682d600084b3aaf75acf9c3426699bc27b65e96bb32d175a31c74e9" +dependencies = [ + "anyhow", + "camino", + "uniffi_bindgen", +] + +[[package]] +name = "uniffi_checksum_derive" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55137c122f712d9330fd985d66fa61bdc381752e89c35708c13ce63049a3002c" +dependencies = [ + "quote", + "syn 2.0.48", +] + +[[package]] +name = "uniffi_core" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6121a127a3af1665cd90d12dd2b3683c2643c5103281d0fed5838324ca1fad5b" +dependencies = [ + "anyhow", + "bytes", + "camino", + "log", + "once_cell", + "oneshot-uniffi", + "paste", + "static_assertions", +] + +[[package]] +name = "uniffi_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11cf7a58f101fcedafa5b77ea037999b88748607f0ef3a33eaa0efc5392e92e4" +dependencies = [ + "bincode", + "camino", + "fs-err", + "once_cell", + "proc-macro2", + "quote", + "serde", + "syn 2.0.48", + "toml", + "uniffi_build", + "uniffi_meta", +] + +[[package]] +name = "uniffi_meta" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71dc8573a7b1ac4b71643d6da34888273ebfc03440c525121f1b3634ad3417a2" +dependencies = [ + "anyhow", + "bytes", + "siphasher", + "uniffi_checksum_derive", +] + +[[package]] +name = "uniffi_testing" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "118448debffcb676ddbe8c5305fb933ab7e0123753e659a71dc4a693f8d9f23c" +dependencies = [ + "anyhow", + "camino", + "cargo_metadata", + "fs-err", + "once_cell", +] + +[[package]] +name = "uniffi_udl" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "889edb7109c6078abe0e53e9b4070cf74a6b3468d141bdf5ef1bd4d1dc24a1c3" +dependencies = [ + "anyhow", + "uniffi_meta", + "uniffi_testing", + "weedle2", +] + +[[package]] +name = "uuid" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wallet_library" +version = "0.2.0" +dependencies = [ + "anyhow", + "concordium_base", + "either", + "hex", + "key_derivation", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.48", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" + +[[package]] +name = "weedle2" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e79c5206e1f43a2306fd64bdb95025ee4228960f2e6c5a8b173f3caaf807741" +dependencies = [ + "nom", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "winnow" +version = "0.5.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +dependencies = [ + "memchr", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] diff --git a/lib/crypto/Cargo.toml b/lib/crypto/Cargo.toml new file mode 100644 index 0000000..64d9b28 --- /dev/null +++ b/lib/crypto/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "crypto" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["staticlib", "lib"] +name = "crypto" + +[dependencies] +thiserror = "1.0.56" +uniffi = "0.25" +wallet_library = { path = "./concordium-base/rust-src/wallet_library" } + +[build-dependencies] +uniffi = { version = "0.25", features = ["build"] } diff --git a/lib/crypto/build.rs b/lib/crypto/build.rs new file mode 100644 index 0000000..145281c --- /dev/null +++ b/lib/crypto/build.rs @@ -0,0 +1,3 @@ +fn main() { + uniffi::generate_scaffolding("./src/lib.udl").unwrap(); +} diff --git a/lib/crypto/build.sh b/lib/crypto/build.sh new file mode 100755 index 0000000..8840c4f --- /dev/null +++ b/lib/crypto/build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +set -eux + +rm -rf ./ConcordiumWalletCrypto/ +cargo swift package --name=ConcordiumWalletCrypto --platforms=ios --platforms=macos --release diff --git a/lib/crypto/concordium-base b/lib/crypto/concordium-base new file mode 160000 index 0000000..6d9ad35 --- /dev/null +++ b/lib/crypto/concordium-base @@ -0,0 +1 @@ +Subproject commit 6d9ad3500d0150062d8596715f6920ff33678c89 diff --git a/lib/crypto/src/lib.rs b/lib/crypto/src/lib.rs new file mode 100644 index 0000000..5f64c5d --- /dev/null +++ b/lib/crypto/src/lib.rs @@ -0,0 +1,155 @@ +use wallet_library::wallet::{ + get_account_public_key_aux, get_account_signing_key_aux, + get_attribute_commitment_randomness_aux, get_credential_id_aux, get_id_cred_sec_aux, + get_prf_key_aux, get_signature_blinding_randomness_aux, + get_verifiable_credential_backup_encryption_key_aux, get_verifiable_credential_public_key_aux, + get_verifiable_credential_signing_key_aux, +}; + +// UniFFI book: https://mozilla.github.io/uniffi-rs/udl_file_spec.html +uniffi::include_scaffolding!("lib"); + +/// Error type returned by the bridge functions. +/// A corresponding Swift type will be generated (via the UDL definition). +#[derive(Debug, thiserror::Error)] +enum ConcordiumWalletCryptoError { + #[error("call {call} failed: {msg}")] + CallFailed { call: String, msg: String }, +} + +fn get_account_signing_key( + seed_hex: String, + net: String, + identity_provider_index: u32, + identity_index: u32, + credential_counter: u32, +) -> Result { + get_account_signing_key_aux(seed_hex, net.as_str(), identity_provider_index, identity_index, credential_counter) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_account_signing_key(seed_hex, net={net}, identity_provider_index={identity_provider_index}, identity_index={identity_index}, credential_counter={credential_counter})"), + msg: e.to_string(), + }) +} + +fn get_account_public_key( + seed_hex: String, + net: String, + identity_provider_index: u32, + identity_index: u32, + credential_counter: u32, +) -> Result { + get_account_public_key_aux(seed_hex, net.as_str(), identity_provider_index, identity_index, credential_counter) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_account_public_key(seed_hex, net={net}, identity_provider_index={identity_provider_index}, identity_index={identity_index}, credential_counter={credential_counter})"), + msg: e.to_string(), + }) +} + +fn get_id_cred_sec( + seed_hex: String, + net: String, + identity_provider_index: u32, + identity_index: u32, +) -> Result { + get_id_cred_sec_aux(seed_hex, net.as_str(), identity_provider_index, identity_index) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_id_cred_sec(seed_hex, net={net}, identity_provider_index={identity_provider_index}, identity_index={identity_index})"), + msg: e.to_string(), + }) +} + +fn get_prf_key( + seed_hex: String, + net: String, + identity_provider_index: u32, + identity_index: u32, +) -> Result { + get_prf_key_aux(seed_hex, net.as_str(), identity_provider_index, identity_index) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_prf_key(seed_hex, net={net}, identity_provider_index={identity_provider_index}, identity_index={identity_index})"), + msg: e.to_string(), + }) +} + +fn get_credential_id( + seed_hex: String, + net: String, + identity_provider_index: u32, + identity_index: u32, + credential_counter: u8, + commitment_key: String, +) -> Result { + get_credential_id_aux(seed_hex, net.as_str(), identity_provider_index, identity_index, credential_counter, commitment_key.as_str()) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_credential_id(seed_hex, net={net}, identity_provider_index={identity_provider_index}, identity_index={identity_index}, credential_counter={credential_counter}, commitment_key={commitment_key})"), + msg: e.to_string(), + }) +} + +fn get_signature_blinding_randomness( + seed_hex: String, + net: String, + identity_provider_index: u32, + identity_index: u32, +) -> Result { + get_signature_blinding_randomness_aux(seed_hex, net.as_str(), identity_provider_index, identity_index) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_signature_blinding_randomness(seed_hex, net={net}, identity_provider_index={identity_provider_index}, identity_index={identity_index})"), + msg: e.to_string(), + }) +} + +fn get_attribute_commitment_randomness( + seed_hex: String, + net: String, + identity_provider_index: u32, + identity_index: u32, + credential_counter: u32, + attribute: u8, +) -> Result { + get_attribute_commitment_randomness_aux(seed_hex, net.as_str(), identity_provider_index, identity_index, credential_counter, attribute) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_attribute_commitment_randomness(seed_hex, net={net}, identity_provider_index={identity_provider_index}, identity_index={identity_index}, credential_counter={credential_counter}, attribute={attribute})"), + msg: e.to_string(), + }) +} + +fn get_verifiable_credential_signing_key( + seed_hex: String, + net: String, + issuer_index: u64, + issuer_subindex: u64, + verifiable_credential_index: u32, +) -> Result { + get_verifiable_credential_signing_key_aux(seed_hex, net.as_str(), issuer_index, issuer_subindex, verifiable_credential_index) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_verifiable_credential_signing_key(seed_hex, net={net}, issuer_index={issuer_index}, issuer_subindex={issuer_subindex}, verifiable_credential_index={verifiable_credential_index})"), + msg: e.to_string(), + }) +} + +fn get_verifiable_credential_public_key( + seed_hex: String, + net: String, + issuer_index: u64, + issuer_subindex: u64, + verifiable_credential_index: u32, +) -> Result { + get_verifiable_credential_public_key_aux(seed_hex, net.as_str(), issuer_index, issuer_subindex, verifiable_credential_index) + .map_err(|e| ConcordiumWalletCryptoError::CallFailed { + call: format!("get_verifiable_credential_public_key(seed_hex, net={net}, issuer_index={issuer_index}, issuer_subindex={issuer_subindex}, verifiable_credential_index={verifiable_credential_index})"), + msg: e.to_string(), + }) +} + +fn get_verifiable_credential_backup_encryption_key( + seed_hex: String, + net: String, +) -> Result { + get_verifiable_credential_backup_encryption_key_aux(seed_hex, net.as_str()).map_err(|e| { + ConcordiumWalletCryptoError::CallFailed { + call: format!("get_verifiable_credential_backup_encryption_key(seed_hex, net={net}"), + msg: e.to_string(), + } + }) +} diff --git a/lib/crypto/src/lib.udl b/lib/crypto/src/lib.udl new file mode 100644 index 0000000..26a5cea --- /dev/null +++ b/lib/crypto/src/lib.udl @@ -0,0 +1,27 @@ +[Error] +enum ConcordiumWalletCryptoError { + "CallFailed" +}; + +namespace crypto { + [Throws=ConcordiumWalletCryptoError] + string get_account_signing_key(string seed_hex, string network, u32 identity_provider_index, u32 identity_index, u32 credential_counter); + [Throws=ConcordiumWalletCryptoError] + string get_account_public_key(string seed_hex, string network, u32 identity_provider_index, u32 identity_index, u32 credential_counter); + [Throws=ConcordiumWalletCryptoError] + string get_id_cred_sec(string seed_hex, string network, u32 identity_provider_index, u32 identity_index); + [Throws=ConcordiumWalletCryptoError] + string get_prf_key(string seed_hex, string network, u32 identity_provider_index, u32 identity_index); + [Throws=ConcordiumWalletCryptoError] + string get_credential_id(string seed_hex, string network, u32 identity_provider_index, u32 identity_index, u8 credential_counter, string commitment_key); + [Throws=ConcordiumWalletCryptoError] + string get_signature_blinding_randomness(string seed_hex, string network, u32 identity_provider_index, u32 identity_index); + [Throws=ConcordiumWalletCryptoError] + string get_attribute_commitment_randomness(string seed_hex, string network, u32 identity_provider_index, u32 identity_index, u32 credential_counter, u8 attribute); + [Throws=ConcordiumWalletCryptoError] + string get_verifiable_credential_signing_key(string seed_hex, string network, u64 issuer_index, u64 issuer_subindex, u32 verifiable_credential_index); + [Throws=ConcordiumWalletCryptoError] + string get_verifiable_credential_public_key(string seed_hex, string network, u64 issuer_index, u64 issuer_subindex, u32 verifiable_credential_index); + [Throws=ConcordiumWalletCryptoError] + string get_verifiable_credential_backup_encryption_key(string seed_hex, string network); +};