103 | * If optimized product of pairing is supported then 104 | * invoking the #pairing(Element[], Element[]) method should 105 | * guarantee better performance. 106 | * 107 | * @return true if optimized 108 | * product of pairing is supported, 109 | * false otherwise. 110 | * @see #pairing(Element[], Element[]) 111 | * @since 2.0.0 112 | */ 113 | boolean isProductPairingSupported(); 114 | 115 | /** 116 | * Computes the product of pairings, that is 117 | * 'e'('in1'[0], 'in2'[0]) ... 'e'('in1'[n-1], 'in2'[n-1]). 118 | * 119 | * @param in1 must have at least 'n' elements belonging to the groups G1 120 | * @param in2 must have at least 'n' elements belonging to the groups G2 121 | * @return the product of pairings, that is 'e'('in1'[0], 'in2'[0]) ... 'e'('in1'[n-1], 'in2'[n-1]). 122 | * @since 1.1.0 123 | */ 124 | Element pairing(Element[] in1, Element[] in2); 125 | 126 | /** 127 | * Returns the length in bytes needed to represent a PairingPreProcessing structure. 128 | * 129 | * @return the length in bytes needed to represent a PairingPreProcessing structure. 130 | * @see #getPairingPreProcessingFromBytes(byte[]) 131 | * @see #getPairingPreProcessingFromElement(Element) 132 | * @see PairingPreProcessing 133 | * @since 1.2.0 134 | */ 135 | int getPairingPreProcessingLengthInBytes(); 136 | 137 | /** 138 | * Get ready to perform a pairing whose first input is in1, returns the results of time-saving pre-computation. 139 | * 140 | * @param in1 the first input of a pairing execution, used to pre-compute the pairing. 141 | * @return the results of time-saving pre-computation. 142 | * @since 1.0.0 143 | */ 144 | PairingPreProcessing getPairingPreProcessingFromElement(Element in1); 145 | 146 | /** 147 | * Reads a PairingPreProcessing from the buffer source. 148 | * 149 | * @param source the source of bytes. 150 | * @return the PairingPreProcessing instance. 151 | * @since 1.2.0 152 | */ 153 | PairingPreProcessing getPairingPreProcessingFromBytes(byte[] source); 154 | 155 | /** 156 | * Reads a PairingPreProcessing from the buffer source starting from offset. 157 | * 158 | * @param source the source of bytes. 159 | * @param offset the starting offset. 160 | * @return the PairingPreProcessing instance. 161 | * @since 1.2.0 162 | */ 163 | PairingPreProcessing getPairingPreProcessingFromBytes(byte[] source, int offset); 164 | 165 | } 166 | -------------------------------------------------------------------------------- /src/main/java/it/unisa/dia/gas/jpbc/PairingParametersGenerator.java: -------------------------------------------------------------------------------- 1 | package it.unisa.dia.gas.jpbc; 2 | 3 | /** 4 | * This interface lets the user to generate all the necessary parameters 5 | * to initialize a pairing. 6 | * 7 | * @author Angelo De Caro (jpbclib@gmail.com) 8 | * @since 2.0.0 9 | */ 10 | public interface PairingParametersGenerator
{
11 |
12 | /**
13 | * Generates the parameters.
14 | *
15 | * @return a map with all the necessary parameters.
16 | * @since 2.0.0
17 | */
18 | P generate();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/it/unisa/dia/gas/jpbc/PairingPreProcessing.java:
--------------------------------------------------------------------------------
1 | package it.unisa.dia.gas.jpbc;
2 |
3 | /**
4 | * This interface is used to compute the pairing function when pre-processed information has
5 | * been compute before on the first input which is so fixed for each instance of this interface.
6 | *
7 | * @author Angelo De Caro (jpbclib@gmail.com)
8 | * @since 1.0.0
9 | */
10 | public interface PairingPreProcessing {
11 |
12 | /**
13 | * Compute the pairing where the second argument is in2. The pre-processed information
14 | * are used for a fast computation
15 | *
16 | * @param in2 the second pairing function argument.
17 | * @return an element from GT whose value is assigned by this map applied to in1 and in2.
18 | * @since 1.0.0
19 | */
20 | Element pairing(Element in2);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/it/unisa/dia/gas/jpbc/Point.java:
--------------------------------------------------------------------------------
1 | package it.unisa.dia.gas.jpbc;
2 |
3 | /**
4 | * This interface represents an element with two coordinates.
5 | * (A point over an elliptic curve).
6 | *
7 | * @author Angelo De Caro (jpbclib@gmail.com)
8 | * @since 1.0.0
9 | */
10 | public interface Point