A proper sample
All checks were successful
buildbot/travis_bionic Build done.
buildbot/multibuild_parent Build done.

This commit is contained in:
Lee Miller 2023-01-05 07:20:58 +02:00
parent 43ba487d67
commit d97ea82c1f
Signed by: lee.miller
GPG Key ID: 4F97A5EA88F4AB63

View File

@ -5,34 +5,39 @@ var TcpTransport = require('bitmessage-transports').TcpTransport;
var eccrypto = require("eccrypto");
(async () => {
const sender = Address({
version: 2, stream: 1,
signPrivateKey: Buffer.from(
'93d0b61371a54b53df143b954035d612f8efa8a3ed1cf842c2186bfd8f876665', 'hex'
),
encPrivateKey: Buffer.from(
'4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a', 'hex'
)}),
recipient = Address.fromPassphrase('test');
const from = Address.fromPassphrase('loremipsum1');
console.log('[from]', from.encode());
console.log('[from sign priv key]', from.signPrivateKey.toString('hex'));
console.log('[from version]', from.version);
console.log('[from stream]', from.stream);
console.log('[from behaviour]', from.behavior);
const toAddr = Address.fromPassphrase('gru');
console.log('[toAddr]', toAddr.encode());
console.log('[toAddr enc pub key]', toAddr.encPublicKey.toString('hex'));
console.log('[toAddr version]', toAddr.version);
console.log('[toAddr stream]', toAddr.stream);
console.log('[toAddr ripe]', toAddr.ripe);
const encodedMsg = await objects.msg.encodePayloadAsync({
ttl: 1800,
from: from,
to: toAddr,
message: 'hey there!',
subject: 'Lorem Ipsum',
console.log('[sender]', sender.encode());
console.log('[recipient]', toAddr.encode());
console.log('[recipient enc pub key]', toAddr.encPublicKey.toString('hex'));
console.log('[recipient version]', toAddr.version);
console.log('[recipient stream]', toAddr.stream);
console.log('[recipient ripe]', toAddr.ripe);
var encodedMsg = await objects.msg.encodePayloadAsync({
ttl: 24 * 60 * 60,
from: sender,
to: recipient,
message: 'The quick brown fox jumps over the lazy dog.',
subject: 'hello',
encoding: 2,
friend: true,
skipPow: true,
// skipPow: true,
});
const strippedMsg = encodedMsg.slice(8);
console.log('[check messages]', strippedMsg);
console.log('[check messages]', strippedMsg.toString('hex'));
console.log('[message]', encodedMsg.toString('hex'));
var d = await objects.msg.decodePayloadAsync(encodedMsg, {
skipPow: true,
identities: toAddr,
// skipPow: true,
identities: recipient,
});
console.log('[decoded]', d.message);
// const encPublicKey = '04a60f6cd97ecd16768215ef059ccfbb1840b736bcdb0763872ddfeef4c417d2ec8439383ce68de9a2b30ad44e9f0e56a13fc2895a6e41f7cf3757e46181d32dd0';