/************************************************************ * @(#)MillstoneCryptoModule.java * * Requires: java 1.1.5 (or higher) * * [as e.g. provided in Netscape 4.06] * * References: * * [CS98] Ronald Cramer and Victor Shoup: A practical public key crypto * system provably secure against adaptive chosen ciphertext attack * in proceedings of Crypto 1998, LNCS 1462, p.13ff * * No Copyright (!c) */ import java.math.BigInteger; import java.util.Random; public class MillstoneCryptoModule { /**************************************** * CryptoModule implements the Cramer-Shoup * public key Crypto Algorithm * * If you want to use it, you have to modify this file and * add your own private key. * * see: http://www.verify-it.de/sub/cramer_shoup.html * http://www.verify-it.de/sub/crypter.html * * @author M. Oliver Möller * @version 1.2 Mon Jul 8 10:09:00 2002 */ /************************************************************ * Public and secret keys ************************************************************/ public String keyNameString = "Method: Cramer-Shoup98\nKey-Name: Millstone-5020\nOwner: M. Oliver Moeller \n"; private SecretKey sk; private PublicKey pk; private Random rnd; public MillstoneCryptoModule(){ /**************************************** * Initialize: * Set the keys to personal adjustings ****************************************/ /* * Method: Cramer-Shoup98 * Key-Name: Millstone-5020 * Owner: M. Oliver Moeller */ byte[] p = { 9,15,93,-70,-37,-68,-24,-126,-115,-75,-48,-44,-20,123,-36,58,-26,-125,-62,-96,-127,54,75,-127,51,78,-123,17,13,-77,84,68,53,95,55,48,-1,46,49,117,50,56,-9,-76,52,-33,55,-127,28,125,60,56,97,83,7,25,87,-6,-1,-72,51,-73,58,-65,92,-24,-13,-21,-78,43,-120,49,21,47,17,-112,18,-117,-91,11,125,-119,0,-113,-20,36,-100,-4,-90,62,71,33,60,83,75,-66,58,52,61,-124,-100,99,-115,45,-62,-26,30,80,-15,51,107,104,69,-86,45,-20,91,-106,-84,99,77,-4,17,-63,-39,56,23,-69,-93,9,-5,-97,110,-23,24,79,73,-49,39,-81,-103,0,-34,-89,14,-118,-11,-44,59,73,-26,54,50,3,-120,59,101,-11,16,-33,52,-31,-45,25,-59,12,4,-63,-49,-80,102,77,85,-37,78,99,-95,57,-110,18,52,28,-57,39,31,-113,-120,-96,125,-90,-35,-55,-95,-16,-30,-55,-113,-77,-5,-15,-42,14,-75,-6,86,36,-18,74,-7,53,-61,20,-84,6,-29,51,53,-126,56,101,12,60,-58,-69,3,55,117,-101,82,62,-70,31,-33,90,-48,-79,-88,120,-71,-10,-2,-124,-70,42,-97,12,5,111,61,7,47,-75,40,-62,-34,102,-84,52,48,51,103,-14,41,-54,-99,121,21,39,-24,-123,90,81,74,23,-123,126,74,28,-7,-79,64,-89,-30,-98,-29,-86,74,-33,66,-32,-48,115,99,74,-51,-26,58,-127,52,-51,106,-97,115,-14,-123,73,-128,100,-105,36,-54,-76,99,68,65,-102,71,-27,-46,1,-72,-4,-23,-71,120,76,-73,3,81,78,-63,-26,125,-16,113,73,95,84,-104,33,-55,38,58,118,28,-32,-126,-73,-96,14,-95,-7,-64,-28,103,-47,79,-19,-98,109,96,-88,-97,85,-121,-59,6,100,109,-116,-16,120,3,8,98,-11,66,-109,-119,-67,-44,-113,96,-47,35,8,20,-108,60,-101,84,-42,-1,82,-92,23,69,-118,115,-81,42,-15,3,-51,41,99,47,-125,24,-60,5,91,-13,-115,-99,-66,15,-58,-87,68,55,35,-10,10,37,106,120,52,15,5,68,-111,30,115,-92,-38,16,-56,-23,-48,17,102,87,96,78,-13,79,-128,-100,-16,-65,106,91,-126,108,98,-19,-46,-65,-90,-108,-11,-90,-52,60,34,111,61,-50,-121,-70,1,36,124,-128,72,-107,94,-48,115,-66,-29,1,-92,71,37,-106,0,-53,-17,4,23,-71,-108,92,-68,-122,-19,82,-18,108,-64,41,-114,122,-68,99,-39,-40,104,-42,47,76,-26,-100,-116,71,-35,37,54,87,77,77,-33,-7,57,123,-119,71,6,-125,56,-110,17,-113,-22,-34,-123,46,96,76,-40,-50,-104,-73,-36,-117,-2,79,-91,14,86,25,30,66,-28,73,4,50,106,68,27,6,112,107,-66,-84,45,117,127,6,67,-81,113,70,-83,-70,77,-22,-67,33,52,89,22,75,-120,77,-35,109,86,39,-127,-30,121,-107,-118,-85,-61,70,32,32,-90,-76,10,-58,-26,-111,51,-120,-86,-24,-7,55,-26,34,33,-42,-82,-74,-51,-110,30,3,4,78,-74,-27,59 }; byte[] g1 = { 6,110,-123,38,35,-43,102,-25,28,83,28,-76,-121,-109,-7,-4,-89,97,-40,-109,24,-70,122,-56,14,-72,74,-30,96,-125,66,-93,-100,50,-83,-69,72,-58,7,64,24,104,-29,-75,-56,95,24,30,-23,17,17,-60,-123,107,-21,70,-101,-62,-96,120,46,-20,97,26,2,-2,3,-48,34,-29,-71,-4,-87,-17,53,-15,18,73,112,77,4,17,30,-40,-101,26,39,18,-39,125,57,63,-36,54,127,-107,79,-110,53,-59,-112,-107,-35,-45,-43,-33,25,35,115,75,61,-86,-112,19,57,-1,36,97,28,-61,-103,108,-118,-127,99,64,55,-67,-70,102,38,-25,109,-15,-30,-51,-91,-107,37,76,-42,50,-48,41,-51,69,-82,-126,-79,-51,-75,-42,92,38,16,25,-98,0,35,-12,-44,-84,94,70,10,-119,-15,-55,-33,61,-124,89,62,-50,22,-40,-91,36,41,-4,15,-43,-67,55,98,99,71,57,-12,126,9,-23,-58,-67,-1,-54,-124,-4,-52,77,76,126,55,77,-65,93,-16,70,-99,-121,-55,-8,49,-43,26,13,-128,92,87,-15,-48,98,-77,-8,-27,-55,16,98,-121,-3,106,-36,-2,-1,-77,-90,-107,-54,19,71,-72,-43,-65,40,18,-78,17,34,-92,71,86,87,-42,115,-34,-8,-65,8,-80,48,-26,-12,-4,79,-41,-2,66,-41,-31,-110,-38,-73,-40,100,30,-81,-53,-39,16,90,-94,114,64,3,-85,11,38,-26,-95,-64,-46,-29,-87,38,-29,55,27,20,23,-4,74,27,3,65,76,104,59,71,-100,100,-122,-23,-56,35,-28,12,-76,-43,-57,-26,104,-25,9,121,30,70,62,92,-34,-5,39,-71,-69,27,29,68,44,-23,-6,100,-8,67,99,-59,-46,82,50,-107,74,-100,-27,-38,-37,-117,-6,-112,8,118,87,-80,-80,55,-100,-53,6,-119,-69,65,53,-39,-80,17,47,99,86,104,44,-94,30,-110,-29,-69,25,6,-69,52,119,-113,76,-51,35,-18,19,-61,64,120,-28,-39,-1,-50,-85,87,51,-120,41,39,118,-121,-43,17,-74,81,-107,-58,-87,-10,78,-47,2,-86,25,79,-32,-95,-41,63,-104,59,27,-121,-92,-60,-93,-16,72,57,-42,78,-81,-104,-89,-28,-69,-115,3,-111,33,-85,-94,116,106,-11,-19,-32,81,84,-55,124,-123,-15,12,-50,-121,116,-2,26,-61,-119,-103,85,109,-4,101,-121,73,118,-62,-113,102,-76,-56,101,17,-15,54,92,114,-88,-124,125,-108,-17,-88,-17,-40,6,12,-17,-6,-78,-62,-112,105,-83,-123,30,56,39,-44,-96,107,-45,16,102,103,97,-35,49,-23,51,86,87,6,-56,-86,-95,-59,-87,35,-10,-11,-67,117,-127,37,3,36,96,-56,-111,-52,-56,-52,-91,-56,41,25,20,-122,28,31,58,-3,96,-73,127,7,-128,-112,36,13,44,43,-9,-62,-75,-10,-3,74,-94,114,73,-127,-85,125,75,40,-39,58,124,-32,-20,31,93,-47,93,-124,-82,31,-19,34,-71,-99,-4,57,108,102,-103,-6,-102,15,39,117,84,-98,-94,20,-27,23,-108,-26,49,-81,95,-15,-95,-2,51,55,-113,-13,52,-77,63,-89,74,96,26 }; byte[] g2 = { 0,-83,16,118,-1,76,-80,-13,7,121,-49,102,12,-5,-1,69,62,-62,-96,-32,-96,-76,34,-110,-48,43,122,-4,54,-87,-27,85,25,-81,31,-39,37,54,-112,-8,96,-3,-55,-82,5,124,-83,48,-99,22,-81,32,72,-123,-47,-115,92,-111,-14,-104,-128,-70,45,-57,51,69,73,-37,-65,-57,-39,-92,44,95,-24,0,-48,85,-95,-63,8,7,-99,-16,76,-80,14,61,-10,-127,13,-103,-7,-76,21,-78,119,-23,13,-43,-97,-28,40,120,-67,82,-30,67,-94,2,-67,102,-15,-26,7,-57,102,41,84,-95,-58,27,72,78,127,-26,-48,58,-114,-109,120,111,-2,-52,-105,105,-57,-106,-43,-44,81,90,-51,81,2,91,54,-6,24,114,60,-77,-76,-80,-45,-31,-123,0,2,-123,-13,-105,-68,69,-12,116,99,96,74,-97,-83,1,-15,41,30,-12,3,86,-127,-95,8,37,-82,46,-89,100,-120,43,49,68,91,95,-15,90,126,-83,75,-30,41,41,23,-124,103,52,122,30,-2,-4,-111,2,27,-103,-100,-20,-121,69,-52,104,-73,-69,33,-77,122,-30,33,119,116,-38,-79,-7,44,6,-54,-119,95,1,-72,-61,60,92,-19,-77,-108,-16,53,31,-118,0,91,100,-127,46,117,88,-119,-85,-62,-76,28,95,125,-91,-64,-117,117,-111,-62,51,118,-104,49,-93,38,18,113,27,111,115,27,-9,-48,108,-6,-7,48,-49,9,-1,78,84,17,-2,30,105,-105,-37,-28,-54,-37,69,-8,-36,59,86,83,31,-23,-104,-38,-11,-123,-23,60,-21,-126,113,45,-38,-45,-42,122,74,114,-93,-108,-100,-55,55,37,-27,-91,25,71,-23,14,-111,-26,71,-54,-116,-119,111,91,79,103,87,-88,-34,44,18,-36,111,106,-50,-64,-48,58,-128,-115,-18,-126,3,38,-128,65,122,-112,-2,-16,95,-41,86,-2,87,121,-47,-127,18,3,56,101,-78,98,107,122,-5,111,50,-111,51,101,52,-98,-43,-97,74,21,115,1,72,-14,-80,23,-117,65,63,-113,-26,-75,-127,-112,-58,99,73,-126,115,49,-85,57,90,-73,-7,73,-68,-57,83,-108,70,85,-26,-16,100,11,-21,-21,52,-107,102,98,23,52,-121,39,83,87,-72,28,-26,116,-41,38,-122,83,127,80,87,-37,-10,11,23,107,-58,11,-110,70,-74,-68,17,31,-19,-59,30,2,-13,30,117,-121,-6,13,-83,-41,100,79,-5,69,6,8,109,89,-52,96,-89,-53,32,54,67,-106,-90,94,-3,98,-4,35,-16,29,62,-27,-49,-22,122,34,-122,101,-72,-15,-94,10,-57,13,-11,108,113,26,-91,57,34,-17,-17,55,38,72,-26,-118,12,-27,93,3,31,3,80,-98,34,35,18,47,-50,104,90,30,-55,15,127,116,-40,84,-92,21,-17,-23,33,87,22,55,24,121,-105,87,-4,67,50,51,69,-55,2,-83,78,-120,48,-81,-59,15,71,86,-7,32,81,37,79,100,45,25,-4,-118,-43,-128,-1,-10,72,95,86,1,50,-21,1,-113,-68,-2,-90,-112,-37,-89,105,-17,105,68,-55,54,-107,-26,-1,-83,-108,-95,-42,1,107,9,30 }; byte[] c = { 0,-9,-83,5,97,-24,-3,63,29,116,-113,-80,-93,-18,29,-96,-83,52,-99,-81,102,-33,-52,-121,-32,74,-121,57,-79,-117,29,37,-74,-32,41,21,-12,58,-86,-81,-64,-124,-65,82,123,-57,102,-13,-103,-57,-86,-47,117,117,52,116,-64,-68,38,67,15,70,-72,-3,-54,-74,9,-51,111,1,52,-112,88,95,-34,86,110,-114,119,127,12,-5,33,-13,79,-36,23,59,3,25,-122,-19,53,35,-25,117,-23,-80,73,-18,-94,127,-61,-29,-26,-90,115,-38,-74,23,-123,-23,124,-74,119,-13,-94,41,10,108,68,92,17,57,84,119,-82,7,96,118,42,13,-22,92,-91,32,63,21,-127,70,45,65,-40,112,124,-67,-119,-73,98,-106,116,75,-72,-95,-17,-37,27,44,-84,-15,117,28,124,-73,46,92,33,119,-64,110,96,108,-22,81,-70,122,-52,127,11,120,27,92,-59,121,-48,32,5,15,80,127,20,-24,-101,-43,9,108,-7,-27,-126,-108,46,-6,35,-58,-65,-46,-29,13,59,-116,-24,-75,-77,29,-28,-70,-46,-67,-69,122,32,-60,-91,-1,0,22,-34,-88,18,-118,-64,41,30,-17,110,77,95,-94,24,-82,-69,-97,-11,-51,34,-26,-71,-114,-1,-1,-80,76,-121,42,-82,-48,-98,97,-15,88,66,-88,28,111,-92,102,127,-59,39,63,84,11,33,72,7,81,-47,-25,22,118,71,-35,56,125,-74,-64,99,16,-9,-119,64,-1,27,-93,-63,-47,-13,-81,123,64,63,81,30,124,36,81,50,-56,-126,110,-13,-32,119,-10,-2,-62,-44,-101,-7,-111,0,68,105,-89,116,120,-81,-115,-20,-6,-127,40,-83,-32,41,115,60,-100,26,-79,22,-121,98,26,24,-37,86,-41,124,83,65,-36,-14,-57,-76,-25,62,-108,-71,-28,-103,34,-77,112,80,81,34,-113,-5,113,25,-13,-43,99,-52,-85,91,-81,72,5,-127,18,-71,-61,-26,88,121,-39,47,-103,-128,-92,-76,-58,-32,-65,69,78,113,31,-99,-39,67,30,64,-16,-110,-114,-115,-10,-121,74,4,-48,-79,-48,-105,72,93,-103,-51,-44,-115,20,3,24,100,66,105,85,90,-14,0,-105,33,-13,-9,-86,87,104,-94,-77,77,-93,14,20,40,-58,8,-96,119,-21,-25,-92,-27,-106,-64,10,-21,101,120,72,81,-23,91,23,-23,-103,105,-107,-81,-127,-24,55,35,97,30,57,102,104,-18,108,-56,-84,21,-92,74,-49,47,-114,-56,88,64,53,40,-55,52,41,60,80,17,33,43,-125,-58,59,24,80,-17,-54,-10,-42,-4,-1,-91,101,4,-38,54,103,-77,87,-58,3,122,-120,68,44,114,-5,-101,106,3,-64,-82,118,-4,-67,-41,-102,-20,-35,5,-38,-124,-20,-109,-12,-42,102,84,-74,-26,-116,-53,-3,76,-9,-55,-14,73,-3,-45,-26,-32,-128,51,40,-50,58,-4,-30,-108,17,109,-26,36,-114,-35,62,104,53,6,-29,37,-31,-85,102,41,87,121,94,-66,-68,-68,-75,116,105,60,34,127,-74,-100,41,51,67,-7,27,-27,97,61,49,-105,-22,5,-67,-115,71,-51,-72,39,115,-44,-85,-12,70,-48,-52 }; byte[] d = { 7,90,119,-69,21,-115,17,-22,-47,17,20,-3,-28,-89,18,-45,-90,-96,73,-80,92,-11,64,-53,-85,77,97,14,-99,70,-38,-72,85,7,52,40,43,88,-63,119,-80,-48,-62,87,72,119,39,-18,-13,-45,-103,107,-41,114,-37,-64,-56,-25,118,-126,118,-119,62,-11,-77,25,10,95,19,-122,-13,100,-31,75,-33,-33,-81,45,-63,-26,-120,40,-76,11,87,-118,-48,-53,-24,-126,-81,110,103,101,26,5,40,103,-96,-51,85,2,14,113,112,75,-110,38,-22,-9,-5,-93,90,51,-42,-68,-54,42,-23,80,71,-108,-24,37,55,58,-33,70,9,-114,99,-23,122,-72,-121,-66,46,-118,-42,-75,56,30,89,-88,7,-99,-95,104,-128,96,-60,-98,50,1,29,59,-9,-70,29,-125,-57,-126,124,121,96,117,13,-25,65,74,104,34,23,-53,-80,52,-47,-84,10,36,-125,81,-37,84,80,119,-40,87,-50,-80,-47,-78,-115,91,-107,-109,-13,127,9,-72,18,119,79,86,-24,-10,-53,61,-8,-125,89,-122,72,-122,-20,22,-115,-12,88,-41,63,-108,-32,-97,85,12,120,62,47,-54,-23,-75,123,15,34,60,-39,-29,53,43,35,42,127,41,-103,119,-36,124,117,18,-104,-98,95,75,20,-71,-68,115,2,-124,41,86,-54,78,-105,-62,13,40,-116,-123,-48,102,93,-84,60,-83,1,24,123,-127,-80,83,-104,-42,57,68,51,106,46,-32,116,74,-85,-111,68,54,-38,97,-76,68,-125,-40,99,-46,-40,107,-50,62,7,-24,103,97,-42,-65,122,-56,-103,24,86,26,97,-70,-56,-116,-27,90,-93,-99,-18,-59,-24,18,-10,100,-28,-9,104,-113,88,-53,-90,28,43,13,17,-18,-79,25,84,68,-86,2,-71,76,-61,53,-58,-29,79,-82,12,-104,-52,-107,45,-94,-36,95,-67,-42,-113,-114,-121,-119,-21,-81,-103,102,-70,-78,32,51,-118,-24,-31,-26,26,109,32,114,-22,70,-120,-74,-82,78,13,12,124,-29,35,-110,86,32,116,-30,-117,79,-23,123,9,50,-67,39,59,-34,38,-120,-127,6,41,3,105,-10,-107,-41,-89,-117,109,-66,82,-107,111,-31,-34,36,-31,63,23,59,-113,22,4,-23,120,-24,-120,-17,111,-101,-32,-70,124,-21,44,6,-43,-9,69,-114,-54,19,30,-45,125,-35,-47,-112,71,-128,-46,114,-17,86,103,-76,30,36,-54,-118,69,-42,-80,-89,54,-13,25,9,2,-78,83,101,-20,41,2,121,-8,126,-100,77,-26,-49,51,-14,-28,124,77,28,-2,-122,108,-10,-79,125,45,12,-110,-34,-37,-115,99,53,-43,-39,-16,-43,40,-33,-18,-25,60,-79,-122,-42,-94,31,-34,-59,-67,-36,-73,70,77,-112,4,-89,-120,41,23,61,127,-44,2,-58,-128,-88,-26,-122,75,-70,124,-94,-124,76,5,32,90,17,107,34,-36,92,47,122,-18,-46,13,-88,46,52,-12,-104,-99,64,-23,-31,-123,-107,30,103,124,6,8,112,125,21,-9,40,90,-35,-106,17,19,-38,75,113,-44,75,-39,23,89,127,36,-73,-2,127,67,17,61,122,-118,12,71,-104,58,97,118,-52 }; byte[] h = { 4,112,-55,78,86,-85,-112,-63,-39,-53,9,2,-123,-58,-120,30,-37,50,39,41,103,-104,47,22,-101,80,-126,49,28,-16,-123,85,-110,122,99,26,92,-77,96,9,-58,-11,-106,-36,11,59,-119,-107,31,45,14,1,-94,-86,66,-115,6,50,-47,33,61,-96,-71,-51,-42,101,96,33,126,127,60,94,-127,78,-105,28,-95,-103,-14,-106,32,-22,-57,-71,-42,-98,-8,93,-4,55,37,-76,-29,-75,86,-38,-54,-84,-23,127,-13,0,-46,-36,-83,-7,97,-121,102,-63,103,-78,102,68,-68,28,65,11,-46,100,-125,8,114,-108,89,-100,-110,7,-108,126,-84,6,-66,-56,-84,34,116,76,-81,58,-89,22,-4,51,-33,9,-113,37,119,-119,44,118,10,39,-55,4,85,33,18,-83,-24,9,16,-11,-49,-117,-52,97,-24,107,-68,-44,35,-55,7,-114,-47,114,84,32,-88,-60,-69,-54,44,-116,-49,-10,-1,-55,-3,13,28,94,-120,-29,-122,103,20,-74,124,113,-22,42,116,-3,-56,93,53,35,-88,-55,126,112,33,-76,-29,45,-41,-15,108,31,-126,48,-103,-13,-6,8,60,-77,-35,21,-110,-67,42,113,-64,52,93,36,-125,107,-37,-42,-120,65,-6,-110,2,-59,74,-45,42,97,-121,51,72,-16,8,-76,-28,-8,-35,64,-26,-61,-104,-60,100,57,80,58,57,-52,37,116,-64,57,32,5,-71,33,36,43,-86,21,127,-105,-68,82,13,98,-47,33,60,-23,-86,-63,-44,65,-109,-12,76,16,69,-8,-50,87,81,7,77,61,-83,-116,-53,87,118,100,44,51,25,-67,-41,123,90,-88,-11,-25,-106,-26,-57,126,109,-46,-13,73,-56,-100,60,6,-128,96,33,-21,101,-50,-60,-108,64,58,7,-22,18,-65,60,57,61,50,-50,45,19,-124,-39,-121,-125,-67,-94,-31,-94,-103,-21,-17,92,35,109,16,-40,-16,24,65,-23,22,-32,43,-107,13,77,-85,32,-96,-92,17,61,37,-93,-23,11,0,27,-50,67,-37,3,-11,62,87,-14,-9,-79,120,82,98,-94,-41,-126,-44,0,-61,109,50,16,99,30,97,14,75,-29,18,6,-90,32,-108,123,-9,-10,110,58,-39,-68,-37,11,-93,-9,100,-10,-121,8,-60,-7,71,79,-59,120,-37,13,108,-105,5,-88,-114,-23,-55,87,82,32,-31,107,-42,-115,49,126,77,28,-105,-50,-27,-14,39,-111,91,102,-94,123,97,-62,4,55,94,-69,88,-33,-12,-2,-103,108,-85,-99,-99,127,-2,-52,-8,-117,-128,72,29,-120,111,-24,-54,-59,38,-78,122,63,91,63,88,81,-15,112,-16,-42,-99,-90,-69,92,-118,-5,-92,-38,-9,-94,-79,-77,37,-35,-4,48,68,123,-6,-33,56,53,-93,54,-55,28,-2,5,2,95,-73,-125,91,86,67,93,-109,-11,94,-14,-65,-108,-4,-104,-80,-30,63,-60,86,107,-72,-70,106,-111,3,1,29,122,12,-54,30,18,-91,45,75,77,-53,-68,20,16,51,-30,8,96,3,32,-1,27,-10,-66,-95,103,126,113,-21,104,125,-62,-78,-21,14,60,-79,127,-53,17,-39,50,12,99,-72,25,35,-82,-88 }; byte[] hg1 = { 4,65,5,-26,-111,35,-41,86,-90,-101,-119,78,-128,-85,106,50,-49,-82,88,-94,44,40,43,109,-57,-77,-115,81,18,73,-85,-82,57,105,-71,61,-79,79,62,82,86,-96,42,9,-17,-84,-128,-96,80,-10,115,-1,86,-7,-29,70,90,-76,74,-124,39,114,-7,-77,-19,-65,-74,-21,1,102,37,-6,-64,-14,-10,55,10,55,-51,-84,-55,5,14,-91,-55,55,-16,40,-30,-94,-86,11,30,-90,-34,51,-94,-60,-17,-62,-2,-92,-22,125,-92,72,-109,15,-60,67,115,-105,42,-22,0,11,23,2,-23,-81,78,-27,112,17,38,11,69,20,80,-54,91,93,15,109,-110,14,90,7,-24,101,22,26,-42,52,114,-69,-103,104,121,123,57,17,33,-26,-33,-100,-30,-106,94,36,-86,4,116,-58,-75,-85,-16,95,16,108,72,71,-51,-84,-81,-64,-26,-91,69,10,-81,54,62,-62,84,-108,116,-43,111,-11,68,53,-107,-32,77,7,-39,87,-52,-117,36,-40,12,125,1,-108,-40,89,-22,-119,108,119,-92,65,-25,-85,-88,-122,69,81,87,2,-106,-88,60,-40,2,-124,114,-70,0,14,113,56,-78,21,24,-107,30,98,-114,17,-86,102,16,-104,124,65,-24,100,-107,-25,-99,-47,-108,25,-69,91,67,-96,56,86,-58,-5,-99,22,-58,-49,-111,-54,-44,85,74,-23,-85,64,-61,65,51,70,85,-117,-14,-3,-11,14,112,-79,105,110,-52,8,37,-109,-47,-81,120,-109,93,-34,-69,-102,18,-31,-73,37,2,22,84,-110,112,36,-64,6,94,35,125,78,111,-126,110,-52,54,-37,16,-26,65,-41,24,-58,-118,-59,16,-60,71,-109,75,16,-96,17,111,-75,-43,-124,55,102,101,-96,-40,102,19,-82,56,93,85,-127,4,-40,34,-59,-128,-36,-64,-27,-25,-118,-104,-13,-93,-53,101,60,26,-4,33,7,-95,-16,16,-112,61,66,-120,98,11,-86,49,-125,19,33,-60,107,92,-32,-105,-53,101,112,73,-36,11,-12,-73,92,-57,29,-114,92,-80,21,91,107,-40,-125,-42,-99,109,94,29,105,-70,9,6,-73,-39,70,-32,-44,-25,-101,-97,-50,127,86,-20,15,120,-8,81,-38,37,63,25,59,-26,-43,101,-81,61,-92,-72,-71,77,53,22,97,6,14,101,26,63,23,-10,-92,-21,-72,-108,-58,-2,-40,119,-47,79,-25,79,67,-57,-22,31,121,77,42,-100,87,71,46,17,42,-89,48,14,81,-92,35,52,21,-66,124,77,47,-62,108,22,55,1,112,104,-126,-49,71,54,94,-54,104,111,53,-89,-15,-49,53,-124,49,-32,-4,90,8,-55,-83,121,13,56,-36,13,121,111,24,-5,79,-48,91,-23,80,104,-41,20,89,61,-77,-124,-86,125,104,-31,53,111,-119,-128,-123,23,95,-57,-20,3,97,-56,111,124,-88,-83,-109,1,-112,-64,-5,-45,-36,-35,66,65,-32,7,-67,105,71,-27,49,-103,-70,-107,-18,-97,86,73,8,-47,124,34,-44,-84,66,72,-13,62,-50,-5,-81,-63,91,-60,47,-65,-122,89,-57,-57,94,27,14,-67,50,6,94,10,81,-47,-2,-110,-124 }; byte[] hg2 = { 4,119,31,-122,-117,79,-34,50,-122,3,96,24,-62,-33,-56,119,-24,-93,71,97,98,5,67,-7,-127,-81,-22,52,-11,17,-39,108,115,-121,107,-55,7,-93,9,-32,13,-55,-104,-112,-102,-104,91,-1,84,110,88,-118,88,122,-52,-15,59,4,-36,3,-49,70,-54,101,18,63,98,-64,101,118,-8,-116,33,107,69,-73,104,35,45,115,123,107,60,-13,71,20,-6,-76,-86,46,28,-112,-30,0,-59,-127,24,-42,120,-115,-72,-86,-34,-68,58,-2,-82,68,124,54,7,-108,114,-66,-75,31,30,-64,1,-80,-97,125,112,55,-59,-15,121,60,-73,45,-62,119,-1,105,57,58,98,105,-79,70,29,74,-52,53,-80,-18,72,-14,-94,87,39,-109,100,74,-33,-118,-104,84,-4,-67,52,109,99,5,-107,-71,52,-107,11,-31,-124,-39,19,-10,64,-39,-84,-127,-41,-43,-20,60,-122,-58,-75,-60,-28,-125,11,-63,-21,0,-41,127,40,108,44,-105,41,37,64,26,-38,30,-64,41,27,-99,-97,-40,-128,0,68,-88,114,92,34,24,103,-84,-113,54,-70,-93,94,-121,-87,16,-128,107,-109,-94,-102,93,104,-62,115,-60,-68,-81,72,-69,19,93,-8,90,-58,30,-33,17,95,-15,64,104,-12,32,-5,-112,-108,123,90,55,-30,48,40,-96,49,85,-126,6,97,110,110,-121,-15,36,-52,-118,35,38,1,3,-87,-92,3,-113,82,-56,-95,-23,121,-55,121,34,-119,-23,92,19,72,-9,-20,-49,-124,-90,-22,-32,-86,-9,-19,109,121,81,-115,-28,32,5,-124,114,26,125,42,9,-74,-5,110,118,19,19,37,83,1,35,82,-100,4,15,-92,-97,83,22,-52,40,54,108,121,-27,-88,115,95,120,-58,-106,-128,14,-32,99,-46,-67,76,-18,21,78,111,-116,-54,50,26,18,-4,7,122,-17,6,48,-106,101,118,13,60,-121,-117,-111,-85,-75,-110,37,48,-88,53,121,72,-40,-61,13,-43,107,5,-35,19,-25,1,59,89,46,-50,-34,-57,39,-7,-47,-19,108,-67,-125,-20,-128,-13,-50,33,-112,-114,12,-29,-31,100,28,58,73,-80,78,105,17,-123,70,-40,-107,-118,-34,76,88,113,-18,79,-76,22,16,30,83,-48,-93,-38,50,-107,-34,122,51,15,-18,45,-1,-115,-70,-92,-114,16,101,107,30,68,44,-112,-42,-19,54,74,89,115,47,-75,-93,-50,-88,48,81,106,-14,75,127,-72,-69,37,-70,-118,76,-35,74,-64,83,-58,5,-99,-23,18,-88,-30,-72,-78,62,49,19,-74,61,111,-77,-5,-59,73,-90,13,112,-6,114,108,52,-70,-22,35,68,117,32,-110,-112,-32,40,56,-85,56,-87,126,-14,16,30,45,-10,-1,4,-69,23,100,-55,-1,-100,-74,17,-103,52,71,91,-120,-124,-97,-5,0,32,122,-126,-79,54,-108,-112,10,115,-111,-83,-23,92,127,-78,65,89,-69,-82,33,-29,38,-63,29,82,1,-8,52,-115,105,24,-110,6,-14,-99,-82,46,108,-8,8,-117,18,-105,-1,117,88,-115,-51,-43,-65,-15,114,-32,56,64,97,79,-5,-7,44,-102,84,28,62,-98 }; /* * Secret Key components start here ( disabled ) */ byte[] x1 = { 0 }; byte[] x2 = { 0 }; byte[] y1 = { 0 }; byte[] y2 = { 0 }; byte[] z = { 0 } ; //**************************************** pk = new PublicKey(5020,p,g1,g2,c,d,h,hg1,hg2); sk = new SecretKey(5020,p,x1,x2,y1,y2,z,hg1,hg2); /**************************************** * A toy pair of valid secret and public keys... * if you copy this java source, you can use those to play around. byte[] p = { 8,15 }; byte[] g1 = { 2,-79 }; byte[] g2 = { 2,-111 }; byte[] c = { 3,22 }; byte[] d = { 2,-24 }; byte[] h = { 3,-90 }; byte[] hg1 = { 3,41 }; byte[] hg2 = { 1,-75 }; byte[] x1 = { 6,-45 }; byte[] x2 = { 7,-87 }; byte[] y1 = { 3,55 }; byte[] y2 = { 2,-127 }; byte[] z = { 1,-25 }; pk = new PublicKey(12,p,g1,g2,c,d,h,hg1,hg2); sk = new SecretKey(12,p,x1,x2,y1,y2,z,hg1,hg2); ****************************************/ /**************************************** * Initiatize random generator ****************************************/ rnd = new Random(); } /************************************************************ * Converter Methods ************************************************************/ private BigInteger bits2BigInteger(boolean[] bits){ int len = bits.length; byte[] bytes = new byte[2 + (len/8)]; int b; int index = 1+ len/8; int bitIndex = 0; // in bits: least significant bit comes first // in bytes: most significant bit is first! bytes[0] = 0; // play safe - we do not want a negative number... bytes[1] = 0; while(bitIndex127)b = b - 256; bytes[i] = (byte)b;} bytes[0] = 1; return new BigInteger(bytes); }; private boolean[] bitListOne(int k, BigInteger b1){ // LEAST significant bits first... boolean[] res = new boolean[k]; int i; int index = 0; for(i = 0; i