Skip to content

Commit

Permalink
test of DFINITY parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Apr 4, 2023
1 parent 1a423b6 commit 88defaa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ffi/cs/bls_test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,31 @@ static void TestAreAllMsgDifferent()
assert("verify", AreAllMsgDifferent(msgVec) == t.expected);
}
}
static void TestDFINITY()
{
Console.WriteLine("TestDFINITY");
// it is alread called in Main
// Init(BLS12_381);
SetETHserialization(true);
SetMapToMode(MapToMode.HashToCurve);
PublicKey gen = new PublicKey();
gen.SetStr("1 0x24aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8 0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e 0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801 0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be");
SetGeneratorOfPublicKey(ref gen);
SetDstG1("BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_");

// end of init for DFINITY


// test of https://github.com/dfinity/agent-js/blob/5214dc1fc4b9b41f023a88b1228f04d2f2536987/packages/bls-verify/src/index.test.ts#L101
String pubStr = "a7623a93cdb56c4d23d99c14216afaab3dfd6d4f9eb3db23d038280b6d5cb2caaee2a19dd92c9df7001dede23bf036bc0f33982dfb41e8fa9b8e96b5dc3e83d55ca4dd146c7eb2e8b6859cb5a5db815db86810b8d12cee1588b5dbf34a4dc9a5";
String sigStr = "b89e13a212c830586eaa9ad53946cd968718ebecc27eda849d9232673dcd4f440e8b5df39bf14a88048c15e16cbcaabe";
PublicKey pub = new PublicKey();
Signature sig = new Signature();
pub.Deserialize(FromHexStr(pubStr));
sig.Deserialize(FromHexStr(sigStr));
assert("verify", pub.Verify(sig, "hello"));
assert("verify", !pub.Verify(sig, "hallo"));
}
static void Main(string[] args) {
try {
int[] curveTypeTbl = { BN254, BLS12_381 };
Expand All @@ -412,6 +437,9 @@ static void TestAreAllMsgDifferent()
TestFastAggregateVerify();
TestAggregateVerify();
}
if (curveType == BLS12_381 && !isETH) {
TestDFINITY();
}
if (err == 0) {
Console.WriteLine("all tests succeed");
} else {
Expand Down

0 comments on commit 88defaa

Please sign in to comment.