From 9638528b8e8567886eaf0555259b4a9329e8ebf6 Mon Sep 17 00:00:00 2001 From: "Owain G. Ainsworth" Date: Fri, 14 Jun 2013 00:06:25 +0100 Subject: [PATCH] test hybrid keys too. Nothing that I know of uses them, but if we have the code path we should be pretty sure it works. --- pubkey_test.go | 26 ++++++++++++++++++++++++++ test_coverage.txt | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pubkey_test.go b/pubkey_test.go index cec38d7b..581cdc41 100644 --- a/pubkey_test.go +++ b/pubkey_test.go @@ -70,6 +70,32 @@ var pubKeyTests = []pubKeyTest{ }, isValid: false, }, + pubKeyTest{ + name: "uncompressed as hybrid ok", + key: []byte{0x07, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, + 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, + 0xb6, 0x8a, 0x38, 0x2e, 0x97, 0xb1, 0x48, 0x2e, 0xca, + 0xd7, 0xb1, 0x48, 0xa6, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, + 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0xf9, 0x74, 0x44, 0x64, + 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, + 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, + 0xb4, 0x12, 0xa3, + }, + isValid: true, + }, + pubKeyTest{ + name: "uncompressed as hybrid wrong", + key: []byte{0x06, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, + 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, + 0xb6, 0x8a, 0x38, 0x2e, 0x97, 0xb1, 0x48, 0x2e, 0xca, + 0xd7, 0xb1, 0x48, 0xa6, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, + 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0xf9, 0x74, 0x44, 0x64, + 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, + 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, + 0xb4, 0x12, 0xa3, + }, + isValid: false, + }, // from tx 0b09c51c51ff762f00fb26217269d2a18e77a4fa87d69b3c363ab4df16543f20 pubKeyTest{ name: "compressed ok (ybit = 0)", diff --git a/test_coverage.txt b/test_coverage.txt index 0432f2a3..fc212146 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -12,9 +12,9 @@ github.com/conformal/btcec/btcec.go KoblitzCurve.ScalarBaseMult 100.00% (1/1) github.com/conformal/btcec/btcec.go initAll 100.00% (1/1) github.com/conformal/btcec/pubkey.go isOdd 100.00% (1/1) github.com/conformal/btcec/btcec.go KoblitzCurve.addJacobian 91.67% (55/60) +github.com/conformal/btcec/pubkey.go ParsePubKey 90.62% (29/32) github.com/conformal/btcec/btcec.go KoblitzCurve.affineFromJacobian 90.00% (9/10) -github.com/conformal/btcec/pubkey.go ParsePubKey 78.12% (25/32) github.com/conformal/btcec/signature.go ParseSignature 0.00% (0/41) github.com/conformal/btcec/btcec.go KoblitzCurve.Double 0.00% (0/2) -github.com/conformal/btcec ------------------------------- 72.68% (149/205) +github.com/conformal/btcec ------------------------------- 74.63% (153/205)