Beispiel #1
0
        public void Bls_priv_to_pub()
        {
            string[] smallDir = Directory.GetDirectories(Path.Combine("priv_to_pub", "small"));
            foreach (string testCase in smallDir)
            {
                Console.WriteLine(testCase);
                (YamlNode node, YamlNodeType nodeType) = LoadValue(Path.Combine(testCase, "data.yaml"));
                string?inputHex = node.Prop <string>("input");
                if (inputHex is null)
                {
                    throw new InvalidDataException("Input missing");
                }

                byte[] privateKeyBytes = Bytes.FromHexString(inputHex);
                BlsProxy.GetPublicKey(privateKeyBytes, out Span <byte> publicKey);

                string?outputHex = node.Prop <string>("output");
                if (outputHex is null)
                {
                    throw new InvalidDataException("Expected output missing");
                }

                byte[] expectedPublicKey = Bytes.FromHexString(outputHex);
                Assert.AreEqual(expectedPublicKey, publicKey.ToArray());
            }
        }
Beispiel #2
0
        public void TestPrivateKeyToPublic()
        {
            var privateKeyBytes = Bytes.FromHexString("47b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665138");

            TestContext.Out.WriteLine("Serialized private key: {0}", privateKeyBytes.ToHexString());

            BlsProxy.GetPublicKey(privateKeyBytes, out var publicKeySpan);
            var publicKeyBytes = publicKeySpan.ToArray();

            Assert.AreEqual("b301803f8b5ac4a1133581fc676dfedc60d891dd5fa99028805e5ea5b08d3491af75d0707adab3b70c6a6a580217bf81", publicKeyBytes.ToHexString());
        }