Created
March 20, 2026 07:28
-
-
Save IvanAnishchuk/92acf89db234bcbcdc25e8d0c33b04c3 to your computer and use it in GitHub Desktop.
key gen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user@g94 ~/src/ghostsomething $ uv run gen.py | |
| ======================================== | |
| ๐ GHOST-TIP MINT KEY GENERATION UTILITY | |
| ======================================== | |
| --- [1] SECP256K1 IDENTITY KEYS --- | |
| MINT_IDENTITY_PRIVKEY_HEX (Python .env) : 0x22d0660777583e8d539991fb0f3b3e93ee1a1137d245e70be103ec7c223e2d20 | |
| MINT_IDENTITY_PUBKEY (Frontend TS) : 0x03ffe59db59efa387524902c29a91e9a8a8102aba294b17269e111d3a66141b1ca | |
| --- [2] BN254 BLS KEYS --- | |
| MINT_BLS_PRIVKEY_INT (Python .env) : 20039963676432430907863765051914022724331012657499563741125354131636076685515 | |
| PK_MINT_SOLIDITY (Smart Contract): | |
| [4841927008653339574974194095432166215193429065775517885539601443847116354259, | |
| 19953233022014287473621921793059794286416051202301779034244565308615443699185, | |
| 4016398327507360094870864384150532403047872794108719217963763835037823324995, | |
| 13950460623292641526021521646291107281098077903592978537085398164831610421682] | |
| PK_MINT_TYPESCRIPT (Frontend TS): | |
| ['0xab46efe6ab11eddc0cd5eafe81553e00ccf13f5259c10325d82a05ed762f2d3', | |
| '0x2c1d21328377daf0d9d6e0c86bc7c05a726bdacface51413f42afa3e1b8d55f1', | |
| '0x8e1336dcccd6fee6754516602806ac52451d3100af4423b566ddd977240d343', | |
| '0x1ed7ae4f7d079d5f9bc2e5f0bcb3ac282443c97e7a9b5f4b280ac917ea0541b2'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from eth_keys import keys | |
| from py_ecc.bn128 import curve_order, G2, multiply | |
| def generate_keys(): | |
| print("========================================") | |
| print("๐ GHOST-TIP MINT KEY GENERATION UTILITY") | |
| print("========================================\n") | |
| # --------------------------------------------------------- | |
| # 1. SECP256K1 IDENTITY KEY (ECDH Return Channel) | |
| # --------------------------------------------------------- | |
| identity_priv_bytes = os.urandom(32) | |
| identity_priv_key = keys.PrivateKey(identity_priv_bytes) | |
| identity_pub_compressed = identity_priv_key.public_key.to_compressed_bytes().hex() | |
| print("--- [1] SECP256K1 IDENTITY KEYS ---") | |
| print(f"MINT_IDENTITY_PRIVKEY_HEX (Python .env) : 0x{identity_priv_key.to_hex()[2:]}") | |
| print(f"MINT_IDENTITY_PUBKEY (Frontend TS) : 0x{identity_pub_compressed}\n") | |
| # --------------------------------------------------------- | |
| # 2. BN254 BLIND SIGNATURE KEY | |
| # --------------------------------------------------------- | |
| sk_bytes = os.urandom(32) | |
| sk_int = int.from_bytes(sk_bytes, 'big') % curve_order | |
| # Calculate PK_mint = sk * G2 | |
| pk_g2 = multiply(G2, sk_int) | |
| # Extract coordinates | |
| # py_ecc G2 points are tuples of FQ2 polynomials: ((x.real, x.imag), (y.real, y.imag)) | |
| # Note: Solidity ecPairing expects: [x.imag, x.real, y.imag, y.real] | |
| x_real = pk_g2[0].coeffs[0].n | |
| x_imag = pk_g2[0].coeffs[1].n | |
| y_real = pk_g2[1].coeffs[0].n | |
| y_imag = pk_g2[1].coeffs[1].n | |
| print("--- [2] BN254 BLS KEYS ---") | |
| print(f"MINT_BLS_PRIVKEY_INT (Python .env) : {sk_int}\n") | |
| # Format for Solidity (Base-10 Integers) | |
| print("PK_MINT_SOLIDITY (Smart Contract):") | |
| print(f"[{x_imag},\n {x_real},\n {y_imag},\n {y_real}]\n") | |
| # Format for TypeScript / mcl-wasm (Hex Strings) | |
| print("PK_MINT_TYPESCRIPT (Frontend TS):") | |
| print(f"['{hex(x_imag)}',\n '{hex(x_real)}',\n '{hex(y_imag)}',\n '{hex(y_real)}']\n") | |
| if __name__ == "__main__": | |
| generate_keys() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [project] | |
| name = "ghostsomething" | |
| version = "0.1.0" | |
| description = "Add your description here" | |
| readme = "README.md" | |
| requires-python = ">=3.13" | |
| dependencies = [ | |
| "eth-keys>=0.7.0", | |
| "py-ecc>=8.0.0", | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment