-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
18 changed files
with
2,697 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import ConcordiumWalletCrypto | ||
import Foundation | ||
import GRPC | ||
import NIOCore | ||
|
Oops, something went wrong.