congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ECKey.getAddress
Code IndexAdd Tabnine to your IDE (free)

How to use
getAddress
method
in
io.yggdrash.common.crypto.ECKey

Best Java code snippets using io.yggdrash.common.crypto.ECKey.getAddress (Showing top 13 results out of 315)

origin: yggdrash/yggdrash

/**
 * Account Constructor.
 * - generate wallet with new key
 */
public Account() {
  this.key = new ECKey();
  this.address = this.key.getAddress();
}
origin: yggdrash/yggdrash

this.keyPath = keyPath;
this.keyName = keyName;
this.address = key.getAddress();
this.publicKey = key.getPubKey();
origin: yggdrash/yggdrash

this.keyPath = keyPath;
this.keyName = keyName;
this.address = key.getAddress();
this.publicKey = key.getPubKey();
origin: yggdrash/yggdrash

@Test
public void test3() {
  BigInteger privKey = new BigInteger("cd244b3015703ddf545595da06ada5516628c5feadbf49dc66049c4b370cc5d8", 16);
  byte[] addr = ECKey.fromPrivate(privKey).getAddress();
  assertEquals("89b44e4d3c81ede05d0f5de8d1a68f754d73d997", Hex.toHexString(addr));
}
origin: yggdrash/yggdrash

@Test
public void test4() {
  byte[] cowBytes = sha3("cow".getBytes());
  byte[] addr = ECKey.fromPrivate(cowBytes).getAddress();
  assertEquals("CD2A3D9F938E13CD947EC05ABC7FE734DF8DD826", Hex.toHexString(addr).toUpperCase());
}
origin: yggdrash/yggdrash

@Test
public void test10() {
  BigInteger privKey = new BigInteger("74ef8a796480dda87b4bc550b94c408ad386af0f65926a392136286784d63858", 16);
  byte[] addr = ECKey.fromPrivate(privKey).getAddress();
  assertEquals("ba73facb4f8291f09f27f90fe1213537b910065e", Hex.toHexString(addr));
}
origin: yggdrash/yggdrash

@Test
public void test5() {
  byte[] horseBytes = sha3("horse".getBytes());
  byte[] addr = ECKey.fromPrivate(horseBytes).getAddress();
  assertEquals("13978AEE95F38490E9769C39B2773ED763D9CD5F", Hex.toHexString(addr).toUpperCase());
}
origin: yggdrash/yggdrash

@Test
public void testGetAddress() {
  ECKey key = ECKey.fromPublicOnly(pubKey);
  assertArrayEquals(Hex.decode(address), key.getAddress());
}
origin: yggdrash/yggdrash

public boolean verify() {
  ECKey.ECDSASignature ecdsaSignature = new ECKey.ECDSASignature(signature.getBytes());
  try {
    ECKey ecKeyPub = ECKey.signatureToKey(rawForSign.getBytes(), ecdsaSignature);
    if (ecKeyPub.verify(rawForSign.getBytes(), ecdsaSignature)) {
      return new Address(ecKeyPub.getAddress()).equals(owner);
    } else {
      return false;
    }
  } catch (SignatureException e) {
    throw new InvalidSignatureException(e);
  }
}
origin: yggdrash/yggdrash

  @Test  // cpp keys demystified
  public void test13() {

//        us.secret() a4627abc2a3c25315bff732cb22bc128f203912dd2a840f31e66efb27a47d2b1
//        us.public() caa3d5086b31529bb00207eabf244a0a6c54d807d2ac0ec1f3b1bdde0dbf8130c115b1eaf62ce0f8062bcf70c0fefbc97cec79e7faffcc844a149a17fcd7bada
//        us.address() 47d8cb63a7965d98b547b9f0333a654b60ffa190


    ECKey key = ECKey.fromPrivate(Hex.decode("a4627abc2a3c25315bff732cb22bc128f203912dd2a840f31e66efb27a47d2b1"));

    String address = Hex.toHexString(key.getAddress());
    String pubkey = Hex.toHexString(key.getPubKeyPoint().getEncoded(/* uncompressed form */ false));

    log.info("address: " + address);
    log.info("pubkey: " + pubkey);

    assertEquals("47d8cb63a7965d98b547b9f0333a654b60ffa190", address);
    assertEquals("04caa3d5086b31529bb00207eabf244a0a6c54d807d2ac0ec1f3b1bdde0dbf8130c115b1eaf62ce0f8062bcf70c0fefbc97cec79e7faffcc844a149a17fcd7bada", pubkey);
  }

origin: yggdrash/yggdrash

@Test
public void testVerifySignature_Static() throws SignatureException {
  byte[] messageHash = Hex.decode("92e0d4290bba01aa0abbb4705360c751af13fdb1131b8f6f1e632c4621adac75");
  byte[] signature = Hex.decode("1cca588a8eb84d5bf6741bc6e0ccfbe1fdb05b6c624b5fe72199fa1f2e501f876c5b5f11863323a998b79a0d27714fcc8825cf357903e863396f2e2e281220de31");
  // get public key with messageHash, ECDSASignature
  ECKey.ECDSASignature sig = new ECKey.ECDSASignature(signature);
  ECKey keyFromSig = ECKey.signatureToKey(messageHash, sig);
  log.debug("address=" + Hex.toHexString(keyFromSig.getAddress()));
  byte[] pubKeyFromSig = keyFromSig.getPubKey();
  log.debug("pubKey=" + Hex.toHexString(pubKeyFromSig));
  assertArrayEquals(pubKeyFromSig, Hex.decode("0493fe448d38c77c212cce10c07ed37984c59bedac51219b70847429153063cfae0d2f42ba394ffe9d5d2d11b0c0f400ac04997c584c0ef6f2041cf20f8c2c446b"));
  // verify the sign message
  assertTrue(keyFromSig.verify(messageHash, sig));
}
origin: yggdrash/yggdrash

@Test
public void testGetAddressWithSig()
    throws IOException, InvalidCipherTextException, SignatureException {
  Account account = new Account();
  log.debug("Account: " + account.toString());
  log.debug("Account.address: " + Hex.toHexString(account.getAddress()));
  log.debug("Account.pubKey: " + Hex.toHexString(account.getKey().getPubKey()));
  Wallet wallet = new Wallet(account.getKey(), "tmp/path", "nodePri.key", "Aa1234567890!");
  log.debug("Wallet: " + wallet.toString());
  log.debug("Wallet.address: " + Hex.toHexString(wallet.getAddress()));
  log.debug("Wallet.pubKey: " + Hex.toHexString(wallet.getPubicKey()));
  TransactionHusk txHusk1 = createTx(wallet);
  log.debug("Test Transaction1: " + txHusk1.toString());
  log.debug("Test Transaction1 Address: " + txHusk1.getAddress());
  assertThat(txHusk1.verify()).isTrue();
  assertThat(wallet.getAddress()).isEqualTo(account.getAddress());
  assertThat(wallet.getAddress()).isEqualTo(txHusk1.getAddress().getBytes());
  byte[] hashedRawData = txHusk1.getHashForSigning().getBytes();
  log.debug("hashedRawData: " + Hex.toHexString(hashedRawData));
  byte[] signatureBin = txHusk1.getInstance().getSignature().toByteArray();
  log.debug("signatureBin: " + Hex.toHexString(signatureBin));
  ECKey.ECDSASignature ecdsaSignature = new ECKey.ECDSASignature(signatureBin);
  ECKey key = ECKey.signatureToKey(hashedRawData, ecdsaSignature);
  byte[] address = key.getAddress();
  byte[] pubKey = key.getPubKey();
  log.debug("address: " + Hex.toHexString(address));
  log.debug("pubKey: " + Hex.toHexString(pubKey));
  assertThat(account.getAddress()).isEqualTo(address);
  assertThat(account.getKey().getPubKey()).isEqualTo(pubKey);
}
origin: yggdrash/yggdrash

@Test
public void testVerifySignature2() throws SignatureException {
  BigInteger r = new BigInteger("c52c114d4f5a3ba904a9b3036e5e118fe0dbb987fe3955da20f2cd8f6c21ab9c", 16);
  BigInteger s = new BigInteger("6ba4c2874299a55ad947dbc98a25ee895aabf6b625c26c435e84bfd70edf2f69", 16);
  ECDSASignature sig = ECDSASignature.fromComponents(r.toByteArray(), s.toByteArray(), (byte) 0x1b);
  byte[] rawtx = Hex.decode("f82804881bc16d674ec8000094cd2a3d9f938e13cd947ec05abc7fe734df8dd8268609184e72a0006480");
  byte[] rawHash = HashUtil.sha3(rawtx);
  byte[] address = Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826");
  ECKey key = ECKey.signatureToKey(rawHash, sig);
  assertEquals(key, ECKey.signatureToKey(rawHash, sig.toBase64()));
  assertEquals(key, ECKey.recoverFromSignature(0, sig, rawHash));
  assertArrayEquals(key.getPubKey(), ECKey.recoverPubBytesFromSignature(0, sig, rawHash));
  assertArrayEquals(address, key.getAddress());
  assertArrayEquals(address, ECKey.signatureToAddress(rawHash, sig));
  assertArrayEquals(address, ECKey.signatureToAddress(rawHash, sig.toBase64()));
  assertArrayEquals(address, ECKey.recoverAddressFromSignature(0, sig, rawHash));
  assertTrue(key.verify(rawHash, sig));
}
io.yggdrash.common.cryptoECKeygetAddress

Javadoc

Gets the address form of the public key.

Popular methods of ECKey

  • <init>
    Generates an entirely new keypair with the given SecureRandom object. BouncyCastle will be used as
  • doSign
    Signs the given hash and returns the R and S components as BigIntegers and put them in ECDSASignatur
  • fromPrivate
    Creates an ECKey given the private key only.
  • fromPublicOnly
    Creates an ECKey that cannot be used for signing, only verifying signatures, from the given encoded
  • getNodeId
    Generates the NodeID based on this key, that is the public key without first format byte
  • getPrivKeyBytes
    Returns a 32 byte array containing the private key, or null if the key is encrypted or public only
  • getPubKey
    Gets the encoded public key value.
  • isPubKeyCanonical
    Returns true if the given pubkey is canonical, i.e. the correct length taking into wallet compressio
  • recoverPubBytesFromSignature
    Given the components of a signature and a selector value, recover and return the public key that gen
  • sign
    Takes the keccak hash (32 bytes) of data and returns the ECDSA signature
  • signatureToKey
    Compute the key that signed the given signature.
  • verify
    Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key.
  • signatureToKey,
  • verify,
  • check,
  • computeAddress,
  • decompressKey,
  • equals,
  • extractPublicKey,
  • fromNodeId,
  • getPubKeyPoint

Popular in Java

  • Finding current android device location
  • compareTo (BigDecimal)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now