Ed25519 Cs
Ed25519 Cs
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
namespace Cryptographic
{
/* Ported and refactored from Java to C# by Hans Wolff, 10/10/2013
* Released to the public domain
* /
return result;
}
BigInteger r;
using (var rsub = new MemoryStream((BitLength / 8) + message.Length))
{
rsub.Write(h, BitLength / 8, BitLength / 4 - BitLength / 8);
rsub.Write(message, 0, message.Length);
r = HashInt(rsub.ToArray());
}
var bigR = ScalarMul(B, r);
BigInteger s;
var encodedBigR = EncodePoint(bigR.Item1, bigR.Item2);
using (var stemp = new MemoryStream(32 + publicKey.Length +
message.Length))
{
stemp.Write(encodedBigR, 0, encodedBigR.Length);
stemp.Write(publicKey, 0, publicKey.Length);
stemp.Write(message, 0, message.Length);
s = (r+ HashInt(stemp.ToArray()) * a).Mod(L);
}
var r = DecodePoint(rByte);
var a = DecodePoint(publicKey);
BigInteger s = DecodeInt(sByte);
BigInteger h;
BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003
956564819949");
BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003
956564819952");
BigInteger.Parse("72370055773322622139731865630429942408571163593799076060019509382
85454250989");
BigInteger.Parse("19681161376707505956807079304988542015446066515923890162744021073
123829784752");
BigInteger.Parse("46316835694926478169428394003475163141307993866256225615783033603
165251855960");
BigInteger.Parse("15112221349535400772501151409588531511454012693041857206046113283
949847762202");
BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003
956564819967");