Add EIP1024 conform encryption - #7
Conversation
|
NaCl has the option to encrypt and sign a message in a single pass. The signing is is not conform EIP1024 and presents a small risk (since NaCl signs the raw message, and not conform EIP712, there is likely a small risk of unexpectedly signing a transaction). However, I wonder if there are any scenarios where it would make sense to expose this feature in the API. |
|
@Foboz I've updated this repo as well. Encryption now works, as does decryption using the sender's private key. There might be some possible clean up of the code. Lmk what you think. |
| } | ||
|
|
||
| extension PrivateKeyEth1 { | ||
| public func eth_publicKey() throws -> String { |
There was a problem hiding this comment.
@ronaldmannak can you please keep this method to not break back compatibility, but mark it as 'deprecated'?
| /// Create curve25519 public key from Ethereum private key | ||
| /// - Returns: public key | ||
| public func curve25519PublicKeyData() throws -> Data { | ||
| return try TweetNacl.keyPair(fromSecretKey: self.data()).publicKey |
There was a problem hiding this comment.
@ronaldmannak in that case I think it's better to have private var curve25519Keypair and work with it in all 4 methods (actually it's better to use public var <name>: <type> { get throws { ... } }), instead of having 2 methods with calls of TweetNacl.keyPair dependencies on each other.
| } | ||
|
|
||
|
|
||
| /// Decrypt the message using the sender's private key |
There was a problem hiding this comment.
@ronaldmannak this looks good to me, but indentations needs to be fixed
| .package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "9.0.0")), | ||
| .package(url: "https://github.com/MyEtherWallet/bls-eth-swift.git", .exact("1.0.1")), | ||
| .package(url: "https://github.com/attaswift/BigInt.git", from: "5.2.1"), | ||
| .package(name: "MEWwalletTweetNacl", url: "https://github.com/MyEtherWallet/mew-wallet-ios-tweetnacl.git", .upToNextMajor(from: "1.0.0")) |
This draft PR is related to mew-wallet-ios-tweetnacl PR#3.
I have added encryption to conform to EIP1024.
Question for the maintainers: is the current approach the best way of adding encryption?