<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />

Codec

static class Codec
namespace Org.BouncyCastle.Math.EC.Rfc8032 { internal static class Codec { internal static uint Decode16(byte[] bs, int off) { return (uint)(bs[off] | (bs[++off] << 8)); } internal static uint Decode24(byte[] bs, int off) { return (uint)(bs[off] | (bs[++off] << 8) | (bs[++off] << 16)); } internal static uint Decode32(byte[] bs, int off) { return (uint)(bs[off] | (bs[++off] << 8) | (bs[++off] << 16) | (bs[++off] << 24)); } internal static void Decode32(byte[] bs, int bsOff, uint[] n, int nOff, int nLen) { for (int i = 0; i < nLen; i++) { n[nOff + i] = Decode32(bs, bsOff + i * 4); } } internal static void Encode24(uint n, byte[] bs, int off) { bs[off] = (byte)n; bs[++off] = (byte)(n >> 8); bs[++off] = (byte)(n >> 16); } internal static void Encode32(uint n, byte[] bs, int off) { bs[off] = (byte)n; bs[++off] = (byte)(n >> 8); bs[++off] = (byte)(n >> 16); bs[++off] = (byte)(n >> 24); } internal static void Encode32(uint[] n, int nOff, int nLen, byte[] bs, int bsOff) { for (int i = 0; i < nLen; i++) { Encode32(n[nOff + i], bs, bsOff + i * 4); } } internal static void Encode56(ulong n, byte[] bs, int off) { Encode32((uint)n, bs, off); Encode24((uint)(n >> 32), bs, off + 4); } } }