Skip to content

Commit

Permalink
\SensitiveParameter added
Browse files Browse the repository at this point in the history
  • Loading branch information
furqansiddiqui committed Aug 4, 2024
1 parent a1da505 commit 9597375
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/BIP39.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public static function fromRandom(AbstractLanguage $wordList, int $wordCount = 1
* @return \FurqanSiddiqui\BIP39\Mnemonic
* @throws \FurqanSiddiqui\BIP39\Exception\Bip39EntropyException
*/
public static function fromEntropy(AbstractByteArray $entropy, AbstractLanguage $wordList): Mnemonic
public static function fromEntropy(
#[\SensitiveParameter]
AbstractByteArray $entropy,
AbstractLanguage $wordList
): Mnemonic
{
// Validate Entropy Length
$entropyBits = $entropy->len() * 8;
Expand Down Expand Up @@ -90,7 +94,11 @@ public static function fromEntropy(AbstractByteArray $entropy, AbstractLanguage
* @return \FurqanSiddiqui\BIP39\Mnemonic
* @throws \FurqanSiddiqui\BIP39\Exception\Bip39MnemonicException
*/
public static function fromMnemonic(array $words, AbstractLanguage $wordList, bool $verifyChecksum = true): Mnemonic
public static function fromMnemonic(
#[\SensitiveParameter] array $words,
AbstractLanguage $wordList,
bool $verifyChecksum = true
): Mnemonic
{
$bitLen = static::wordCountToBits(count($words));

Expand Down Expand Up @@ -145,7 +153,7 @@ public static function fromWords(array $words, AbstractLanguage $wordList, bool
* @param int $checksumBits
* @return string
*/
private static function checksum(string $entropyBn, int $checksumBits): string
private static function checksum(#[\SensitiveParameter] string $entropyBn, int $checksumBits): string
{
$checksumChar = ord(hash("sha256", $entropyBn, true)[0]);
$checksum = "";
Expand Down
2 changes: 2 additions & 0 deletions src/Mnemonic.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
*/
public function __construct(
public string $language,
#[\SensitiveParameter]
public array $words,
public array $wordsIndex,
#[\SensitiveParameter]
public string $entropy
)
{
Expand Down

0 comments on commit 9597375

Please sign in to comment.