Monday, January 27, 2025
HomeBitcoinutxo - Can not unserialize chainstate transaction outputs after de-obfuscation

utxo – Can not unserialize chainstate transaction outputs after de-obfuscation


I used to be capable of learn chainstate database.

Getting the important thing and de-obfuscating to get a legitimate final block.

Nevertheless, with regards to transactions that comply with after that,

I can’t de-serialize them it doesn’t matter what I am doing.

obtained the important thing: 1e9ad7d35416f693
final block:
ind:  42
key:  1e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f693
val:  1e9ad7d35416f6931e9d0500458046bf32a7a4316479e1d99a33ea499237f9c3
xor:  00000000000000000007d2d31196b02c2c3d73e2306f174a84a93d9ac6210f50 <- that is good
transaction:
ind:  430000000001ec3a985ee53d32ef164b58f69ab50792d1f97119b4780a96d476d100
key:  1e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e
val:  badbd53e2b2b9a9893a09c755e97af385069c874d3520a3641
xor:  a44102ed7f3d6c0b8d3a4ba60a8159ab4ef31fa78744fca55f      <- appears like fallacious? idk
model:  164  nCode:  65  fCoinBase:  1  vAvail 1&2:  false false  N:  7
transaction:
ind:  430000000001ec3a985ee53d32ef164b58f69ab50792d1f97119b4780a96d476d102
key:  1e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f693
val:  01c855e08c6c63663c160665a736b7977b4d3f1049a47bc6ee9ad7d35416fb853e9afff7d50a3641
xor:  1f528233d87a95f5228cd1b6f320410465d7e8c31db28d55f000000000000d1620002824811cc0d2
model:  31  nCode:  82  fCoinBase:  0  vAvail 1&2:  true false  N:  10
transaction:
ind:  430000000001ec3a985ee53d32ef164b58f69ab50792d1f97119b4780a96d476d103
key:  1e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f693
val:  76a2bac0ed1819a6ce9bd2da2eaff013b1f584bf68e82e1b8d145941e1aca4ac3e9afff7d50a3641
xor:  68386d13b90eef35d00105097ab90680af6f536c3cfed888938e8e92b5ba523f20002824811cc0d2
model:  104  nCode:  56  fCoinBase:  0  vAvail 1&2:  false false  N:  6
transaction:
ind:  430000000001ec3a985ee53d32ef164b58f69ab50792d1f97119b4780a96d476d104
key:  1e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f693
val:  17528449f55864088b11ccf31519fb6f26ab84223f38016b613fd83116fe6e853e9afff7d50a3641
xor:  09c8539aa14e929b958b1b20410f0dfc383153f16b2ef7f87fa50fe242e8981620002824811cc0d2
model:  9  nCode:  200  fCoinBase:  0  vAvail 1&2:  false false  N:  24
transaction:
ind:  430000000001ec3a985ee53d32ef164b58f69ab50792d1f97119b4780a96d476d105
key:  1e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f6931e9ad7d35416f693
val:  1db5122772cdab7b79e9d625261bc618652539fa4250aeb3efde1c950f6c588a3e9afff7d50a3641
xor:  032fc5f426db5de8677301f6720d308b7bbfee2916465820f144cb465b7aae1920002824811cc0d2
model:  3  nCode:  47  fCoinBase:  1  vAvail 1&2:  true true  N:  5

They simply do not appear to comply with the principles. After I take the primary two bytes of the transition worth, they produce arbitrary model and unreasonably giant N. I consider, it must be zero or a few bytes at greatest.

  • The upper bits encode N, the variety of non-zero bytes within the following bitvector.
  • In case each bit 2 and bit 4 are unset, they encode N-1, as there should be not less than one non-spent output).

Do not know the way to make the proper unspentness bitvector out of it. Additionally it is unclear to me when one vout ends and the opposite one begins.
Likewise, no thought the way to determine the peak, particularly as a result of it is in a c++ varint format.

Right here is code, am I getting the proper XORs for transactions proper?
I’m altering endianness instantly after retrieving every worth.

var degree = require('degree')
var db = degree('kaka-read', {  valueEncoding: 'hex', keyEncoding: 'hex'})

db.createReadStream({ restrict:1000 })
    .on('information', perform (information) {
        var worth= reverseBytes(information.worth);                // altering endiannes for all values
        var index= information.key;
        
        if (!this.hasOwnProperty('key')){
            var key_val = worth.slice(0,-2);                    // eradicating extreme byte from the obfuscation key
            console.log('obtained the important thing: '+key_val);
            
            this.key= class {                               // establishing the obfuscation key class
                constructor(new_len=0){
                    this.pos=-1;
                    this.len= key_val.size;
                    this.verbose= key_val;
                    this.prolonged='';
                    this.lengthen(new_len);
                }
                generate(){
                    this.pos = (this.pos+ 1) % this.len;
                    this.prolonged += this.verbose[this.pos];
                }
                lengthen(new_len){
                    for (var i=0; i>3;                           // shift 3 proper (bit 4+)
        if (vAvail[0]==0 && vAvail[1]==0) N--;  // if each spent, N-1
        
        //// the outcomes do not appear to look proper, but I do not know
        console.log('model: ', model,' nCode: ',nCode,' fCoinBase: ', fCoinBase,' vAvail 1&2: ', vAvail[0],vAvail[1],' N: ',N);
    })
    
    .on('finish', perform () {
        console.log('Fin')
    })

// Convert a hex string to a byte array
perform hexToBytes(hex) {
    for (var bytes = [], c = 0; c < hex.size; c += 2)
    bytes.push(parseInt(hex.substr(c, 2), 16));
    return bytes;
}

// Convert a byte array to a hex string
perform bytesToHex(bytes) {
    for (var hex = [], i = 0; i < bytes.size; i++) {
        var present = bytes[i] < 0 ? bytes[i] + 256 : bytes[i];
        hex.push((present >>> 4).toString(16));
        hex.push((present & 0xF).toString(16));
    }
    return hex.be a part of("");
}

perform reverseBytes(enter){
    return bytesToHex(hexToBytes(enter).reverse());
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments