Search in sources :

Example 6 with Bytes48

use of org.apache.tuweni.bytes.Bytes48 in project teku by ConsenSys.

the class BLSTest method fastAggregateVerify_verify4Signers.

@Test
void fastAggregateVerify_verify4Signers() {
    Bytes message = Bytes.fromHexString("0x999bb85f3690c2ccb1607dd3e11a7e114038eb4044bdbdd340bc81aa3e5e0c9e");
    List<BLSPublicKey> publicKeys = Stream.of("0x97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb", "0xa572cbea904d67468808c8eb50a9450c9721db309128012543902d0ac358a62ae28f75bb8f1c7c42c39a8c5529bf0f4e", "0x89ece308f9d1f0131765212deca99697b112d61f9be9a5f1f3780a51335b3ff981747a0b2ca2179b96d2c0c9024e5224", "0xac9b60d5afcbd5663a8a44b7c5a02f19e9a77ab0a35bd65809bb5c67ec582c897feb04decc694b13e08587f3ff9b5b60").map(pk -> BLSPublicKey.fromBytesCompressedValidate(Bytes48.fromHexString(pk))).collect(Collectors.toList());
    BLSSignature aggregatedSignature = BLSSignature.fromBytesCompressed(Bytes.fromHexString("0xb2550663aa862b2741c9abc94f7b0b8a725b6f12b8f214d833e214e87c64235e4b1fb1e1ee64e5ae942cb3e0392699fc0524ae6f35072d1f243668de730be8745ab5be3314f90c107e246cefd1f1b97cd7241cfe97f4c80aeb354e8fac2ea720"));
    assertTrue(BLS.fastAggregateVerify(publicKeys, message, aggregatedSignature));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Arrays(java.util.Arrays) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Bytes(org.apache.tuweni.bytes.Bytes) Collectors(java.util.stream.Collectors) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) Stream(java.util.stream.Stream) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Bytes48(org.apache.tuweni.bytes.Bytes48) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Bytes32(org.apache.tuweni.bytes.Bytes32) Bytes(org.apache.tuweni.bytes.Bytes) Test(org.junit.jupiter.api.Test)

Example 7 with Bytes48

use of org.apache.tuweni.bytes.Bytes48 in project teku by ConsenSys.

the class BlstPublicKeyTest method infinityPublicKey.

// The infinite public key is now considered to be invalid
@Test
void infinityPublicKey() {
    Bytes48 infinitePublicKeyBytes = Bytes48.fromHexString("0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
    assertThatThrownBy(() -> {
        BlstPublicKey publicKey = BlstPublicKey.fromBytes(infinitePublicKeyBytes);
        publicKey.forceValidation();
    }).isInstanceOf(IllegalArgumentException.class);
}
Also used : Bytes48(org.apache.tuweni.bytes.Bytes48) Test(org.junit.jupiter.api.Test) AbstractPublicKeyTest(tech.pegasys.teku.bls.impl.AbstractPublicKeyTest)

Aggregations

Bytes48 (org.apache.tuweni.bytes.Bytes48)7 Test (org.junit.jupiter.api.Test)5 AbstractPublicKeyTest (tech.pegasys.teku.bls.impl.AbstractPublicKeyTest)2 IOException (java.io.IOException)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Bytes (org.apache.tuweni.bytes.Bytes)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 Cipher (tech.pegasys.signers.bls.keystore.model.Cipher)1 KdfParam (tech.pegasys.signers.bls.keystore.model.KdfParam)1 KeyStoreData (tech.pegasys.signers.bls.keystore.model.KeyStoreData)1