29.07.2013 Views

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RSABlindingFactor bf = createBlindingFactor();<br />

byte[] t = FileHandler.writeObject(ballot);<br />

BlindFingerprint bfp = blind(publ, bf, Fingerprint.create(t, 0, t.length,<br />

"SHA1"));<br />

BlindSignature bs = blindSign(priv, bfp);<br />

org.logi.crypto.sign.Signature signed = unblind(publ, bs, bf);<br />

boolean ok = verify(publ, signed, ballot);<br />

Debugger.debug(className, 3, "Verifying blind signature (true)? = " + ok); //must<br />

return true<br />

org.logi.crypto.sign.Signature signedNormal = sign(priv, ballot);<br />

ok = equals(signed.getBytes(), signedNormal.getBytes());<br />

Debugger.debug(className, 3, "Testing blind signature = signature (true)? = " +<br />

ok); //must return true<br />

ballot.setType(Coin.C_TYPE); //corrupting data<br />

// ballot[0] = 4;<br />

boolean ok2 = verify(publ, signed, ballot);<br />

Debugger.debug(className, 3, "Testing blind signature functions completed<br />

successful(false)? = " + ok2); //must return false<br />

org.logi.crypto.sign.Signature signed2 = sign(priv, ballot);<br />

boolean ok3 = verify(publ, signed2, ballot);<br />

Debugger.debug(className, 3, "Testing blind signature functions completed<br />

successful(true)? = " + ok3); //must return true<br />

}<br />

public static boolean equals(byte[] a, byte[] b)<br />

{<br />

if(a.length != b.length)<br />

return false;<br />

}<br />

for(int i = 0; i < a.length; i++)<br />

if(a[i] != b[i])<br />

return false;<br />

return true;<br />

public static String hexDigit(byte x)<br />

{<br />

StringBuffer sb = new StringBuffer();<br />

char c;<br />

// First nibble<br />

c = (char) ((x >> 4) & 0xf);<br />

if(c > 9)<br />

{<br />

c = (char) ((c - 10) + 'a');<br />

}<br />

else<br />

{<br />

c = (char) (c + '0');<br />

}<br />

sb.append(c);<br />

// Second nibble<br />

c = (char) (x & 0xf);<br />

if(c > 9)<br />

{<br />

c = (char) ((c - 10) + 'a');<br />

}<br />

else<br />

{<br />

c = (char) (c + '0');<br />

}<br />

sb.append(c);<br />

return sb.toString();<br />

}<br />

390

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!