public static byte[] varInt(long value) { ByteBuffer buffer = ByteBuffer.allocate(9); varInt(value, buffer); buffer.flip(); return Bytes.truncate(buffer.array(), buffer.limit()); }
public PrivateKey(long version, long stream, String passphrase, long nonceTrialsPerByte, long extraBytes, Pubkey.Feature... features) { try { // FIXME: this is most definitely wrong this.privateSigningKey = Bytes.truncate(Security.sha512(passphrase.getBytes("UTF-8"), new byte[]{0}), 32); this.privateEncryptionKey = Bytes.truncate(Security.sha512(passphrase.getBytes("UTF-8"), new byte[]{1}), 32); this.pubkey = Security.createPubkey(version, stream, privateSigningKey, privateEncryptionKey, nonceTrialsPerByte, extraBytes, features); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
public InventoryVector getInventoryVector() { return new InventoryVector(Bytes.truncate(Security.doubleSha512(nonce, getPayloadBytesWithoutNonce()), 32)); }
public InventoryVector getInventoryVector() { return new InventoryVector( Bytes.truncate(cryptography().doubleSha512(nonce, getPayloadBytesWithoutNonce()), 32) ); }
Builder generate() { long signingKeyNonce = nextNonce; long encryptionKeyNonce = nextNonce + 1; byte[] ripe; do { privEK = Bytes.truncate(cryptography().sha512(seed, Encode.varInt(encryptionKeyNonce)), 32); privSK = Bytes.truncate(cryptography().sha512(seed, Encode.varInt(signingKeyNonce)), 32); pubSK = cryptography().createPublicKey(privSK); pubEK = cryptography().createPublicKey(privEK); ripe = cryptography().ripemd160(cryptography().sha512(pubSK, pubEK)); signingKeyNonce += 2; encryptionKeyNonce += 2; } while (ripe[0] != 0 || (shorter && ripe[1] != 0)); nextNonce = signingKeyNonce; return this; } }