Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
delete 助记词 InvalidChecksumException 检查
Browse files Browse the repository at this point in the history
  • Loading branch information
QuincySx committed May 15, 2018
1 parent 98eaaeb commit 19da077
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ private static void validate(final int[] wordIndexes) throws
final int cs = ent / 32;
if (entPlusCs != ent + cs)
throw new InvalidWordCountException();
final byte[] entropyWithChecksum = new byte[(entPlusCs + 7) / 8];

wordIndexesToEntropyWithCheckSum(wordIndexes, entropyWithChecksum);
Arrays.fill(wordIndexes, 0);

final byte[] entropy = Arrays.copyOf(entropyWithChecksum, entropyWithChecksum.length - 1);
final byte lastByte = entropyWithChecksum[entropyWithChecksum.length - 1];
Arrays.fill(entropyWithChecksum, (byte) 0);

final byte sha = MnemonicGenerator.firstByteOfSha256(entropy);

final byte mask = maskOfFirstNBits(cs);

if (((sha ^ lastByte) & mask) != 0)
throw new InvalidChecksumException();
// final byte[] entropyWithChecksum = new byte[(entPlusCs + 7) / 8];
//
// wordIndexesToEntropyWithCheckSum(wordIndexes, entropyWithChecksum);
// Arrays.fill(wordIndexes, 0);
//
// final byte[] entropy = Arrays.copyOf(entropyWithChecksum, entropyWithChecksum.length - 1);
// final byte lastByte = entropyWithChecksum[entropyWithChecksum.length - 1];
// Arrays.fill(entropyWithChecksum, (byte) 0);

// final byte sha = MnemonicGenerator.firstByteOfSha256(entropy);
//
// final byte mask = maskOfFirstNBits(cs);
//
// if (((sha ^ lastByte) & mask) != 0)
// throw new InvalidChecksumException();
}

private int[] findWordIndexes(final Collection<? extends CharSequence> split) throws
Expand Down

0 comments on commit 19da077

Please sign in to comment.