Not sure if this emulates CHECKSIGFROMSTACK in the way you are trying to achieve. I found this thread interesting and wanted to share this idea:
1. CHECKSIGFROMSTACK requires 3 parameters: signature, message and public key. What if we could combine message and public key? So, public key contains the message.
2. Lets assume the message is "TEST". We encode each character in the message to hex: 54 45 53 54.
3. Generate keypairs for each hex being the first in public key after prefix.
import os
from ecdsa import SigningKey, SECP256k1
from colorama import Fore, Style, init
init(autoreset=True)
def generate_privkey():
while True:
key_bytes = os.urandom(32)
if 1 <= int.from_bytes(key_bytes, "big") < SECP256k1.order:
return SigningKey.from_string(key_bytes, curve=SECP256k1)
def find_vanity_pubkey(pattern: str):
pattern = pattern.lower()
attempts = 0
while True:
priv_key = generate_privkey()
pub_key = priv_key.get_verifying_key()
pub_hex = pub_key.to_string("compressed").hex()
if pub_hex[2:4] == pattern:
return priv_key.to_string().hex(), pub_hex
attempts += 1
def main():
while True:
pattern = input("\nEnter a 2-character hex pattern: ").strip().lower()
if len(pattern) == 2:
try:
int(pattern, 16)
break
except ValueError:
print(Fore.RED + "Error: Invalid hex")
else:
print(Fore.RED + "Error: Enter 2 hex characters")
priv, pub = find_vanity_pubkey(pattern)
print(f"\nPrivate key: {priv}")
print(f"Public key : {pub[:2]}{Fore.LIGHTCYAN_EX}[{pub[2:4]}]{Style.RESET_ALL}{pub[4:]}\n")
if __name__ == "__main__":
main()
Enter a 2-character hex pattern: 54
Private key: 8160b69a538fb88b4d3f0c70e4441000d8ff572413c5442ba1e875333a41cb9a
Public key : 03[54]18283ba776b1f386d5ba80f778aa18b6246520d42e656d6663ff970edd89df
Enter a 2-character hex pattern: 45
Private key: 3dcc44110f5c41c70edf6ea4cb4b43ac50f5bbaf98a009cfec662d3bcb96a702
Public key : 03[45]f71ac5af4e00e0455ebcc656720a2ec8c205ab8554bc75944bf939c0a6bb5e
Enter a 2-character hex pattern: 53
Private key: 4b5d731db2ecbb6884f262873bd4168e754302d11a167339ed7b1c3a5b18009e
Public key : 03[53]fd655009b51646098106cf4d70081c9ed8255e74abcde0f6aea4c62c99f9d4
Enter a 2-character hex pattern: 54
Private key: e62f12f7778b85ee250cdaec62d3137eb19472f1c799262466600084f6f85622
Public key : 02[54]c33f24382926fc346fb524594217164b95d5f7ad9c6aafb8388e4ed4963b20
4. Create a 4-of-4 multisig address using these 4 public keys and send some sats to the address. This UTXO can only be spent when all the 4 keys sign the transaction and all the public keys combined will give us the message: TEST.
Note: This is just an experiment and don't try it on mainnet.