mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-13 19:37:49 +01:00
Bech32: use ByteUtils.concat() in verifyChecksum()
This commit is contained in:
parent
96835143db
commit
5edb96cbb8
1 changed files with 2 additions and 3 deletions
|
@ -18,6 +18,7 @@ package org.bitcoinj.base;
|
||||||
|
|
||||||
import org.bitcoinj.base.exceptions.AddressFormatException;
|
import org.bitcoinj.base.exceptions.AddressFormatException;
|
||||||
import org.bitcoinj.base.internal.ByteArray;
|
import org.bitcoinj.base.internal.ByteArray;
|
||||||
|
import org.bitcoinj.base.internal.ByteUtils;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -197,9 +198,7 @@ public class Bech32 {
|
||||||
*/
|
*/
|
||||||
private static Encoding verifyChecksum(final String hrp, final byte[] values) {
|
private static Encoding verifyChecksum(final String hrp, final byte[] values) {
|
||||||
byte[] hrpExpanded = expandHrp(hrp);
|
byte[] hrpExpanded = expandHrp(hrp);
|
||||||
byte[] combined = new byte[hrpExpanded.length + values.length];
|
byte[] combined = ByteUtils.concat(hrpExpanded, values);
|
||||||
System.arraycopy(hrpExpanded, 0, combined, 0, hrpExpanded.length);
|
|
||||||
System.arraycopy(values, 0, combined, hrpExpanded.length, values.length);
|
|
||||||
final int check = polymod(combined);
|
final int check = polymod(combined);
|
||||||
if (check == BECH32_CONST)
|
if (check == BECH32_CONST)
|
||||||
return Encoding.BECH32;
|
return Encoding.BECH32;
|
||||||
|
|
Loading…
Add table
Reference in a new issue