Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Encryption using solitaire?

Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
01-22-2008 08:59
I'm currently reading Neil Stephenson's «Cryptonomicon» where a encryption method called «solitaire» is described, which was invented by Bruce Schneier...

It looks kinda promising and I found a link to a javascript implementation on Bruce's Homepage (http://www.schneier.com/solitaire.html)...

Did anyone try to implement this in SL? is it even practicable?
RobbyRacoon Olmstead
Red warrior is hungry!
Join date: 20 Sep 2006
Posts: 1,821
01-22-2008 09:57
Decent encryption in LSL is really not possible as far as I've seen.

There have been some excellent attempts at it, but even the best attempts are slow and memory-intensive. Looking at the javascript implementation, right off the bat I see that it would require significant list and string processing, two thing which LSL is particularly poor at.

Take the shuffle() method as an example:
CODE


function shuffle(){

var used=new Array(54);
for(i=0;i<54;i++){used=0}

for(i=0;i<54;i++){
deck=Math.ceil(54*Math.random());
while(used[deck]==1){
deck=Math.ceil(54*Math.random());
}
used[deck]=1;
}
document.forms[0].deckarea.value=deck;

}


This simple code requires four assignments to an array element. There's no efficient way to do this in LSL, and nearly all of the methods in that implementation require this. Even if you don't run out of memory in the attempt it's likely to be prohibitively slow.

Of course those are just my initial thoughts, and I've not really tried to make it work, so it's possible someone will prove me wrong and come up with a great implementation. I hope that's true, and I'd love to see it.

[EDIT] Oh... Actually, that code will make a great deal more than just four array assignments, I only counted the number of lines of code where an assignment occurs, but it's a loop :)
_____________________
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-22-2008 13:41
Actually I think you COULD implement it in LSL pretty easily. Only one list/deck is required to be kept in memory, and any single operation on it will require at most twice the memory of this list (and you can probably use tricks to reduce this).

The real question is WHY you would want to implement this in LSL. The algorithm really uses what's called a one-time pad, and an algorithm for generating it and using it to produce longer sequences of characters for use in encryption. You could just as easily do this without using the exact algorithm described. For example:

1. Take a list of the alphabetical characters (it should contain all the characters, but may contain duplicates; the deck of cards used in "Solitaire" contains two of each character) and shuffle them.
2. Use an established predetermined pseudo-random number generator with an agreed upon starting seed.

The order of the characters in 1. and the seed in 2. can be your key.

3. Generate pseudo-random numbers, and use them to index the list of characters. Use them to encrypt your plaintext message by adding as described for the "Solitaire" algorithm.

With the right choice of pseudo-random number generation algorithms, this should be as secure (probably more so) as "Solitaire," the difference being that you wouldn't want to compute pseudo-random numbers by hand.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
This is the way to go...
01-22-2008 15:26
Use a deck made of 52 separate objects, and have them physically move around in the deck. That way you don't have to use lists, and you have something that looks really cool at the end.
_____________________
So many monkeys, so little Shakespeare.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
01-22-2008 21:33
Sure I'll do an LSL implementation of Solitaire, it will be fun.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
02-28-2008 15:21
From: Strife Onizuka
Sure I'll do an LSL implementation of Solitaire, it will be fun.


So hows that lsl version coming along.
_____________________