Clarify public key encoding and enrich tests (#37)

Don't throw in `seckey_verify`: it's inconsistent to have this function throw
for some invalid inputs and return false for other invalid inputs.

Document public key compression and add tests.
This commit is contained in:
Bastien Teinturier
2021-11-05 10:45:49 +01:00
committed by GitHub
parent f695e7453d
commit 2ae6abcf93
4 changed files with 73 additions and 26 deletions

View File

@@ -72,7 +72,8 @@ JNIEXPORT jint JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256k1_1ec
if (jctx == 0) return 0;
if (jseckey == NULL) return 0;
CHECKRESULT((*penv)->GetArrayLength(penv, jseckey) != 32, "secret key must be 32 bytes");
if ((*penv)->GetArrayLength(penv, jseckey) != 32) return 0;
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
result = secp256k1_ec_seckey_verify(ctx, (unsigned char*)seckey);
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);