Sign

Signing device private key

Params:

hash - {string|buffer} - Hash

JS module
CLI
RPC
WS
Result
let hash = crypto.createHash("sha256").update('test', "utf8").digest();
let signDevice = core.signDevicePrivateKey(hash);
biot-core signDevicePrivateKey <hash>
client.request('signDevicePrivateKey', ['hash'], (err, data) => {
if(err)
throw err;
console.log(data);
});
let message_id = id++
socket.send(JSON.stringify({
id: message_id,
name: 'signDevicePrivateKey',
args: ['hash']
}));
socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.id === message_id && data.name === 'signDevicePrivateKey') {
console.log('result:', data.result);
}
};
{ sign: 'qzDF4L1uqLe7iORRb8LcpFm35P2u2JjFqu+bXw4wQ35Ool+yA26tbeyVq75AKftgazM9cOIbzQnUeaUJ+X5ygA==',
pub_b64: 'AxhdtgYqxWoBQOojahmaWaNGUMfqVNAuwxsBINdOwyjH' }

Signing with address (watch: myAddressInfo)

Params:

account - {number} - account

is_change - {number} - is_change

address_index - {number} - address_index

hash - {string|buffer} - Hash

JS module
CLI
RPC
WS
Result
let wallets = await core.getMyDeviceWallets();
let addresses = await core.getAddressesInWallet(wallets[0]);
let addressInfo = await core.myAddressInfo(addresses[0]);
let signAddress = core.signWithAddress(addressInfo.account, addressInfo.is_change, addressInfo.address_index, hash);
biot-core signWithAddress <account> <isChange> <addrressIndex> <hash>
client.request('signWithAddress', ['account', 'isChange', 'addrressIndex', 'hash'], (err, data) => {
if(err)
throw err;
console.log(data);
});
let message_id = id++;
socket.send(JSON.stringify({
id: id++,
name: 'signWithAddress',
args: ['account', 'isChange', 'addrressIndex', 'hash']
}));
socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.id === message_id && data.name === 'signWithAddress') {
console.log('result:', data.result);
}
};
{ sign: 'Pmg7U6zco+pAvShR8vxE2D7G2tQz6KZ/8GgMRjs6cxQcFOKsX2U197IEYqhq3nU01/xZYYS9NSZh8bsktgx43g==',
pub_b64: 'AmhkMy3pWRWb6jxjTp3sTiwZUf0riV2CIS4Iqi8Qzx56' }

Sign verification

Params:

hash - {string|buffer} - Hash

sign - {string} - Sign

pub_64 - {string} - pub_64

JS module
CLI
RPC
WS
Result
core.verifySign(hash, sign, pub_b64)
biot-core verifySign <hash> <sign> <pub_b64>
client.request('verifySign', ['hash', 'sign', 'pub_b64'], (err, data) => {
if(err)
throw err;
console.log(data);
});
let message_id = id++;
socket.send(JSON.stringify({
id: message_id,
name: 'verifySign',
args: ['hash', 'sign', 'pub_b64']
}));
socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.id === message_id && data.name === 'verifySign') {
console.log('result:', data.result);
}
};
true