lga ncrypt source i got a number of requests for code so here it is its written in x asm borland tasm will do tasm lga asm tlink t lga asm the code lga ncryption c by nick nassuphis code segment assume cs code ds code org h start jmp begin gas particle assigment bit particle moving east bit particle moving west bit particle moving north bit particle moving south bit particle moving east bit particle moving west bit particle moving north bit particle moving south collisiong rules gas rules if e w and n s then e w n s if n s and e w then n s e w for nibbles and for bytes reflection rules just swap bits along directions this look up table implements two particle collisions for the hpp lattice gas hpprule db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b this rule implements the velocity reversal needed to run the gas evolution in reverse its called a wallrule because its the same as is all particles hit a wall head on wallrule db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b db b maxbyte equ lineno equ srcptr dw offset buffer desptr dw offset buffer savebuff db maxbyte lineno dup buffer db maxbyte lineno dup db dup buffer db maxbyte lineno dup db dup data db db db db this is a test for a lattice gas based encryption db algorithm the data is encoded as particles of a db digital gas whose time evolution is then simulated db with a cellular automaton type algorithm decryption db can be achieved by running the simulation in reverse db a thermodynamic argument ensures that even if a single db bit is flipped no decryption of the data is possible db db after the gas is let to evolve for timesteps db one can either run the reverse evolution by pressing db space or flip a bit and then run by pressing db db for a cryptographic application the key would consist db of the number of time steps and the time and location db of specific bit inversions db db db db db fill the gas with a piece of code initgas mov di cs srcptr mov si offset data mov cx lineno ig push di push cx mov cx maxbyte ig mov al cs si mov cs di al inc si inc di loop ig pop cx pop di add di maxbyte loop ig mov si cs srcptr mov di offset initgas mov cx maxbyte mov al lg mov byte ptr cs si al not al inc si loop lg ret display gas molecules bouncing around showgas push es push si push di push cx push bx mov ax b h mov es ax mov si cs srcptr mov di mov cx lineno add si maxbyte sg push cx push di mov cx maxbyte sg mov al cs si mov byte ptr es di al inc si add di dec cx jnz sg pop di pop cx add di loop sg pop bx pop cx pop di pop si pop es ret cs si sourse of data cs di destination of data scanonemiddleline first byte is a special case because of warparound mov bl al is the assembled byte mov bh cs si maxbyte north is one line up lower and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte south is one line down higher and bh b and at bits and or bl bh place the stuff into al mov bh cs si maxbyte west is one byte left lower and bh b and at bits and or bl bh mov bh cs si east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al inc si inc di middle bytes can be handled in a loop mov cx maxbyte sol mov bl al is the assembled byte mov bh cs si maxbyte north is one line up lower and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte south is one line down higher and bh b and at bits and or bl bh place the stuff into al mov bh cs si west is one byte left lower and bh b and at bits and or bl bh mov bh cs si east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al inc si inc di loop sol last byte is also special mov bl al is the assembled byte mov bh cs si maxbyte north is one line up lower and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte south is one line down higher and bh b and at bits and or bl bh place the stuff into al mov bh cs si west is one byte left lower and bh b and at bits and or bl bh mov bh cs si maxbyte east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al inc si inc di ret cs si sourse of data cs di destination of data scanfirstline first byte is a special case because of warparound mov bl mov bh cs si maxbyte lineno and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte and bh b and at bits and or bl bh place the stuff into al mov bh cs si maxbyte west is one byte left lower and bh b and at bits and or bl bh mov bh cs si east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al inc si inc di middle bytes can be handled in a loop mov cx maxbyte sfl mov bl al is the assembled byte mov bh cs si maxbyte lineno and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte and bh b and at bits and or bl bh place the stuff into al mov bh cs si west is one byte left lower and bh b and at bits and or bl bh mov bh cs si east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al inc si inc di loop sfl last byte is also special mov bl al is the assembled byte mov bh cs si maxbyte lineno and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte and bh b and at bits and or bl bh place the stuff into al mov bh cs si west is one byte left lower and bh b and at bits and or bl bh mov bh cs si maxbyte east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al ret cs si sourse of data cs di destination of data scanlastline first byte is a special case because of warparound mov bl al is the assembled byte mov bh cs si maxbyte and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte lineno and bh b and at bits and or bl bh place the stuff into al mov bh cs si maxbyte west is one byte left lower and bh b and at bits and or bl bh mov bh cs si east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al inc si inc di middle bytes can be handled in a loop mov cx maxbyte sll mov bl al is the assembled byte mov bh cs si maxbyte and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte lineno and bh b and at bits and or bl bh place the stuff into al mov bh cs si west is one byte left lower and bh b and at bits and or bl bh mov bh cs si east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al inc si inc di loop sll last byte is also special mov bl al is the assembled byte mov bh cs si maxbyte and bh b and at bits and or bl bh or them into the assembled byte mov bh cs si maxbyte lineno and bh b and at bits and or bl bh place the stuff into al mov bh cs si west is one byte left lower and bh b and at bits and or bl bh mov bh cs si maxbyte east is one byte right higher and bh b and at bits and or bl bh mov bh mov al byte ptr cs bx offset hpprule mov cs di al inc si inc di ret invert all velocities in the gas invertall push bx push cx push si mov si cs srcptr mov bx mov cx lineno ia push cx mov cx maxbyte ia mov bl cs si mov al byte ptr cs bx offset wallrule mov cs si al inc si loop ia pop cx loop ia pop si pop cx pop bx ret iterateonce mov si cs srcptr mov di cs desptr mov cs srcptr di mov cs desptr si push si push di call scanfirstline pop di pop si add si maxbyte add di maxbyte mov cx lineno dont scan first and last l push si push di push cx call scanonemiddleline pop cx pop di pop si add si maxbyte add di maxbyte loop l push si push di call scanlastline pop si pop di l ret iterate hpp rule cx times iterate push cx call iterateonce pop cx call showgas loop iterate ret iterate hpp rule cx times iterateuntil mov si mov cx offset iu offset iu iu mov al byte ptr cs si offset iu xor byte ptr cs si offset iu al inc si loop iu iu call iterateonce call showgas mov si cs srcptr mov cx maxbyte mov bx mov ah mov al iu mov bl byte ptr cs si mov dl byte ptr cs bx wallrule not ah xor dl ah and al dl inc si loop iu mov si mov cx offset iu offset iu iu mov ah byte ptr cs si offset iu and ah al xor byte ptr cs si offset iu ah inc si loop iu jmp iu iu mov ax offset iu push ax ret db dup h iu push ax push bx push cx push dx push ds mov ah mov dx cs msgptr int h pop ds pop dx pop cx pop bx pop ax ret db dup h msgptr dw offset msg msg db this message is printed out by db code decrypted using data from the lattice db which was applied to the decoding routine db after every time step db the decoding function left the code unchanged db except after the gas evolution had completelly db reversed the thermalization times equ repetitions are enough to equilibrate the gas begin mov ax h mov bh mov dh mov dl mov cx int h mov ah mov bh mov dh mov dl int h call initgas call showgas mov ah int h push cx mov cx times call iterate call invertall call showgas mov ah int h cmp al jne begin mov si cs srcptr xor byte ptr cs si b begin mov cx times call iterateuntil call invertall call showgas mov ax c h int h code ends end start
