|
|
@ -321,9 +321,16 @@ struct Test { |
|
|
|
|
|
|
|
|
|
|
|
void conv() |
|
|
|
void conv() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const char *bin = "0b100100011010001010110011110001001000000010010001101000101011001111000100100000001001000110100010101100111100010010000"; |
|
|
|
const char *bin, *hex, *dec; |
|
|
|
const char *hex = "0x123456789012345678901234567890"; |
|
|
|
if (Fp::getBitSize() <= 117) { |
|
|
|
const char *dec = "94522879687365475552814062743484560"; |
|
|
|
bin = "0b10000000000000000000000000000000000000000000000000000000000001110"; |
|
|
|
|
|
|
|
hex = "0x1000000000000000e"; |
|
|
|
|
|
|
|
dec = "18446744073709551630"; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
bin = "0b100100011010001010110011110001001000000010010001101000101011001111000100100000001001000110100010101100111100010010000"; |
|
|
|
|
|
|
|
hex = "0x123456789012345678901234567890"; |
|
|
|
|
|
|
|
dec = "94522879687365475552814062743484560"; |
|
|
|
|
|
|
|
} |
|
|
|
Fp b(bin); |
|
|
|
Fp b(bin); |
|
|
|
Fp h(hex); |
|
|
|
Fp h(hex); |
|
|
|
Fp d(dec); |
|
|
|
Fp d(dec); |
|
|
@ -623,6 +630,12 @@ CYBOZU_TEST_AUTO(test) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Test test; |
|
|
|
Test test; |
|
|
|
const char *tbl[] = { |
|
|
|
const char *tbl[] = { |
|
|
|
|
|
|
|
// N = 2
|
|
|
|
|
|
|
|
"0x0000000000000001000000000000000d", |
|
|
|
|
|
|
|
"0x7fffffffffffffffffffffffffffffff", |
|
|
|
|
|
|
|
"0x8000000000000000000000000000001d", |
|
|
|
|
|
|
|
"0xffffffffffffffffffffffffffffff61", |
|
|
|
|
|
|
|
|
|
|
|
// N = 3
|
|
|
|
// N = 3
|
|
|
|
"0x000000000000000100000000000000000000000000000033", // min prime
|
|
|
|
"0x000000000000000100000000000000000000000000000033", // min prime
|
|
|
|
"0x00000000fffffffffffffffffffffffffffffffeffffac73", |
|
|
|
"0x00000000fffffffffffffffffffffffffffffffeffffac73", |
|
|
|