private void initSign(){
  messDigestTrees.reset();
  GMSSPrivateKeyParameters gmssPrivateKey=(GMSSPrivateKeyParameters)key;
  if (gmssPrivateKey.isUsed()) {
    throw new IllegalStateException("Private key already used");
  }
  if (gmssPrivateKey.getIndex(0) >= gmssPrivateKey.getNumLeafs(0)) {
    throw new IllegalStateException("No more signatures can be generated");
  }
  this.gmssPS=gmssPrivateKey.getParameters();
  this.numLayer=gmssPS.getNumOfLayers();
  byte[] seed=gmssPrivateKey.getCurrentSeeds()[numLayer - 1];
  byte[] OTSSeed=new byte[mdLength];
  byte[] dummy=new byte[mdLength];
  System.arraycopy(seed,0,dummy,0,mdLength);
  OTSSeed=gmssRandom.nextSeed(dummy);
  this.ots=new WinternitzOTSignature(OTSSeed,digestProvider.get(),gmssPS.getWinternitzParameter()[numLayer - 1]);
  byte[][][] helpCurrentAuthPaths=gmssPrivateKey.getCurrentAuthPaths();
  currentAuthPaths=new byte[numLayer][][];
  for (int j=0; j < numLayer; j++) {
    currentAuthPaths[j]=new byte[helpCurrentAuthPaths[j].length][mdLength];
    for (int i=0; i < helpCurrentAuthPaths[j].length; i++) {
      System.arraycopy(helpCurrentAuthPaths[j][i],0,currentAuthPaths[j][i],0,mdLength);
    }
  }
  index=new int[numLayer];
  System.arraycopy(gmssPrivateKey.getIndex(),0,index,0,numLayer);
  byte[] helpSubtreeRootSig;
  subtreeRootSig=new byte[numLayer - 1][];
  for (int i=0; i < numLayer - 1; i++) {
    helpSubtreeRootSig=gmssPrivateKey.getSubtreeRootSig(i);
    subtreeRootSig[i]=new byte[helpSubtreeRootSig.length];
    System.arraycopy(helpSubtreeRootSig,0,subtreeRootSig[i],0,helpSubtreeRootSig.length);
  }
  gmssPrivateKey.markUsed();
}

private void initSign ( ) { messDigestTrees . reset ( ) ; GMSSPrivateKeyParameters gmssPrivateKey = ( GMSSPrivateKeyParameters ) key ; if ( gmssPrivateKey . isUsed ( ) ) { throw new IllegalStateException ( "Private key already used" ) ; } if ( gmssPrivateKey . getIndex ( 0 ) >= gmssPrivateKey . getNumLeafs ( 0 ) ) { throw new IllegalStateException ( "No more signatures can be generated" ) ; } this . gmssPS = gmssPrivateKey . getParameters ( ) ; this . numLayer = gmssPS . getNumOfLayers ( ) ; byte [ ] seed = gmssPrivateKey . getCurrentSeeds ( ) [ numLayer - 1 ] ; byte [ ] OTSSeed = new byte [ mdLength ] ; byte [ ] dummy = new byte [ mdLength ] ; System . arraycopy ( seed , 0 , dummy , 0 , mdLength ) ; OTSSeed = gmssRandom . nextSeed ( dummy ) ; this . ots = new WinternitzOTSignature ( OTSSeed , digestProvider . get ( ) , gmssPS . getWinternitzParameter ( ) [ numLayer - 1 ] ) ; byte [ ] [ ] [ ] helpCurrentAuthPaths = gmssPrivateKey . getCurrentAuthPaths ( ) ; currentAuthPaths = new byte [ numLayer ] [ ] [ ] ; for ( int j = 0 ; j < numLayer ; j ++ ) { currentAuthPaths [ j ] = new byte [ helpCurrentAuthPaths [ j ] . length ] [ mdLength ] ; for ( int i = 0 ; i < helpCurrentAuthPaths [ j ] . length ; i ++ ) { System . arraycopy ( helpCurrentAuthPaths [ j ] [ i ] , 0 , currentAuthPaths [ j ] [ i ] , 0 , mdLength ) ; } } index = new int [ numLayer ] ; System . arraycopy ( gmssPrivateKey . getIndex ( ) , 0 , index , 0 , numLayer ) ; byte [ ] helpSubtreeRootSig ; subtreeRootSig = new byte [ numLayer - 1 ] [ ] ; for ( int i = 0 ; i < numLayer - 1 ; i ++ ) { helpSubtreeRootSig = gmssPrivateKey . getSubtreeRootSig ( i ) ; subtreeRootSig [ i ] = new byte [ helpSubtreeRootSig . length ] ; System . arraycopy ( helpSubtreeRootSig , 0 , subtreeRootSig [ i ] , 0 , helpSubtreeRootSig . length ) ; } gmssPrivateKey . markUsed ( ) ; }
initializes the signature algorithm for signing a message .
