Closed jesili closed 3 weeks ago
And i try the serialize function as follows, i found the result is wrong
G1 g1 = new G1();
G1 g = new G1();
g.deserialize(g1.serialize());
the value of g is not equal to g1 1 5599143398083935610374186532129481627143475178919331168509268578950374510890 5294742852547101856655570981746608842116104296916941421017505945925887545842 1 5599143398083935610374186532129481627143475178919331168509268578950374510890 11421454753289275224544372032360862587343389120178789031181440418017766282028
new G1()
is an undefined value, so you must set a correct one.
I tested the following code, and it runs well.
import java.io.*;
import com.herumi.mcl.*;
public class Test {
static {
String lib = "mcljava";
String libName = System.mapLibraryName(lib);
System.out.println("libName : " + libName);
System.loadLibrary(lib);
}
public static void main(String argv[]) {
Mcl.SystemInit(Mcl.BN254);
Fr p = new Fr();
p.setByCSPRNG();
G1 g1 = new G1();
Mcl.hashAndMapToG1(g1, p.serialize());
G1 g2 = new G1();
g2.deserialize(g1.serialize());
System.out.println(g1.toString());
System.out.println(g2.toString());
}
}
1 14718852485654364492067555047143452070543907868063243005495748641434978195525 5910875915294437084092313525811835145506598652254003876466078788996519963173
1 14718852485654364492067555047143452070543907868063243005495748641434978195525 5910875915294437084092313525811835145506598652254003876466078788996519963173
Thank you very much, i read the test file and find the reason of my wrong. Now i have my code works, and it's very fast than using JPBC.
I just got the following error, java.io.NotSerializableException: com.herumi.mcl.G1, I define a class that contains G1 and Fr elements, I want to serialize this class to a file and deserialize it