-
Notifications
You must be signed in to change notification settings - Fork 847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Key: add helper method GetSeedBytes #969
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
using System.Linq; | ||
using System.Text; | ||
using NBitcoin.DataEncoders; | ||
using System.IO; | ||
#if !HAS_SPAN | ||
using NBitcoin.BouncyCastle.Math; | ||
#endif | ||
|
@@ -154,7 +155,7 @@ public SchnorrSignature SignSchnorr(uint256 hash) | |
{ | ||
AssertNotDiposed(); | ||
#if HAS_SPAN | ||
Span<byte> h = stackalloc byte[32]; | ||
Span<byte> h = stackalloc byte[KEY_SIZE]; | ||
hash.ToBytes(h); | ||
return new SchnorrSignature(_ECKey.SignSchnorr(h)); | ||
#else | ||
|
@@ -407,6 +408,18 @@ public BitcoinSecret GetWif(Network network) | |
return new BitcoinSecret(this, network); | ||
} | ||
|
||
public byte[] GetSeedBytes() | ||
{ | ||
AssertNotDiposed(); | ||
byte[] bytes = Enumerable.Repeat((byte)0x00, KEY_SIZE).ToArray(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops! didn't realize that the bytes would be overriden later anyway, was just monkey-translating F# code to C# code from somewhere else |
||
using (var bytesStream = new MemoryStream(bytes)) | ||
{ | ||
var stream = new BitcoinStream(bytesStream, true); | ||
ReadWrite(stream); | ||
} | ||
return bytes; | ||
} | ||
|
||
public BitcoinEncryptedSecretNoEC GetEncryptedBitcoinSecret(string password, Network network) | ||
{ | ||
AssertNotDiposed(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call it
ToBytes
and follow how I implemented it inPubKey
.Your version is super inefficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sure