From 03c948838cb7a17c4437c25b9b2e41d7da6ff5b3 Mon Sep 17 00:00:00 2001 From: kimziv Date: Wed, 27 Sep 2017 04:55:39 +0800 Subject: [PATCH] fix getAddress method fix getAddress method reference: https://github.com/AschPlatform/asch-js/blob/master/lib/base58check/index.js#L14 --- src/so/asch/sdk/security/DefaultSecurityStrategy.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/so/asch/sdk/security/DefaultSecurityStrategy.java b/src/so/asch/sdk/security/DefaultSecurityStrategy.java index 9aabcce..7a91bce 100644 --- a/src/so/asch/sdk/security/DefaultSecurityStrategy.java +++ b/src/so/asch/sdk/security/DefaultSecurityStrategy.java @@ -83,7 +83,13 @@ public String getAddress(String publicKey) throws SecurityException{ byte[] hash1 = sha256Hash(Decoding.hex(publicKey)); byte[] hash2 = ripemd160Hash(hash1); - return AschConst.BASE58_ADDRESS_PREFIX + Encoding.base58(hash2); + //fix by kimziv + //reference: https://github.com/AschPlatform/asch-js/blob/master/lib/base58check/index.js#L14 + byte[] checksum=sha256Hash(sha256Hash(hash2)); + byte[] hash3=new byte[hash2.length+4]; + System.arraycopy(hash2,0,hash3,0,hash2.length); + System.arraycopy(checksum,0,hash3,hash2.length,4); + return AschConst.BASE58_ADDRESS_PREFIX + Encoding.base58(hash3); } catch (Exception ex){ throw new SecurityException("generate key pair failed", ex);