-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmobile.go
39 lines (32 loc) · 1.04 KB
/
mobile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package sansseed
import (
"encoding/hex"
"strings"
"github.com/zackslash/sansseed/derivation"
"github.com/zackslash/sansseed/lengths"
"github.com/zackslash/sansseed/wordlists"
)
// New24WordMnemonicPhraseForLanguage is a GoMobile compatible function that
// returns a new random 24 word mnemonic phrase for given language as a single space seperated string
func New24WordMnemonicPhraseForLanguage(language string) (string, error) {
ent, err := NewWordEntropy(lengths.SeedBitLength(lengths.TwentyfourWordSeed))
if err != nil {
return "", err
}
wl, err := wordlists.GetByLanguageName(language)
if err != nil {
return "", err
}
reSlice, err := MnemonicPhraseForLanguage(ent, *wl)
if err != nil {
return "", err
}
r := strings.Join(reSlice, " ")
return r, nil
}
// DeriveSeedFromMnemonic is a GoMobile compatible function that
// returns the hex encoded seed derived from the given mnemonic
func DeriveSeedFromMnemonic(mnemonic string) string {
seed := derivation.DeriveSeedFromMnemonic(mnemonic, "")
return hex.EncodeToString(seed)
}