Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

PVT_K1 is a legacy WIF key #282

Open
Mattijah opened this issue Nov 17, 2020 · 0 comments
Open

PVT_K1 is a legacy WIF key #282

Mattijah opened this issue Nov 17, 2020 · 0 comments

Comments

@Mattijah
Copy link
Contributor

Mattijah commented Nov 17, 2020

The key returned by toEosioK1PrivateKey is in the legacy (WIF) format, while the actual PVT_K1 keys as for example PVT_K1_2QiGfgPuTfYxupXz4vAPGgeC3fCp2AJV23Lxxuuv6xxbUgND51 are not supported.

var toEosioK1PrivateKey: String {
return "PVT_K1_" + self.addPrefix(0x80).append4ByteDoubleSha256Suffix.base58EncodedString
}

Data(eosioPrivateKey:) fails when trying to initialize it with the key shown above.

guard checksum == hash.prefix(4) else {

Edit 1:
There is already a logic in place for checking the checksum of the new key, but for some reason it's only used for R1.

keyToHash = key + "R1".data(using: .utf8)!
hash = RIPEMD160.hash(message: keyToHash)

Edit 2:
All test cases testing the private keys contain a fail message that talks about converting a public key.

return XCTFail("Failed to convert public K1 key to Data()")

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant