-
Notifications
You must be signed in to change notification settings - Fork 389
feat: zano hf + bip39 #3359
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
Open
MrCyjaneK
wants to merge
6
commits into
dev
Choose a base branch
from
CW-1249-bip39-zano-hf
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: zano hf + bip39 #3359
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1c1e37c
feat: bip39 zano hf
MrCyjaneK 62c2f94
fix: correct monero_c hash
MrCyjaneK 2359c37
lockfile [skip ci]
MrCyjaneK 7f34713
fix: zano: proper bip32
MrCyjaneK 7a2bc4b
fix: nonBip39WalletTypes
MrCyjaneK 6b79174
fix: zano wallet rename
MrCyjaneK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import 'dart:typed_data'; | ||
|
|
||
| import 'package:bip32/bip32.dart' as bip32; | ||
| import 'package:bip39/bip39.dart' as bip39; | ||
| import 'package:bip39/src/wordlists/english.dart' as bip39_english; | ||
|
|
||
| bool isBip39Seed(String mnemonic) => bip39.validateMnemonic(mnemonic); | ||
|
|
||
| List<String> get bip39EnglishWords => List<String>.from(bip39_english.WORDLIST); | ||
|
|
||
| String generateBip39Mnemonic({int strength = 128}) => | ||
| bip39.generateMnemonic(strength: strength); | ||
|
|
||
| String getSecretDerivationFromBip39(String mnemonic, {String passphrase = ''}) { | ||
| final seed = bip39.mnemonicToSeed(mnemonic, passphrase: passphrase); | ||
|
|
||
| final bip32KeyPair = bip32.BIP32.fromSeed(seed).derivePath("m/44'/128'/0'/0/0"); | ||
|
|
||
| return _reduceECKey(bip32KeyPair.privateKey!).toHexString(); | ||
| } | ||
|
|
||
| const _ed25519CurveOrder = "1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED"; | ||
|
|
||
| Uint8List _reduceECKey(Uint8List buffer) { | ||
| final curveOrder = BigInt.parse(_ed25519CurveOrder, radix: 16); | ||
| final bigNumber = _readBytes(buffer); | ||
|
|
||
| var result = bigNumber % curveOrder; | ||
|
|
||
| final resultBuffer = Uint8List(32); | ||
| for (var i = 0; i < 32; i++) { | ||
| resultBuffer[i] = (result & BigInt.from(0xff)).toInt(); | ||
| result = result >> 8; | ||
| } | ||
|
|
||
| return resultBuffer; | ||
| } | ||
|
|
||
| /// Read BigInt from a little-endian Uint8List | ||
| /// From https://github.com/dart-lang/sdk/issues/32803#issuecomment-387405784 | ||
| BigInt _readBytes(Uint8List bytes) { | ||
| BigInt read(int start, int end) { | ||
| if (end - start <= 4) { | ||
| var result = 0; | ||
| for (int i = end - 1; i >= start; i--) { | ||
| result = result * 256 + bytes[i]; | ||
| } | ||
| return BigInt.from(result); | ||
| } | ||
| final mid = start + ((end - start) >> 1); | ||
| return read(start, mid) + read(mid, end) * (BigInt.one << ((mid - start) * 8)); | ||
| } | ||
|
|
||
| return read(0, bytes.length); | ||
| } | ||
|
|
||
| extension on Uint8List { | ||
| String toHexString() => | ||
| map((b) => b.toRadixString(16).padLeft(2, '0')).join(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| NODE=http://37.27.100.59:10500/json_rpc | ||
| HEIGHT=$(curl -s -X POST $NODE -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"getinfo"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['height'])") | ||
| echo "_Checkpoint($(curl -s -X POST $NODE -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"getblockheaderbyheight","params":{"height":1}}' | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['block_header']['timestamp'])"), 1)," | ||
| for i in $(seq 1 $((HEIGHT/10000))); do echo "_Checkpoint($(curl -s -X POST $NODE -H 'Content-Type: application/json' -d "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"getblockheaderbyheight\",\"params\":{\"height\":${i}0000}}" | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['block_header']['timestamp'])"), ${i}0000),"; done |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.