congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
KeyAddress.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.icodici.crypto.KeyAddress
constructor

Best Java code snippets using com.icodici.crypto.KeyAddress.<init> (Showing top 20 results out of 315)

origin: UniversaBlockchain/universa

/**
 * Generate address for the key, see {@link KeyAddress} for more.
 *
 * @param useSha3_384 use SHA3-384 for hash, otherwise SHA3-256
 * @param keyMark some data code in 0..15 range inclusive
 * @return generated address
 */
public KeyAddress address(boolean useSha3_384, int keyMark) {
  return new KeyAddress(this, keyMark, useSha3_384);
}
origin: UniversaBlockchain/universa

public UnsRecord(AbstractKey key, int keyMark) {
  unsAddresses.add(new KeyAddress(key, keyMark, false));
  unsAddresses.add(new KeyAddress(key, keyMark, true));
}
origin: UniversaBlockchain/universa

public UnsRecord(AbstractKey key) {
  unsAddresses.add(new KeyAddress(key, 0, false));
  unsAddresses.add(new KeyAddress(key, 0, true));
}
origin: UniversaBlockchain/universa

/**
 * Check that the key matches this address, e.g. has of the same type and the digest of its components is the same.
 * The key components digest is calculated by the key self in the {@link AbstractKey#updateDigestWithKeyComponents(Digest)}
 *
 * @param key
 *         to check
 *
 * @return true if the key matches (what means, it is the key corresponding to this address)
 */
@Override
public boolean isMatchingKey(AbstractKey key) {
  KeyAddress other = new KeyAddress(key, 0, _isLong);
  if (other.keyMask != keyMask)
    return false;
  if (!Arrays.equals(keyDigest, other.keyDigest))
    return false;
  return true;
}
origin: UniversaBlockchain/universa

public JSApiSimpleRole(String name, String... addresses) throws KeyAddress.IllegalAddressException {
  List<KeyAddress> keyAddresses = new ArrayList<>();
  for (int i = 0; i < addresses.length; ++i) {
    keyAddresses.add(new KeyAddress(addresses[i]));
  }
  simpleRole = new SimpleRole(name, keyAddresses);
}
origin: UniversaBlockchain/universa

public void setOwner(List<String> addresses) throws KeyAddress.IllegalAddressException {
  List<KeyAddress> addressesList = new ArrayList<>();
  for (String s : addresses)
    addressesList.add(new KeyAddress(s));
  this.currentContract.setOwnerKeys(addressesList);
}
origin: UniversaBlockchain/universa

@Override
public Object deserialize(Binder binder, BiDeserializer deserializer) {
  try {
    return new KeyAddress(binder.getBinaryOrThrow("uaddress"));
  } catch (IllegalAddressException e) {
    e.printStackTrace();
    throw new IllegalArgumentException("can't reconstruct KeyAddress");
  }
}
origin: UniversaBlockchain/universa

protected UnsRecord initializeWithDsl(Binder binder) {
  String digest = binder.getString(ORIGIN_FIELD_NAME, null);
  if (digest != null) {
    unsOrigin = HashId.withDigest(digest);
  } else {
    ArrayList<?> list = binder.getArray(ADDRESSES_FIELD_NAME);
    for (Object obj: list)
      if (obj.getClass().getName().endsWith("String")) {
        try {
          unsAddresses.add(new KeyAddress((String) obj));
        } catch (Exception e) {
          throw new IllegalArgumentException("Error converting address from base58 string: " + e.getMessage());
        }
      }
  }
  return this;
}
origin: UniversaBlockchain/universa

@Before
public void beforeScriptEngineTest() throws Exception {
  // add U issuer test key
  configForProvider.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
}
origin: UniversaBlockchain/universa

private static void doCreateAddress(String keyFilePath, boolean bShort) throws IOException {
  report("Generate " + (bShort ? "short" : "long") + " address from key: " + keyFilePath);
  PublicKey key = readKeyAndGetPublic(keyFilePath);
  KeyAddress address = new KeyAddress(key, 0, !bShort);
  report("Address: " + address.toString());
  finish();
}
origin: UniversaBlockchain/universa

private static void doAddressMatch(String address, String keyFilePath) throws IOException {
  boolean bResult = false;
  try {
    PublicKey key = readKeyAndGetPublic(keyFilePath);
    KeyAddress keyAddress = new KeyAddress(address);
    bResult = keyAddress.isMatchingKey(key);
  }
  catch (Exception e) {};
  report("Matching address: " + address + " with key: "+ keyFilePath);
  report("Matching result: " + bResult);
  finish();
}
origin: UniversaBlockchain/universa

Main createMain(String name, String postfix, boolean nolog) throws InterruptedException {
  String path = new File("src/test_node_config_v2" + postfix + "/" + name).getAbsolutePath();
  System.out.println(path);
  String[] args = new String[]{"--test", "--config", path, nolog ? "--nolog" : ""};
  List<Main> mm = new ArrayList<>();
  Thread thread = new Thread(() -> {
    try {
      Main m = new Main(args);
      try {
        m.config.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
      } catch (KeyAddress.IllegalAddressException e) {
        e.printStackTrace();
      }
      //m.config.getKeysWhiteList().add(m.config.getUIssuerKey());
      m.waitReady();
      mm.add(m);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  });
  thread.setName("Node Server: " + name);
  thread.start();
  while (mm.size() == 0) {
    Thread.sleep(100);
  }
  return mm.get(0);
}
origin: UniversaBlockchain/universa

@Before
public void beforeMainTest() throws Exception {
  // clearLedgers
  List<String> dbUrls = new ArrayList<>();
  dbUrls.add("jdbc:postgresql://localhost:5432/universa_node_t1");
  dbUrls.add("jdbc:postgresql://localhost:5432/universa_node_t2");
  dbUrls.add("jdbc:postgresql://localhost:5432/universa_node_t3");
  dbUrls.add("jdbc:postgresql://localhost:5432/universa_node_t4");
  List<Ledger> ledgers = new ArrayList<>();
  dbUrls.stream().forEach(url -> {
    try {
      clearLedger(url);
      PostgresLedger ledger = new PostgresLedger(url);
      ledgers.add(ledger);
    } catch (Exception e) {
      e.printStackTrace();
    }
  });
  // add U issuer test key
  configForProvider.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
}
origin: UniversaBlockchain/universa

@Test
public void testAddressRole() throws Exception {
  Set<KeyAddress> keyAddresses = new HashSet<>();
  keyAddresses.add(new KeyAddress(keys.get(0).getPublicKey(), 0, true));
  SimpleRole sr = new SimpleRole("tr1", keyAddresses);
  Binder serialized = DefaultBiMapper.serialize(sr);
  Role r1 = DefaultBiMapper.deserialize(serialized);
  Set<PublicKey> pubKeys = new HashSet<>();
  pubKeys.add(keys.get(0).getPublicKey());
  assertTrue(sr.isAllowedForKeys(pubKeys));
  assertTrue(r1.isAllowedForKeys(pubKeys));
  assertEquals(sr, r1);
}
origin: UniversaBlockchain/universa

@BeforeClass
public static void beforeClass() throws Exception {
  nodeConfig = new Config();
  nodeConfig.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
}
origin: UniversaBlockchain/universa

static Main createMain(String name,boolean nolog) throws InterruptedException {
  String path = new File("src/test_node_config_v2/"+name).getAbsolutePath();
  System.out.println(path);
  String[] args = new String[]{"--test", "--config", path, nolog ? "--nolog" : ""};
  Main main = new Main(args);
  try {
    main.config.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
  } catch (KeyAddress.IllegalAddressException e) {
    e.printStackTrace();
  }
  try {
    //main.config.getKeysWhiteList().add(CLIMain.getPrivateKey().getPublicKey());
    main.config.getAddressesWhiteList().add(new KeyAddress(CLIMain.getPrivateKey().getPublicKey(), 0, true));
  } catch (IOException e) {
    e.printStackTrace();
  }
  //main.config.getKeysWhiteList().add(main.config.getUIssuerKey());
  main.waitReady();
  return main;
}
origin: UniversaBlockchain/universa

@BeforeClass
public static void beforeClass() throws Exception {
  nodeConfig = new Config();
  nodeConfig.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
}
origin: UniversaBlockchain/universa

  @Test
  public void addWhiteListAddressTest() {
    Config config = new Config();
    PrivateKey randomKey = new PrivateKey(4096);
    KeyAddress keyAddr = new KeyAddress(randomKey.getPublicKey(), 0, true);

    config.getAddressesWhiteList().add(keyAddr);

    assertTrue(config.getAddressesWhiteList().contains(keyAddr));
  }
}
origin: UniversaBlockchain/universa

  @Test
  public void testCloneAsAddressRole() throws Exception {
    Set<KeyAddress> keyAddresses = new HashSet<>();
    keyAddresses.add(new KeyAddress(keys.get(0).getPublicKey(), 0, true));

    SimpleRole sr = new SimpleRole("tr1", keyAddresses);

    SimpleRole r1 = sr.cloneAs("tr2");
    SimpleRole r2 = r1.cloneAs("tr1");

    assertEquals(sr, r2);
  }
}
origin: UniversaBlockchain/universa

private void testMatch(boolean use384) throws KeyAddress.IllegalAddressException {
  KeyAddress a = key1.address(use384, 7);
  KeyAddress b = new KeyAddress(a.toString());
  assertEquals(7, b.getTypeMark());
  assertEquals(7, a.getTypeMark());
  assertTrue(b.isMatchingKey(key1));
  assertTrue(a.isMatchingKeyAddress(b));
  assertTrue(b.isMatchingKeyAddress(a));
  assertTrue(key1.isMatchingKey(key1));
  assertTrue(key1.isMatchingKeyAddress(a));
  assertTrue(key1.isMatchingKeyAddress(b));
  byte[] pack = a.getPacked();
  pack[7] ^= 71;
  try {
    new KeyAddress(pack);
    fail("must throw error on spoiled address");
  }
  catch(KeyAddress.IllegalAddressException e) {
  }
}
com.icodici.cryptoKeyAddress<init>

Javadoc

Build new KeyAddrAddress for a given key

Popular methods of KeyAddress

  • toString
    Get the packed string representaion. Uses Safe58 to encode data provided by the #getPacked()
  • isMatchingKey
    Check that the key matches this address, e.g. has of the same type and the digest of its components
  • getPacked
  • isLong
  • isMatchingKeyAddress
    Check that the address matches key information. It DOES NOT check the typeMark #getTypeMark()! If th
  • equals
  • getBiAdapter
  • getTypeMark
  • mask
    Each supported key has a mask that represents its type. The key that has no known mask can't be proc

Popular in Java

  • Finding current android device location
  • getApplicationContext (Context)
  • requestLocationUpdates (LocationManager)
  • addToBackStack (FragmentTransaction)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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