Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 1x 1x 1x 108x 108x 108x 108x 108x 108x 108x 107x 108x 107x 108x 107x 106x 106x 106x 106x 106x 106x 106x 1x | const Endian = require('@pascalcoin-sbx/common').Endian;
const CommonCoding = require('@pascalcoin-sbx/common').Coding;
const CompositeType = require('@pascalcoin-sbx/common').Coding.CompositeType;
const Data = require('./Data');
class Coding extends CompositeType {
constructor() {
super('pascalcoin_ecies');
this.description('Coding for an pascalcoin encrypted ECIES message');
this.addSubType(new CommonCoding.Core.Int8('publicKeyLength', true));
this.addSubType(new CommonCoding.Core.Int8('macLength', true));
this.addSubType(new CommonCoding.Core.Int16('originalDataLength', true, Endian.LITTLE_ENDIAN));
this.addSubType(new CommonCoding.Core.Int16('originalDataLengthIncPadLength', true, Endian.LITTLE_ENDIAN));
this.addSubType(new CommonCoding.Decissive('publicKey', 'publicKeyLength', function (publicKeyLength) {
return new CommonCoding.Core.BytesFixedLength('publicKey', publicKeyLength);
}));
this.addSubType(new CommonCoding.Decissive('mac', 'macLength', function (macLength) {
return new CommonCoding.Core.BytesFixedLength('mac', macLength);
}));
this.addSubType(new CommonCoding.Core.BytesWithoutLength('encryptedData'));
}
/**
*
* @param bc
* @param options
* @param all
* @return {ECIESData}
*/
decodeFromBytes(bc, options = {}, all = null) {
let decoded = super.decodeFromBytes(bc, options, all);
let data = new Data();
data.withPublicKey(decoded.publicKey);
data.withOriginalDataLength(decoded.originalDataLength);
data.withOriginalDataLengthIncPadLength(decoded.originalDataLengthIncPadLength);
data.withMac(decoded.mac);
data.withEncryptedData(decoded.encryptedData);
return data;
}
}
module.exports = Coding;
|