EOS 签名 ECDSA sign 椭圆曲线数字签名
先零散的记一下,后面再整理
js ecc
https://github.com/EOSIO/eosjs-ecc/blob/7ec577cad54e17da6168fdfb11ec2b09d6f0e7f0/src/signature.js
sign
Signature.sign = function(data, privateKey, encoding = 'utf8') {
if(typeof data === 'string') {
data = Buffer.from(data, encoding)
}
assert(Buffer.isBuffer(data), 'data is a required String or Buffer')
data = hash.sha256(data)
return Signature.signHash(data, privateKey)
}
ecsignature = ecdsa.sign(curve, dataSha256, privateKey.d, nonce++);
java
private String sign(String privateKey, SignArg arg, PackedTransaction t) {
Raw raw = Packer.packPackedTransaction(arg.getChainId(), t);
raw.pack(ByteBuffer.allocate(33).array());// TODO: what's this?
String hash = KeyUtil.signHash(privateKey, raw.bytes());
return hash;
}
参考
ECDSA — The art of cryptographic signatures
https://medium.com/coinmonks/ecdsa-the-art-of-cryptographic-signatures-d0bb254c8b96