Skip to content

Commit 7db4dca

Browse files
committed
fix: generate_deploy_keys
1 parent 93b6c41 commit 7db4dca

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

higgsfield/internal/init.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import io
44

55
from cryptography.hazmat.primitives import serialization, asymmetric
6-
import paramiko
6+
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
7+
78
from jinja2 import Environment, FileSystemLoader
89
from .util import templates_path, ROOT_DIR
910

@@ -68,20 +69,20 @@ def init(wd: Path, project_name: str):
6869
)
6970

7071

71-
def generate_deploy_keys() -> Tuple[bytes, bytes, paramiko.Ed25519Key]:
72-
c_ed25519key = asymmetric.ed25519.Ed25519PrivateKey.generate() # type: ignore
73-
privpem = c_ed25519key.private_bytes(
72+
def generate_deploy_keys() -> Tuple[bytes, bytes]:
73+
private_key = Ed25519PrivateKey.generate()
74+
75+
public_key = private_key.public_key()
76+
77+
private_bytes = private_key.private_bytes(
7478
encoding=serialization.Encoding.PEM,
75-
format=serialization.PrivateFormat.OpenSSH,
79+
format=serialization.PrivateFormat.PKCS8,
7680
encryption_algorithm=serialization.NoEncryption(),
7781
)
78-
priv_obj = io.StringIO(privpem.decode())
79-
p_ed25519key = paramiko.Ed25519Key.from_private_key(priv_obj)
8082

81-
pub = c_ed25519key.public_key()
82-
openssh_pub = pub.public_bytes(
83-
encoding=serialization.Encoding.OpenSSH,
84-
format=serialization.PublicFormat.OpenSSH,
83+
public_bytes = public_key.public_bytes(
84+
encoding=serialization.Encoding.PEM,
85+
format=serialization.PublicFormat.SubjectPublicKeyInfo,
8586
)
8687

87-
return privpem, openssh_pub, p_ed25519key
88+
return private_bytes, public_bytes

0 commit comments

Comments
 (0)