I am currently implementing the heuristic 1 algorithm from this paper https://eprint.iacr.org/2017/338.pdf for a university project. (pretty interesting btw worth reading :) ).
My problem currently is, I don't fully understand the vin
field, which I need for the algorithm.
So what I know:
The vin
field contains all input transactions for the whole transaction.
Example would be a vin
field containing 3 inputs, this 3 inputs represent the denominations of the full transaction amount.
Each of this 3 inputs has also a key_image
field. It is there for double spending reasons. Each key_image
exists only once on the blockchain. For simplicity we say key_image = HASH(key_offset)
, where key_offset
is the public key of the real spender in this vin input
.
The values in key_offsets
are: The public key of the spender + the mixins used. So key_offsets_size = spender_key + N * mixin_key
.
I also know that key_offsets
are stored differentially, meaning key_offsets = [1,1,1] => real index of inkeys: [1,2,3]
.
So I am pretty confused how it can be that the same index in key_offsets
can be more than once on the blockchain.
For example I querried block X and I had key_offsets = [ 1 ]
, then I querried block Y (Y > X) and got the same key_offsets
.
What am I missing here? Where are "the real" input keys stored and how can I acquire them? Would be awesome if someone could point me on the correct API call.
UPDATE:
For example I queried block 345
and 1247
. Got tx
9ecdadf8b95aa0a7b754559f5fd7a9bb0f5014c4107b3dc6b3331430b5ea984d
in 345
and ed4717dd86e5b033c36df3b41a3a5296f392e3524651c79792e9b39674c7f1ef
in 1247
.
When I get all the denominations from 345
:
{
"key":
{
"amount": 458444,
"k_image": "2c03aa742e881a41588827ea8680f68ea3e6988917c832767e951f3ff7457b17",
"key_offsets": [
0
]
}
},
and for 1247
:
{
"key":
{
"amount": 307304,
"k_image": "fca0574448356fedf7493310fba22a717c0c7bd7f4acca03fb17bb8d582eb5ef",
"key_offsets": [
0
]
}
},
So for each output you spend, you provide a set of key offsets, one of which will be yours...
This should mean that both txs use the tx with the index 0 as mixin. But there is only 1 offset present in the transactions meaning that the index 0 is the transaction itself.