[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Either expose DefaultCryptoProvider or update your documentation #1174

Open
muratogat opened this issue Oct 11, 2023 · 7 comments
Open

Either expose DefaultCryptoProvider or update your documentation #1174

muratogat opened this issue Oct 11, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@muratogat
Copy link
muratogat commented Oct 11, 2023

Currently during the initialization of the SDK, it is not possible to "just call a configure method" as claimed here, because the DefaultCryptoProvider is not exposed as discussed here.

Either expose DefaultCryptoProvider such that it can be somehow imported even if the package is added through SPM, or alternatively update your documentation such that is clearly explains that developers are expected to implement a crypto provider by themselves to be passed to the Web3Wallet configuration as a parameter.

@muratogat muratogat added the enhancement New feature or request label Oct 11, 2023
@flypaper0
Copy link
Contributor

Thanks for response. Different clients uses different crypto libraries. So we cannot depends on Web3.swift or CryptoSwift in our SDK. But It's a good call to update our integration docs if it's no clear for developers

@flypaper0
Copy link
Contributor

cc @alexander-lsvk

@simonmcl
Copy link

Just ran into this issue as well while updating. Its not clear what this is for or how I should implement it. I'm not using an Ethereum chain, but the CryptoProvider protocol requires me to implement a func that takes an EthereumSignature as a parameter

@simonmcl
Copy link

Please also note that most of the links in the swift repos README are pointing to dead links

@muratogat
Copy link
Author

@simonmcl here is my implementation

struct WC2CryptoProvider: CryptoProvider {
    public func recoverPubKey(signature: EthereumSignature, message: Data) throws -> Data {
        return SECP256K1.recoverPublicKey(hash: message, signature: signature.serialized)!
    }

    public func keccak256(_ data: Data) -> Data {
        return data.sha3(.keccak256)
    }
}

EthereumSignature is part of the WalletConnect SDK. You don't need to create or implement it.
Depending on the libraries you use, you may not have access to those methods above, but the idea should be clear.

@simonmcl
Copy link

@muratogat thanks for the help. Can you link me to the lib you are using for this:

SECP256K1.recoverPublicKey(hash: message, signature: signature.serialized)!

@muratogat
Copy link
Author

This is the file in web3swift, which I forked, where the functionality is.

https://github.com/muratogat/web3swift/blob/develop/Sources/web3swift/Convenience/SECP256k1.swift

However, this is in the background importing the base secp256k1 library (import secp256k1 at the top), which is linked as a static library in web3swift (https://github.com/muratogat/web3swift/tree/develop/Sources/secp256k1). Not sure how it would work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants