congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
KeyAddress.toString
Code IndexAdd Tabnine to your IDE (free)

How to use
toString
method
in
com.icodici.crypto.KeyAddress

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

origin: UniversaBlockchain/universa

@Override
public int hashCode() {
  return toString().hashCode();
}
origin: UniversaBlockchain/universa

/**
 * Get all addresses, used by this role. For public keys returns addresses too.
 * @deprecated the only usable check allowance method is isAllowedForKeys
 * @return list of strings with addresses
 */
@Deprecated
public List<String> getAllAddresses() {
  List<String> res = new ArrayList<>();
  getKeyAddresses().forEach(ka -> res.add(ka.toString()));
  getKeys().forEach(publicKey -> res.add(publicKey.getShortAddress().toString()));
  return res;
}
origin: UniversaBlockchain/universa

private List<String> getAddressesToCheck() {
  Set<String> addresses = new HashSet<>();
  for (UnsName unsName : storedNames)
    for (UnsRecord unsRecord : unsName.getUnsRecords())
      for (KeyAddress keyAddress : unsRecord.getAddresses())
        addresses.add(keyAddress.toString());
  for (Approvable revoked : getRevokingItems())
    removeRevokedAddresses(revoked, addresses);
  return new ArrayList<>(addresses);
}
origin: UniversaBlockchain/universa

private void removeRevokedAddresses(Approvable approvable, Set<String> set) {
  if (approvable instanceof UnsContract) {
    UnsContract unsContract = (UnsContract) approvable;
    for (UnsName unsName : unsContract.storedNames)
      for (UnsRecord unsRecord : unsName.getUnsRecords())
        for (KeyAddress keyAddress : unsRecord.getAddresses())
          set.remove(keyAddress.toString());
  }
  for (Approvable revoked : approvable.getRevokingItems())
    removeRevokedAddresses(revoked, set);
}
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

public NNameRecord(@NonNull UnsName unsName, @NonNull ZonedDateTime expiresAt) {
  name = unsName.getUnsName();
  nameReduced = unsName.getUnsReducedName();
  description = unsName.getUnsDescription();
  url = unsName.getUnsURL();
  this.expiresAt = expiresAt;
  unsName.getUnsRecords().forEach(unsRecord -> {
    String longAddress = null;
    String shortAddress = null;
    for (KeyAddress keyAddress : unsRecord.getAddresses()) {
      if (keyAddress.isLong())
        longAddress = keyAddress.toString();
      else
        shortAddress = keyAddress.toString();
    }
    entries.add(new NNameRecordEntry(unsRecord.getOrigin(), shortAddress, longAddress));
  });
}
origin: UniversaBlockchain/universa

for(KeyAddress keyAddress : getAddresses()) {
  if(keyAddress.isLong())
    longAddress = keyAddress.toString();
  else
    shortAddress = keyAddress.toString();
origin: UniversaBlockchain/universa

@Test
public void getAllAddresses() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  ListRole owner = new ListRole("owner");
  owner.addRole(new SimpleRole("owner", Arrays.asList(TestKeys.publicKey(0), TestKeys.publicKey(1))));
  owner.addRole(new SimpleRole("owner", Arrays.asList(TestKeys.publicKey(2).getLongAddress())));
  owner.addRole(new SimpleRole("owner", Arrays.asList(TestKeys.publicKey(3).getShortAddress(), TestKeys.publicKey(4))));
  contract.registerRole(owner);
  List<String> addresses = contract.getRole("owner").getAllAddresses();
  System.out.println("owner: " + addresses);
  for (String addr : addresses)
    assertThat(addr, Matchers.anyOf(
        Matchers.equalTo(TestKeys.publicKey(0).getShortAddress().toString()),
        Matchers.equalTo(TestKeys.publicKey(1).getShortAddress().toString()),
        Matchers.equalTo(TestKeys.publicKey(2).getLongAddress().toString()),
        Matchers.equalTo(TestKeys.publicKey(3).getShortAddress().toString()),
        Matchers.equalTo(TestKeys.publicKey(4).getShortAddress().toString())
    ));
}
origin: UniversaBlockchain/universa

@Test
public void testModifyDataPermission() throws Exception {
  KeyAddress k0 = TestKeys.publicKey(0).getShortAddress();
  Contract contract = new Contract(TestKeys.privateKey(0));
  String js = "";
  js += "print('testModifyDataPermission');";
  js += "var simpleRole = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"');";
  js += "var modifyDataPermission = jsApi.getPermissionBuilder().createModifyDataPermission(simpleRole, " +
      "{some_field: [1, 2, 3]});";
  js += "result = modifyDataPermission;";
  contract.getDefinition().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters());
  contract.seal();
  JSApiPermission res = (JSApiPermission) contract.execJS(js.getBytes());
  ModifyDataPermission changeOwnerPermission = (ModifyDataPermission)res.extractPermission(new JSApiAccessor());
  ModifyDataPermission sample = new ModifyDataPermission(new SimpleRole("test"), Binder.of("fields", Binder.of("some_field", Arrays.asList(1, 2, 3))));
  Field field = Permission.class.getDeclaredField("name");
  field.setAccessible(true);
  assertEquals(field.get(sample), field.get(changeOwnerPermission));
  field = ModifyDataPermission.class.getDeclaredField("fields");
  field.setAccessible(true);
  assertEquals(field.get(sample), field.get(changeOwnerPermission));
}
origin: UniversaBlockchain/universa

@Test
public void testRevokePermission() throws Exception {
  KeyAddress k0 = TestKeys.publicKey(0).getShortAddress();
  Contract contract = new Contract(TestKeys.privateKey(0));
  String js = "";
  js += "print('testRevokePermission');";
  js += "var simpleRole = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"');";
  js += "var revokePermission = jsApi.getPermissionBuilder().createRevokePermission(simpleRole);";
  js += "result = revokePermission;";
  contract.getDefinition().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters());
  contract.seal();
  JSApiPermission res = (JSApiPermission) contract.execJS(js.getBytes());
  RevokePermission revokePermission = (RevokePermission)res.extractPermission(new JSApiAccessor());
  RevokePermission sample = new RevokePermission(new SimpleRole("test"));
  Field field = Permission.class.getDeclaredField("name");
  field.setAccessible(true);
  assertEquals(field.get(sample), field.get(revokePermission));
}
origin: UniversaBlockchain/universa

@Test
public void testChangeOwnerPermission() throws Exception {
  KeyAddress k0 = TestKeys.publicKey(0).getShortAddress();
  Contract contract = new Contract(TestKeys.privateKey(0));
  String js = "";
  js += "print('testChangeOwnerPermission');";
  js += "var simpleRole = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"');";
  js += "var changeOwnerPermission = jsApi.getPermissionBuilder().createChangeOwnerPermission(simpleRole);";
  js += "result = changeOwnerPermission;";
  contract.getDefinition().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters());
  contract.seal();
  JSApiPermission res = (JSApiPermission) contract.execJS(js.getBytes());
  ChangeOwnerPermission changeOwnerPermission = (ChangeOwnerPermission)res.extractPermission(new JSApiAccessor());
  ChangeOwnerPermission sample = new ChangeOwnerPermission(new SimpleRole("test"));
  Field field = Permission.class.getDeclaredField("name");
  field.setAccessible(true);
  assertEquals(field.get(sample), field.get(changeOwnerPermission));
}
origin: UniversaBlockchain/universa

String js = "";
js += "print('testSplitJoinPermission');";
js += "var simpleRole = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"');";
js += "var splitJoinPermission = jsApi.getPermissionBuilder().createSplitJoinPermission(simpleRole, " +
    "{field_name: 'testval', min_value: 33, min_unit: 1e-7, join_match_fields: ['state.origin']}" +
origin: UniversaBlockchain/universa

@Test
public void testSimpleRoleCheck() throws Exception {
  KeyAddress k0 = TestKeys.publicKey(0).getShortAddress();
  KeyAddress k1 = TestKeys.publicKey(1).getShortAddress();
  KeyAddress k2 = TestKeys.publicKey(2).getShortAddress();
  String p0 = TestKeys.publicKey(0).packToBase64String();
  String p1 = TestKeys.publicKey(1).packToBase64String();
  String p2 = TestKeys.publicKey(2).packToBase64String();
  Contract contract = new Contract(TestKeys.privateKey(0));
  String js = "";
  js += "print('testSimpleRoleCheck');";
  js += "var simpleRole = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"', '"+k1.toString()+"', '"+k2.toString()+"');";
  js += "var check0 = simpleRole.isAllowedForKeys(jsApi.base64toPublicKey('"+p0+"'), jsApi.base64toPublicKey('"+p1+"'));";
  js += "var check1 = simpleRole.isAllowedForKeys(jsApi.base64toPublicKey('"+p0+"'), jsApi.base64toPublicKey('"+p1+"'), jsApi.base64toPublicKey('"+p2+"'));";
  js += "print('check0: ' + check0);";
  js += "print('check1: ' + check1);";
  js += "result = [check0, check1];";
  JSApiScriptParameters scriptParameters = new JSApiScriptParameters();
  contract.getDefinition().setJS(js.getBytes(), "client script.js", scriptParameters);
  contract.seal();
  ScriptObjectMirror res = (ScriptObjectMirror)contract.execJS(js.getBytes());
  assertFalse((boolean)res.get("0"));
  assertTrue((boolean)res.get("1"));
}
origin: UniversaBlockchain/universa

String js = "";
js += "print('testListRoleCheckAll');";
js += "var simpleRole0 = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"');";
js += "var simpleRole1 = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k1.toString()+"');";
js += "var simpleRole2 = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k2.toString()+"');";
js += "var simpleRole3 = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k3.toString()+"');";
js += "var listSubRole = jsApi.getRoleBuilder().createListRole('listRole', 'all', simpleRole2, simpleRole3);";
js += "var listRole = jsApi.getRoleBuilder().createListRole('listRole', 'all', simpleRole0, simpleRole1, listSubRole);";
origin: UniversaBlockchain/universa

@Test
public void jsInContract() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.setOwnerKeys(TestKeys.publicKey(1), TestKeys.publicKey(2), TestKeys.publicKey(3));
  contract.setCreatorKeys(TestKeys.publicKey(4), TestKeys.publicKey(5).getLongAddress());
  System.out.println("testKey[10].getShortAddress: " + TestKeys.publicKey(10).getShortAddress().toString());
  System.out.println("testKey[11].getShortAddress: " + TestKeys.publicKey(11).getShortAddress().toString());
  contract.getStateData().set("some_value", HashId.createRandom().toBase64String());
  contract.getStateData().set("some_hash_id", HashId.createRandom());
  String js = "";
  js += "print('hello world');";
  js += "var currentContract = jsApi.getCurrentContract();";
  js += "print('currentContract.getId(): ' + currentContract.getId());";
  js += "print('currentContract.getRevision(): ' + currentContract.getRevision());";
  js += "print('currentContract.getCreatedAt(): ' + currentContract.getCreatedAt());";
  js += "print('currentContract.getOrigin(): ' + currentContract.getOrigin());";
  js += "print('currentContract.getParent(): ' + currentContract.getParent());";
  js += "print('currentContract.getStateDataField(some_value): ' + currentContract.getStateDataField('some_value'));";
  js += "print('currentContract.getStateDataField(some_hash_id): ' + currentContract.getStateDataField('some_hash_id'));";
  js += "print('currentContract.getDefinitionDataField(scripts): ' + currentContract.getDefinitionDataField('scripts'));";
  js += "print('currentContract.getIssuer(): ' + currentContract.getIssuer());";
  js += "print('currentContract.getOwner(): ' + currentContract.getOwner());";
  js += "print('currentContract.getCreator(): ' + currentContract.getCreator());";
  js += "print('call currentContract.setOwner()...');";
  js += "currentContract.setOwner(['ZastWpWNPMqvVJAMocsMUTJg45i8LoC5Msmr7Lt9EaJJRwV2xV', 'a1sxhjdtGhNeji8SWJNPkwV5m6dgWfrQBnhiAxbQwZT6Y5FsXD']);";
  js += "print('currentContract.getOwner(): ' + currentContract.getOwner());";
  contract.getDefinition().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters());
  contract.seal();
  contract.execJS(js.getBytes());
}
origin: UniversaBlockchain/universa

@Test
public void testSimpleRole() throws Exception {
  KeyAddress k0 = TestKeys.publicKey(0).getShortAddress();
  KeyAddress k1 = TestKeys.publicKey(1).getShortAddress();
  KeyAddress k2 = TestKeys.publicKey(2).getShortAddress();
  KeyAddress k3 = TestKeys.publicKey(3).getShortAddress();
  Contract contract = new Contract(TestKeys.privateKey(0));
  String js = "";
  js += "print('testSimpleRole');";
  js += "var simpleRole = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"', '"+k1.toString()+"', '"+k2.toString()+"');";
  js += "result = simpleRole;";
  JSApiScriptParameters scriptParameters = new JSApiScriptParameters();
  contract.getDefinition().setJS(js.getBytes(), "client script.js", scriptParameters);
  contract.seal();
  JSApiRole res = (JSApiRole)contract.execJS(js.getBytes());
  assertTrue(res.isAllowedForKeys(TestKeys.publicKey(0), TestKeys.publicKey(1), TestKeys.publicKey(2)));
  assertFalse(res.isAllowedForKeys(TestKeys.publicKey(0)));
  assertFalse(res.isAllowedForKeys(TestKeys.publicKey(1)));
  assertFalse(res.isAllowedForKeys(TestKeys.publicKey(2)));
  assertFalse(res.isAllowedForKeys(TestKeys.publicKey(3)));
}
origin: UniversaBlockchain/universa

@Test
public void testListRole() throws Exception {
  KeyAddress k0 = TestKeys.publicKey(0).getShortAddress();
  KeyAddress k1 = TestKeys.publicKey(1).getShortAddress();
  KeyAddress k2 = TestKeys.publicKey(2).getShortAddress();
  KeyAddress k3 = TestKeys.publicKey(3).getShortAddress();
  Contract contract = new Contract(TestKeys.privateKey(0));
  String js = "";
  js += "print('testListRole');";
  js += "var simpleRole0 = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"');";
  js += "var simpleRole1 = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k1.toString()+"');";
  js += "var simpleRole2 = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k2.toString()+"');";
  js += "var listRole = jsApi.getRoleBuilder().createListRole('listRole', 'all', simpleRole0, simpleRole1, simpleRole2);";
  js += "result = listRole;";
  JSApiScriptParameters scriptParameters = new JSApiScriptParameters();
  contract.getDefinition().setJS(js.getBytes(), "client script.js", scriptParameters);
  contract.seal();
  JSApiRole res = (JSApiRole)contract.execJS(js.getBytes());
  assertTrue(res.isAllowedForKeys(TestKeys.publicKey(0), TestKeys.publicKey(1), TestKeys.publicKey(2)));
  assertFalse(res.isAllowedForKeys(TestKeys.publicKey(0)));
  assertFalse(res.isAllowedForKeys(TestKeys.publicKey(1)));
  assertFalse(res.isAllowedForKeys(TestKeys.publicKey(2)));
  assertFalse(res.isAllowedForKeys(TestKeys.publicKey(3)));
}
origin: UniversaBlockchain/universa

@Test
public void jsAddPermission() throws Exception {
  TestSpace testSpace = prepareTestSpace(TestKeys.privateKey(0));
  testSpace.nodes.forEach(m -> m.config.setIsFreeRegistrationsAllowedFromYaml(true));
  KeyAddress k0 = TestKeys.publicKey(0).getShortAddress();
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.getStateData().set("testval", 3);
  String js = "";
  js += "print('addPermission');";
  js += "var simpleRole = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"');";
  js += "var changeNumberPermission = jsApi.getPermissionBuilder().createChangeNumberPermission(simpleRole, " +
      "{field_name: 'testval', min_value: 3, max_value: 80, min_step: 1, max_step: 3}" +
      ");";
  js += "jsApi.getCurrentContract().addPermission(changeNumberPermission);";
  contract.getState().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters());
  contract.execJS(js.getBytes());
  contract.seal();
  ItemResult ir = testSpace.client.register(contract.getPackedTransaction(), 5000);
  assertEquals(ItemState.APPROVED, ir.state);
  Contract newRev = contract.createRevision();
  newRev.addSignerKey(TestKeys.privateKey(0));
  newRev.getStateData().set("testval", 5);
  newRev.seal();
  ir = testSpace.client.register(newRev.getPackedTransaction(), 5000);
  assertEquals(ItemState.APPROVED, ir.state);
  testSpace.nodes.forEach(m -> m.shutdown());
}
origin: UniversaBlockchain/universa

@Test
public void references() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  String js = "";
  js += "print('references');";
  js += "var ref = jsApi.getReferenceBuilder().createReference('EXISTING_STATE');";
  js += "ref.setConditions({'all_of':['ref.issuer=="+TestKeys.publicKey(1).getShortAddress().toString()+"']});";
  js += "jsApi.getCurrentContract().addReference(ref);";
  contract.getState().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters());
  contract.seal();
  contract = Contract.fromPackedTransaction(contract.getPackedTransaction());
  Contract batchContract = new Contract(TestKeys.privateKey(3));
  batchContract.addNewItems(contract);
  batchContract.seal();
  assertTrue(batchContract.check());
  contract.execJS(new JSApiExecOptions(), js.getBytes());
  contract.seal();
  batchContract.seal();
  assertFalse(batchContract.check());
}
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.cryptoKeyAddresstoString

Javadoc

Get the packed string representaion. Uses Safe58 to encode data provided by the #getPacked()

Popular methods of KeyAddress

  • <init>
    Unpack an address. After construction, use #getTypeMark() and #isMatchingKey(AbstractKey) methods to
  • 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

  • Making http post requests using okhttp
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Notification (javax.management)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top 17 Free Sublime Text Plugins
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