Hotfix: Fixed a bug where if a private or public key ended with a0 or other whitespace byte, the validatePrivate or Public Key function in Bitcoin.mjs would strip that byte. In addition added a Public Key To TRX Address Operation.

This commit is contained in:
David C Goldenberg 2024-10-06 21:25:48 -04:00
parent e96e31cd52
commit f7ebae4e88
5 changed files with 202 additions and 24 deletions

View file

@ -183,6 +183,7 @@ import "./tests/WIFToPrivateKey.mjs";
import "./tests/SeedphraseToSeed.mjs";
import "./tests/DeserializeExtendedKey.mjs";
import "./tests/PublicKeyToETHStyleAddress.mjs";
import "./tests/PublicKeyToTRXStyleAddress.mjs";
import "./tests/GetAllCasings.mjs";
import "./tests/SIGABA.mjs";
import "./tests/ELFInfo.mjs";

View file

@ -0,0 +1,97 @@
/**
* Public Key to TRX Style Address Cryptocurrency Address tests.
*
* @author dgoldenberg [virtualcurrency@mitre.org]
* @copyright MITRE 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Public Key To TRX Style Address",
input: "04187ac6bc2723630c936e363b826de17dac62382e3bbfabf306ad5f55cc79538783889fe32946b52092dad24c56893d522413d67e62b28f6c54f14821367a9edc",
expectedOutput: "THV2shRZn4cam7aQreAg9aixfk2sTcho6r",
recipeConfig: [
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
{
name: "Public Key To TRX Style Address Compressed Key",
input: "02d1b5855d3f99c4449eb7af576bec1b9bc0bf0769446820686d2de5c47c13b1a0",
expectedOutput: "TQS4NjvDN4TxcZd8LwD1eAKv9y4vSVkDW2",
recipeConfig: [
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
{
name: "Public Key to ETH Style Address: Compressed Key 2",
input: "03a85e8f6fc71898b5c3347decd2c0bba8abb99393c8358fcf0bca72e4c7d68514",
expectedOutput: "TXBP2ebjZsnDEL9X5xCZSZZ6FC3Vppccv4",
recipeConfig: [
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
{
name: "Public Key to ETH Style Address: Compressed Key 2 (From Hex)",
input: "03a85e8f6fc71898b5c3347decd2c0bba8abb99393c8358fcf0bca72e4c7d68514",
expectedOutput: "TXBP2ebjZsnDEL9X5xCZSZZ6FC3Vppccv4",
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "Public Key To TRX Style Address",
"args": [],
},
],
},
{
name: "Public Key to TRX Style Address: Compressed Key (From Hex)",
input: "02d1b5855d3f99c4449eb7af576bec1b9bc0bf0769446820686d2de5c47c13b1a0",
expectedOutput: "TQS4NjvDN4TxcZd8LwD1eAKv9y4vSVkDW2",
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
{
name: "Public Key To TRX Style Address (From Hex)",
input: "04187ac6bc2723630c936e363b826de17dac62382e3bbfabf306ad5f55cc79538783889fe32946b52092dad24c56893d522413d67e62b28f6c54f14821367a9edc",
expectedOutput: "THV2shRZn4cam7aQreAg9aixfk2sTcho6r",
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "Public Key To TRX Style Address",
"args": []
},
],
},
]);