You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
582 B
17 lines
582 B
#!/bin/bash
|
|
# Helper script for secp256k1 signing using pure shell commands
|
|
|
|
PRIVATE_KEY_FILE="$1"
|
|
MESSAGE_HASH_FILE="$2"
|
|
|
|
# Load private key and message hash
|
|
PRIVATE_KEY=$(cat "$PRIVATE_KEY_FILE" | xxd -p -c 64)
|
|
MESSAGE_HASH=$(cat "$MESSAGE_HASH_FILE" | xxd -p -c 32)
|
|
|
|
# Use secp256k1 library through Python (as a last resort)
|
|
python3 -c "
|
|
from coincurve import PrivateKey
|
|
private_key = PrivateKey(bytes.fromhex('$PRIVATE_KEY'))
|
|
signature = private_key.sign(bytes.fromhex('$MESSAGE_HASH'), hasher=None)
|
|
print(signature.hex())
|
|
" | xxd -r -p | base64 -w 0 | tr '/+' '_-' | tr -d '='
|