Closed xfaber closed 4 months ago
If the value of G2 is the form (x, y), set "1
If the string format is big-endian, you must reverse each Fp element. e.g., 0x123456 => 0x563412 .
If you get the string from the other library, and if the library supports ETH specification, then it is better to use Deserialize() for the other library output of serialize() after calling ETHmode() once.
The PKhexstring is a compressed PK form (bigendian)
Then, could you use PK.Deserialize
to the data by the following FromHexStr
, for example?
public static byte[] FromHexStr(string s)
{
if (s.Length % 2 == 1) {
throw new ArgumentException("s.Length is odd." + s.Length);
}
int n = s.Length / 2;
var buf = new byte[n];
for (int i = 0; i < n; i++) {
buf[i] = Convert.ToByte(s.Substring(i * 2, 2), 16);
}
return buf;
}
I want to set a PK to this value (with curve BLS12-381) "0xa0b862a7527fee3a731bcb59280ab6abd62d5c0b6ea03dc4ddf6612fdfc9d01f01c315425 41771903475eb1ec6615f8d0df0b8b6dce385811d6dcf8cbefb8759e5e616a3dfd054c928940 766d9a5b9db91e3b697e5d70a975181e007f87fca5e" after the SetStr, the value is zero. Is there any problem with the length of the value?
var PKhexstring = "0xa0b862a7527fee3a731bcb59280ab6abd62d5c0b6ea03dc4ddf6612fdfc9d01f01c315425 41771903475eb1ec6615f8d0df0b8b6dce385811d6dcf8cbefb8759e5e616a3dfd054c928940 766d9a5b9db91e3b697e5d70a975181e007f87fca5e"; var PK = new G2(); PK.SetStr(PKhexstring, 16); var check = PK.IsValid(); //=TRUE var check0 = PK.IsZero(); //=TRUE
How I can set the value PKhexstring? Thanks for your help. F