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

Commit

Permalink
Added test for public key conversion and extraction that would fail w…
Browse files Browse the repository at this point in the history
…ithout padding.
  • Loading branch information
opi-smccoole committed Nov 1, 2019
1 parent 3d050c5 commit 3d204dd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions EosioSwiftEccTests/EosioSwiftEccRecoverKeyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ class EosioSwiftEccRecoverKeyTests: XCTestCase {

}

func test_eosioK1_private_to_public_needs_padding() {
do {
let privateKey = "5KLuCa3aEXW2kLyj2xbHjn9fsoZmmBNBTbVHhnkzVXtgjipDyQF"
let publicKey = try EccRecoverKey.recoverPublicKey(privateKey: Data(eosioPrivateKey: privateKey), curve: .k1)
guard let eosLegacyPublicKey = publicKey.toCompressedPublicKey?.toEosioLegacyPublicKey else {
XCTFail("Should not fail to convert to EOSIO Legacy Public key.")
return
}
XCTAssert(eosLegacyPublicKey == "EOS7mbBaD7UFLQKVE3oGkAp4ToFaFjaedjJA2WBpTBY8yXgnwK53e")
} catch let error {
XCTFail("Should not error extracting public from private key: \(error.localizedDescription)")
}
}

func test_eosioK1_private_to_public() {
do {
let privateKey = try Data(eosioPrivateKey: privateKeyK1)
Expand Down

0 comments on commit 3d204dd

Please sign in to comment.