Skip to content

Instantly share code, notes, and snippets.

View chris-gc's full-sized avatar

Christopher A. Taylor chris-gc

View GitHub Profile
@chris-gc
chris-gc / gf256
Created January 15, 2014 22:02
Efficient, simple GF(256) math
//// Utility: GF(256) Multiply and Divide functions
/*
Branchless multiply and divide construction from
"Fast Software Implementations of Finite Field Operations (Extended Abstract)"
by Cheng Huang and Lihao Xu
Small corrections made to paper (Q = 255):
+ The EXP_TABLE needs to have 512*2+1 elements to handle 0*0 = 0 case.
+ Element 255*2 should be set to 1.

Where To Go From Here?

Before we set you loose, we have a few suggestions for how to avoid some common pitfalls when writing JavaScript games. First off you'll want to use the Chrome debugging tools. Secondly: Be sure not to try to delete Views after you create them since it is easy to make mistakes. Finally, consider using the blockEvents property to improve performance.

Debugging Tools

With the Chrome browser you already have a great set of JavaScript debugging tools when you're using the web simulator. Check out the Google Developers page for Chrome Developer Tools to get more information on how to make the most of the toolset.

You are able to set breakpoints, step, and inspect any of your JS variables. Chrome also has the best heap and CPU profiling tools available in our opinion and makes finding performance hotspots easy.

@chris-gc
chris-gc / gist:9194660
Last active August 29, 2015 13:56
PFS Key Ratchet
And I have a design specced out for adding PFS to Calico without
adding any overhead:
The problem is that right now Calico never rekeys. So long encrypted
communications, if one side is compromised, can be decrypted from the
start. To allow for future secrecy, rekeying will be added controlled
by the client automatically on a timer.
Right now I'm using 24 bits for the IV. This is actually pretty excessive.
But 16 bits is not enough.
import device;
exports.TARGET_WIDTH = 576;
// fixed aspect ratio for main content area
exports.CONTENT_RATIO = 2 / 3;
// maximum aspect ratio for background image
exports.BG_RATIO = 9 / 16;