@Test void fuzzShuffle_insufficientInput() { final FuzzUtil fuzzUtil = new FuzzUtil(true, true); byte[] emptyInput = new byte[0]; assertThat(fuzzUtil.fuzzShuffle(emptyInput)).isEmpty(); assertThat(fuzzUtil.fuzzShuffle(Bytes.random(15).toArrayUnsafe())).isEmpty(); assertThat(fuzzUtil.fuzzShuffle(Bytes.random(33).toArrayUnsafe())).isEmpty(); }
public Optional<byte[]> fuzzShuffle(final byte[] input) { if (input.length < (32 + 2)) { return Optional.empty(); } int count = ((int) (0xFFFFFFFFL & BeaconStateUtil.bytes_to_int64(Bytes.wrap(input, 0, 2)))) % 100; Bytes32 seed = Bytes32.wrap(input, 2); ByteBuffer result_bb = ByteBuffer.allocate(count * OUTPUT_INDEX_BYTES); result_bb.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < count; i++) { result_bb.putLong(CommitteeUtil.compute_shuffled_index(i, count, seed)); } return Optional.of(result_bb.array()); }
FuzzUtil { public Optional<byte[]> fuzzShuffle(final byte[] input) { if (input.length < (32 + 2)) { return Optional.empty(); } int count = ((int) (0xFFFFFFFFL & BeaconStateUtil.bytes_to_int64(Bytes.wrap(input, 0, 2)))) % 100; Bytes32 seed = Bytes32.wrap(input, 2); ByteBuffer result_bb = ByteBuffer.allocate(count * OUTPUT_INDEX_BYTES); result_bb.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < count; i++) { result_bb.putLong(CommitteeUtil.compute_shuffled_index(i, count, seed)); } return Optional.of(result_bb.array()); } }
FuzzUtil { public Optional<byte[]> fuzzShuffle(final byte[] input) { if (input.length < (32 + 2)) { return Optional.empty(); } int count = ((int) (0xFFFFFFFFL & BeaconStateUtil.bytes_to_int64(Bytes.wrap(input, 0, 2)))) % 100; Bytes32 seed = Bytes32.wrap(input, 2); ByteBuffer result_bb = ByteBuffer.allocate(count * OUTPUT_INDEX_BYTES); result_bb.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < count; i++) { result_bb.putLong(CommitteeUtil.compute_shuffled_index(i, count, seed)); } return Optional.of(result_bb.array()); } FuzzUtil(final boolean useMainnetConfig, final boolean disable_bls); }
FuzzUtil { public Optional<byte[]> fuzzShuffle(final byte[] input) { if (input.length < (32 + 2)) { return Optional.empty(); } int count = ((int) (0xFFFFFFFFL & BeaconStateUtil.bytes_to_int64(Bytes.wrap(input, 0, 2)))) % 100; Bytes32 seed = Bytes32.wrap(input, 2); ByteBuffer result_bb = ByteBuffer.allocate(count * OUTPUT_INDEX_BYTES); result_bb.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < count; i++) { result_bb.putLong(CommitteeUtil.compute_shuffled_index(i, count, seed)); } return Optional.of(result_bb.array()); } FuzzUtil(final boolean useMainnetConfig, final boolean disable_bls); static void initialize(final boolean useMainnetConfig, final boolean disable_bls); Optional<byte[]> fuzzAttestation(final byte[] input); Optional<byte[]> fuzzAttesterSlashing(final byte[] input); Optional<byte[]> fuzzBlock(final byte[] input); Optional<byte[]> fuzzBlockHeader(final byte[] input); Optional<byte[]> fuzzDeposit(final byte[] input); Optional<byte[]> fuzzProposerSlashing(final byte[] input); Optional<byte[]> fuzzShuffle(final byte[] input); Optional<byte[]> fuzzVoluntaryExit(final byte[] input); }
FuzzUtil { public Optional<byte[]> fuzzShuffle(final byte[] input) { if (input.length < (32 + 2)) { return Optional.empty(); } int count = ((int) (0xFFFFFFFFL & BeaconStateUtil.bytes_to_int64(Bytes.wrap(input, 0, 2)))) % 100; Bytes32 seed = Bytes32.wrap(input, 2); ByteBuffer result_bb = ByteBuffer.allocate(count * OUTPUT_INDEX_BYTES); result_bb.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < count; i++) { result_bb.putLong(CommitteeUtil.compute_shuffled_index(i, count, seed)); } return Optional.of(result_bb.array()); } FuzzUtil(final boolean useMainnetConfig, final boolean disable_bls); static void initialize(final boolean useMainnetConfig, final boolean disable_bls); Optional<byte[]> fuzzAttestation(final byte[] input); Optional<byte[]> fuzzAttesterSlashing(final byte[] input); Optional<byte[]> fuzzBlock(final byte[] input); Optional<byte[]> fuzzBlockHeader(final byte[] input); Optional<byte[]> fuzzDeposit(final byte[] input); Optional<byte[]> fuzzProposerSlashing(final byte[] input); Optional<byte[]> fuzzShuffle(final byte[] input); Optional<byte[]> fuzzVoluntaryExit(final byte[] input);  }