Skip to content

Instantly share code, notes, and snippets.

@yasudacloud
Created July 8, 2025 13:28
Show Gist options
  • Select an option

  • Save yasudacloud/c00c03467eaa898b4c1c02abc3ddcc46 to your computer and use it in GitHub Desktop.

Select an option

Save yasudacloud/c00c03467eaa898b4c1c02abc3ddcc46 to your computer and use it in GitHub Desktop.
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec
private_key = ec.generate_private_key(ec.SECP256R1(), default_backend())
private_bytes = private_key.private_numbers().private_value.to_bytes(32, byteorder='big')
public_numbers = private_key.public_key().public_numbers()
x_bytes = public_numbers.x.to_bytes(32, byteorder='big')
y_bytes = public_numbers.y.to_bytes(32, byteorder='big')
public_bytes = x_bytes + y_bytes
# この2つを使う
print(private_bytes)
print(public_bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment