forked from TrueCloudLab/frostfs-sdk-java
parent
7518893388
commit
ab8a574d0d
14 changed files with 139 additions and 25 deletions
|
@ -24,13 +24,14 @@ import java.security.spec.ECPublicKeySpec;
|
|||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static info.frostfs.sdk.Helper.getRIPEMD160;
|
||||
import static info.frostfs.sdk.Helper.getRipemd160;
|
||||
import static info.frostfs.sdk.Helper.getSha256;
|
||||
import static java.util.Objects.isNull;
|
||||
import static org.bouncycastle.util.BigIntegers.fromUnsignedByteArray;
|
||||
|
||||
public class KeyExtension {
|
||||
public static final byte NEO_ADDRESS_VERSION = 0x35;
|
||||
private static final int PS_IN_HASH160 = 0x0C;
|
||||
private static final int DECODE_ADDRESS_LENGTH = 21;
|
||||
private static final int COMPRESSED_PUBLIC_KEY_LENGTH = 33;
|
||||
private static final int UNCOMPRESSED_PUBLIC_KEY_LENGTH = 65;
|
||||
|
@ -134,7 +135,7 @@ public class KeyExtension {
|
|||
checkInputValue(publicKey);
|
||||
|
||||
var script = createSignatureRedeemScript(publicKey);
|
||||
return getRIPEMD160(getSha256(script));
|
||||
return getRipemd160(getSha256(script));
|
||||
}
|
||||
|
||||
public static String publicKeyToAddress(byte[] publicKey) {
|
||||
|
@ -161,7 +162,7 @@ public class KeyExtension {
|
|||
byte[] buffer = new byte[4];
|
||||
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
buffer[i] = (byte) (value >> i * 8);
|
||||
buffer[i] = (byte) (value >> i * Byte.SIZE);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
@ -176,10 +177,10 @@ public class KeyExtension {
|
|||
);
|
||||
}
|
||||
|
||||
var script = new byte[]{0x0c, COMPRESSED_PUBLIC_KEY_LENGTH}; //PUSHDATA1 33
|
||||
var script = new byte[]{PS_IN_HASH160, COMPRESSED_PUBLIC_KEY_LENGTH}; //PUSHDATA1 33
|
||||
|
||||
script = ArrayHelper.concat(script, publicKey);
|
||||
script = ArrayHelper.concat(script, new byte[]{0x41}); //SYSCALL
|
||||
script = ArrayHelper.concat(script, new byte[]{UNCOMPRESSED_PUBLIC_KEY_LENGTH}); //SYSCALL
|
||||
script = ArrayHelper.concat(script, getBytes(CHECK_SIG_DESCRIPTOR)); //Neo_Crypto_CheckSig
|
||||
return script;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue