Skip to content

Commit

Permalink
Add getBase64SecretScalar() to TorKeyPair
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed May 19, 2024
1 parent 3b7ee8d commit afe249a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions security/src/main/java/bisq/security/keys/TorKeyPair.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ public static TorKeyPair fromProto(bisq.security.protobuf.TorKeyPair proto) {
proto.getOnionAddress());
}

public String getBase64SecretScalar() {
// Key Format definition:
// https://gitlab.torproject.org/tpo/core/torspec/-/blob/main/control-spec.txt
byte[] secretScalar = generateSecretScalar(privateKey);
return java.util.Base64.getEncoder().encodeToString(secretScalar);
}

/**
* The format how the private key is stored in the tor directory
*/
public String getPrivateKeyInOpenSshFormat() {
// Key Format definition:
// https://gitlab.torproject.org/tpo/core/torspec/-/blob/main/control-spec.txt
byte[] secretScalar = generateSecretScalar(privateKey);
String encoded = java.util.Base64.getEncoder().encodeToString(secretScalar);
return "-----BEGIN OPENSSH PRIVATE KEY-----\n" +
encoded + "\n" +
getBase64SecretScalar() + "\n" +
"-----END OPENSSH PRIVATE KEY-----\n";
}

Expand Down

0 comments on commit afe249a

Please sign in to comment.