aboutsummaryrefslogtreecommitdiff
path: root/20210926_181912-message_splitting
blob: 199a14c3c6abc5f25bfb6010b665a90cfbf96248 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Message splitting
=================

In the following, I am going to analyze in written text, as you already see, how can I slpit a chunk of text in parts and then take the parts and put them back.

This is a practical problem I have. I want to utilize ARCHINGKAOS token, to put in a transaction the IPFS link of some data. Whether this is a clear text, or binary I don't care.

My problem starts with the 46bytes strings that are used in IPFS.
The Stellar Network provides an ability to send a memo with each transaction which can handle up to 32bytes of information.

A basic split could be for 46/2=23bytes
Then 32-23=9

46bytes:
a1a2a3a4a5a6a7a8a9a0b1b2b3b4b5b6b7b8b9b0c1c2c3 or
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa or 
aaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaa which could be splitted
aaaaaaaaaaaaaaaaaaaaaab
baaaaaaaaaaaaaaaaaaaaaa

32bytes:
cccccccccccccccccccccccccccccccc
cccccccccaaaaaaaaaaaaaaaaaaaaaab
cccccccccbaaaaaaaaaaaaaaaaaaaaaa

One the 9bytes we firstly have to arrange which of the strings is first
For example:
cccccccc0aaaaaaaaaaaaaaaaaaaaaab
cccccccc1baaaaaaaaaaaaaaaaaaaaaa

I only care for the ipfs link to be readable and searchable at the moment. If have a sender and a receiver and a link splitted in two.

The rest of 8bytes could be used as any keycodes. Could also extend the protocol (cause I guess this is that I am doing here) to have up to 62^9 possibilites means could be used as array with for every transaction you permantly store part of information.

A question is how do I glue them back?

In our case we need the 0 and the 1. but again, let's say we send from some stellar address to another one. What's is happening. Person A sends and B receives. So, B gets 2 transaction with some info. However, our new friend, C, can also see the transaction and the memo. Can C assemble the info? Of course! There is a need for the joiner tool as well.

We can mark with another byte in the start of 9bytes
sccccccc0 s as of start
mccccccc1 m as of middle in cases 
eccccccc2 e as for ending enumerating of transactions

Operating transaction data can be overwhelming at some point. If someone send two messages? and the get mixed up? What happens then?

We have rest of the 7bytes not allocated to any task. We can define some more "rules" but which better than error detection or even better, correctness approval.

In our previous message:
aaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaa we transformed to that
sccccccc0aaaaaaaaaaaaaaaaaaaaaab
eccccccc1baaaaaaaaaaaaaaaaaaaaaa

We can use the last 7bytes of the splitted message aaaaaab and put in the 7byte area of the second half
However, this does not ensure the stability. Cause if lets say, there are a couple of data that can match, we will have an issue for any amount we then talk about lost data.

How to validate?
2nd		1st
aaaaaaabbaaaaaaa|0aaaaaaaaaaaaaaa tx1

1st		2nd
0aaaaaaaaaaaaaaa|aaaaaaabbaaaaaaa tx2

2nd              3rd
aaaaaaabbaaaaaaa|aaaaaaaaaaaaaaa0 tx3

1st		 3rd
0aaaaaaaaaaaaaaa|aaaaaaaaaaaaaaa0 tx4

If we are getting tx4 we can check all the 1st places, places in other transactions, in order to find the one string the we are making. Serialization of transactions is kept by Stellar Network.

Now, we get the previous array or let's say the data we gathered from stellar network into simplified format:


aaaaaaabbaaaaaaa0aaaaaaaaaaaaaaa
aaaaaaabbaaaaaaa0caaaaaaaaaaaaaa
0aaaaaaaaaaaaaaaaaaaaaabbaaaaaaa
aaaaaaabbaaaaaaaaaaaaaaaaaaaaaa0
0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0
0caaaaaaaaaaaaaaaaaaaaabbaaaaaaa
aaaaaaabbaaaaaaaaaaaaaaaaaaaaaa0
0caaaaaaaaaaaaaaaaaaaaaaaaaaaaa0


21=we split [0]2|1
12=we compare [1]1==[0]1 && [1]2==[0]2
23=we compare 22
13=we compare the 1==1 3==3


for tx in txs
tx.memo get first 16bytes and last to an array of objects

[
{"aaaaaaabbaaaaaaa","0aaaaaaaaaaaaaaa"},
{"aaaaaaabbaaaaaaa","0caaaaaaaaaaaaaa"},
{"0aaaaaaaaaaaaaaa","aaaaaaabbaaaaaaa"},
{"aaaaaaabbaaaaaaa","aaaaaaaaaaaaaaa0"},
{"0aaaaaaaaaaaaaaa","aaaaaaaaaaaaaaa0"},
{"0caaaaaaaaaaaaaa","aaaaaaabbaaaaaaa"},
{"aaaaaaabbaaaaaaa","aaaaaaaaaaaaaaa0"},
{"0caaaaaaaaaaaaaa","aaaaaaaaaaaaaaa0"}
]

gathered[8]

if ga[f][1]==ga[i][0] then keep an i the block has 2nd and 3rd parts
if ga[f][0]==ga[i][0] then keep an i the block has 3rd and 1st parts
if ga[f][1]==ga[i][1] then keep an i the block0 has 2nd and 1st parts
if ga[f][0]==ga[i][1] then keep an i the block its the 1st or 2nd block the other block has 1st or 3rd

we have a block and we compare it with the next ones.

Transactions that we look at are on the amount of 0.25ARCHINGKAOS
1 ARCHINGKAOS = 1 IPFS link transfer

1. Gather transactions of 0.25ARCHINGKAOS in an array
2. Their memos are assumed to be part of messages
3. We find the pieces
4. We parse the message
5. We do stuff :)
: