Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions NBitcoin/DataEncoders/HexEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public class HexEncoder : DataEncoder
private static readonly string[] HexTbl = Enumerable.Range(0, 256).Select(v => v.ToString("x2")).ToArray();
#endif

#if NET8_0_OR_GREATER
public override string EncodeData(ReadOnlySpan<byte> data)
{
// TODO: Convert.ToHexStringLower (.NET 9+) once available.
return Convert.ToHexString(data).ToLowerInvariant();
}
#endif

public override string EncodeData(byte[] data, int offset, int count)
{
if (data == null)
Expand Down
7 changes: 3 additions & 4 deletions NBitcoin/Secp256k1/ECPrivKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public ECPrivKey TweakAdd(ReadOnlySpan<byte> tweak)
/// </summary>
/// <param name="tweak">32 bytes tweak</param>
/// <param name="tweakedPrivKey">False If the tweak is not 32 bytes or if the tweak was out of range (chance of around 1 in 2^128 for uniformly random 32-byte arrays, or if the resulting private key would be invalid(only when the tweak is the complement of the private key)</param>
/// <exception cref="System.ObjectDisposedException">This instance has been disposed</exception>
/// <exception cref="ObjectDisposedException">This instance has been disposed</exception>
/// <returns>A tweaked private key</returns>
public bool TryTweakAdd(ReadOnlySpan<byte> tweak, out ECPrivKey? tweakedPrivKey)
{
Expand Down Expand Up @@ -877,9 +877,8 @@ public bool TryTweakMul(ReadOnlySpan<byte> tweak, out ECPrivKey? tweakedPrivkey)
tweakedPrivkey = null;
if (tweak.Length != 32)
return false;
Scalar factor;
int overflow;
factor = new Scalar(tweak, out overflow);

var factor = new Scalar(tweak, out int overflow);
var sec = this.sec;
bool ret = overflow == 0 && secp256k1_eckey_privkey_tweak_mul(ref sec, factor);
if (ret)
Expand Down
Loading