先零散的记一下,后面再整理
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
版权属于:区块链中文技术社区 / 转载原创者
本文链接:https://bcskill.com/index.php/archives/713.html
相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!