Java Code Examples for org.apache.tuweni.bytes.Bytes#mutableCopy()
The following examples show how to use
org.apache.tuweni.bytes.Bytes#mutableCopy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PeerDiscoveryPacketSedesTest.java From besu with Apache License 2.0 | 6 votes |
@Test(expected = PeerDiscoveryPacketDecodingException.class) public void integrityCheckFailsUnmatchedHash() { final byte[] r = new byte[64]; new Random().nextBytes(r); final Bytes target = Bytes.wrap(r); final NodeKey nodeKey = NodeKeyUtils.generate(); final FindNeighborsPacketData data = FindNeighborsPacketData.create(target); final Packet packet = Packet.create(PacketType.FIND_NEIGHBORS, data, nodeKey); final Bytes encoded = Bytes.wrapBuffer(packet.encode()); final MutableBytes garbled = encoded.mutableCopy(); final int i = garbled.size() - 1; // Change one bit in the last byte, which belongs to the payload, hence the hash will not match // any longer. garbled.set(i, (byte) (garbled.get(i) + 0x01)); Packet.decode(Buffer.buffer(garbled.toArray())); }
Example 2
Source File: LogsBloomFilter.java From incubator-tuweni with Apache License 2.0 | 5 votes |
public LogsBloomFilter(Bytes data) { checkArgument( data.size() == 256, "Invalid size for bloom filter backing array: expected 256 but got %s", data.size()); this.data = data.mutableCopy(); }
Example 3
Source File: SecureScuttlebuttStream.java From incubator-tuweni with Apache License 2.0 | 5 votes |
SecureScuttlebuttStream( SHA256Hash.Hash clientToServerKey, Bytes clientToServerNonce, SHA256Hash.Hash serverToClientKey, Bytes serverToClientNonce) { this.clientToServerKey = SecretBox.Key.fromHash(clientToServerKey); this.serverToClientKey = SecretBox.Key.fromHash(serverToClientKey); this.clientToServerNonce = clientToServerNonce.mutableCopy(); this.serverToClientNonce = serverToClientNonce.mutableCopy(); }