public void CreateECKeySerializeDeserializeSignAndVerify(KeyStrength keyStrength)
    {
        var parameters = ECDsaHelper.CreateNewECDsaParameters(keyStrength);
        var key        = new TagPubECKey(parameters);
        var bytes      = key.EncodedBytes;

        TestContext.WriteLine(bytes.AsLiteral());
        using var ms = new MemoryStream(bytes);
        var tag = ms.Decode <TagPubKey>();

        Assert.NotNull(tag);
        Assert.AreEqual(key, tag);
        CollectionAssert.AreEqual(bytes, tag.EncodedBytes);
        var signatureBytes = ECDsaHelper.HashAndSign(bytes, parameters.Parameters, parameters.HashAlgorithm.ToName());
        var signature      = new TagSignature(Algorithm.EcDSA, signatureBytes);

        Assert.IsTrue(key.Verify(bytes, signature), "Signature failed!");
    }
Ejemplo n.º 2
0
 public override void GenerateNextKeys() => _nextKeyParameters = ECDsaHelper.CreateNewECDsaParameters(_data.Strength);