### パラメータファイルの作成
$ openssl ecparam -name secp256k1 -out secp256k1.pem
$ openssl ecparam -in secp256k1.pem -text -noout
EC-Parameters: (256 bit)
ASN1 OID: secp256k1
$ openssl ecparam -in secp256k1.pem -text -param_enc explicit -noout
EC-Parameters: (256 bit)
Field Type: prime-field
Prime:
00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:fe:ff:
ff:fc:2f
A: 0
B: 7 (0x7)
Generator (uncompressed):
04:79:be:66:7e:f9:dc:bb:ac:55:a0:62:95:ce:87:
0b:07:02:9b:fc:db:2d:ce:28:d9:59:f2:81:5b:16:
f8:17:98:48:3a:da:77:26:a3:c4:65:5d:a4:fb:fc:
0e:11:08:a8:fd:17:b4:48:a6:85:54:19:9c:47:d0:
8f:fb:10:d4:b8
Order:
00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
ff:fe:ba:ae:dc:e6:af:48:a0:3b:bf:d2:5e:8c:d0:
36:41:41
Cofactor: 1 (0x1)
### 秘密鍵
$ openssl ecparam -in secp256k1.pem -genkey -noout -out secp256k1-private.pem
$ cat secp256k1-private.pem
16進数表記で出力
$ openssl ec -in secp256k1-private.pem -outform DER | tail -c +8 | head -c 32 | xxd -p -c 32
### 公開鍵
$ openssl ec -in secp256k1-private.pem -pubout -out secp256k1-public.pem ; cat secp256k1-public.pem
16進数表記で出力
$ openssl ec -in secp256k1-private.pem -pubout -outform DER | tail -c 65 | xxd -p -c 65
$ pubKey=04bf03ed7464908e5ee11ca694d3699cef8f27b51d6bd4294576ac30f7a5ebf84346ec91d2fae812d2d8e9528838bc929d6f5eab143214864e8dc719b976c9bbd1
$ prefix=`echo $pubKey | cut -c1-2` ; echo “prefix = $prefix”
prefix = 04
$ x=`echo $pubKey | cut -c3-66` ; echo “x=$x”
x=bf03ed7464908e5ee11ca694d3699cef8f27b51d6bd4294576ac30f7a5ebf843
$ y=`echo $pubKey | cut -c67-130` ; echo “y = $y”
y = 46ec91d2fae812d2d8e9528838bc929d6f5eab143214864e8dc719b976c9bbd1
$ pubKeyHash=`echo $pubKey | hash160` ; echo $pubKeyHash
$ checksum=`echo 00${pubKeyHash} | sha256d | cut -c1-8` ; echo $checksum
$ echo 00${pubKeyHash}${checksum} | b58e
opensslのrmd160がうまくいかん…