Skip to content

Commit

Permalink
More BIP39 tests and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Jan 5, 2024
1 parent 846732e commit 48e3d82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions convex-core/src/main/java/convex/core/crypto/BIP39.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static Blob getSeed(List<String> words, String passphrase) throws NoSuchA
}

public static Blob getSeed(String mnemonic, String passphrase) throws NoSuchAlgorithmException, InvalidKeySpecException {
mnemonic=mnemonic.trim().replaceAll("\\s+"," ");
mnemonic=normaliseSpaces(mnemonic);
mnemonic=Normalizer.normalize(mnemonic, Normalizer.Form.NFKD);
char[] normalisedMnemonic= mnemonic.toCharArray();
return getSeedInternal(normalisedMnemonic,passphrase);
Expand Down Expand Up @@ -287,8 +287,9 @@ public static List<String> getWords(String s) {
return al;
}

public static String normalise(String s) {
return Utils.joinStrings(getWords(s)," ");
public static String normaliseSpaces(String s) {
s=s.trim().replaceAll("\\s+"," ");
return s;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public KeyGenPanel(PeerGUI manager) {
actionPanel.add(btnNormalise);
btnNormalise.addActionListener(e -> {
String s=mnemonicArea.getText();
mnemonicArea.setText(BIP39.normalise(s));
mnemonicArea.setText(BIP39.normaliseSpaces(s));
updateMnemonic();
});
}
Expand Down

0 comments on commit 48e3d82

Please sign in to comment.