// New random signer public Signer() { var seed = new byte[32]; using (var rnd = new RNGCryptoServiceProvider()) { rnd.GetBytes(seed); } Ed25519.Ed25519.PrehashedKeyPairFromSeed(out _, out PrivateKeyBytes, seed); Ed25519.Ed25519.PublicKeyFromPrehashedPrivateKey(out PublicKeyBytes, PrivateKeyBytes); PrivateKey = Pack58.Pack(PrivateKeyBytes); PublicKey = Pack58.Pack(PublicKeyBytes); }
// New signer from prehashed private key public Signer(byte[] privateKey) { if ((privateKey?.Length ?? 0) != 64) { throw new ArgumentException("Private key should be 64 bytes length (pre-hashed)"); } PrivateKeyBytes = new byte[64]; Ed25519.Ed25519.PublicKeyFromPrehashedPrivateKey(out PublicKeyBytes, privateKey); Array.Copy(privateKey, PrivateKeyBytes, 64); PrivateKey = Pack58.Pack(PrivateKeyBytes); PublicKey = Pack58.Pack(PublicKeyBytes); }