 
 func vn(_ x:[Int], _ xi:Int, _ y:[Int], _ yi:Int, _ n:Int) -> Int {
     var d: Int = 0
-	for i in 0..<n {
-		d = d | ( x[xi+i] ^ y[yi+i] )
-	}
-	return (1 & ( (d - 1 ) >>> 8 ) ) - 1
+    for i in 0..<n {
+        d = d | ( x[xi+i] ^ y[yi+i] )
+    }
+    return (1 & ( (d - 1 ) >>> 8 ) ) - 1
 }
 
 func crypto_verify_32(_ x:[Int], _ xi:Int, _ y:[Int], _ yi:Int) -> Int {

  for i in 0..<32 {
    sm[32 + i] = sk[i]
  }
  	
  _ = crypto_hash(&r, Array(sm[32..<sm.count]), n+32)
      
  reduce(&r)

    var b: Int
    var c: Int
    var d: Int
    
    var ah = [Int](repeating: 0, count: 8)
    var al = [Int](repeating: 0, count: 8)
    for i in 0..<8 {
        ah[i] = hh[i]
        al[i] = hl[i]
    }
    
    var pos = 0
    var n = _n      
    while (n >= 128) {
       
        for i in 0..<16 {        
          let j = 8 * i + pos
          wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3]
          wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7]
        }
                
        for i in 0..<80 {
          for j in 0..<7 {
            bh[j] = ah[j]
            bl[j] = al[j]
          }       

          // add
          h = ah[7]
          l = al[7]

          a = l & 0xffff; b = l >>> 16
          c = h & 0xffff; d = h >>> 16

          // Sigma1
          h = ((ah[4] >>> 14) | (al[4] << (32-14))) ^ ((ah[4] >>> 18) | (al[4] << (32-18))) ^ ((al[4] >>> (41-32)) | (ah[4] << (32-(41-32))))
          l = ((al[4] >>> 14) | (ah[4] << (32-14))) ^ ((al[4] >>> 18) | (ah[4] << (32-18))) ^ ((ah[4] >>> (41-32)) | (al[4] << (32-(41-32))))
                      
          a += l & 0xffff
          b += l >>> 16
          c += h & 0xffff
          d += h >>> 16

          // Ch
          h = (ah[4] & ah[5]) ^ (~ah[4] & ah[6])
          l = (al[4] & al[5]) ^ (~al[4] & al[6])

          a += l & 0xffff; b += l >>> 16
          c += h & 0xffff; d += h >>> 16

          // K
          h = Int( getInt32( K[i*2] ) )
          l = Int( getInt32( K[i*2+1] ) )

          a += l & 0xffff
          b += l >>> 16
          c += h & 0xffff
          d += h >>> 16

          // w
          h = wh[i%16]
          l = wl[i%16]

          a += l & 0xffff
          b += l >>> 16
          c += h & 0xffff
          d += h >>> 16

          b += a >>> 16
          c += b >>> 16
          d += c >>> 16

          // *** R
          // th = c & 0xffff | ( d << 16 )
          // tl = a & 0xffff | ( b << 16 )
          th = c & 0xffff | d << 16 
          tl = a & 0xffff | b << 16 
         
          // add
          h = th
          l = tl

          a = l & 0xffff
          b = l >>> 16
          c = h & 0xffff
          d = h >>> 16

          // Sigma0
          h = ((ah[0] >>> 28) | (al[0] << (32-28))) ^ ((al[0] >>> (34-32)) | (ah[0] << (32-(34-32)))) ^ ((al[0] >>> (39-32)) | (ah[0] << (32-(39-32))))
          l = ((al[0] >>> 28) | (ah[0] << (32-28))) ^ ((ah[0] >>> (34-32)) | (al[0] << (32-(34-32)))) ^ ((ah[0] >>> (39-32)) | (al[0] << (32-(39-32))))

          a += l & 0xffff
          b += l >>> 16
          c += h & 0xffff
          d += h >>> 16

          // Maj
          h = (ah[0] & ah[1]) ^ (ah[0] & ah[2]) ^ (ah[1] & ah[2])
          l = (al[0] & al[1]) ^ (al[0] & al[2]) ^ (al[1] & al[2])

          a += l & 0xffff; b += l >>> 16
          c += h & 0xffff; d += h >>> 16

          b += a >>> 16
          c += b >>> 16
          d += c >>> 16

          bh[7] = (c & 0xffff) | (d << 16)
          bl[7] = (a & 0xffff) | (b << 16)

          // add
          h = bh[3]
          l = bl[3]

          a = l & 0xffff
          b = l >>> 16
          c = h & 0xffff
          d = h >>> 16

          h = th
          l = tl

          a += l & 0xffff
          b += l >>> 16
          c += h & 0xffff
          d += h >>> 16

          b += a >>> 16
          c += b >>> 16
          d += c >>> 16

          bh[3] = (c & 0xffff) | (d << 16)
          bl[3] = (a & 0xffff) | (b << 16)

          for j in 0..<8 {
              let k = ( j + 1 ) % 8
              ah[k] = bh[j]
              al[k] = bl[j]
          }
          
          if (i % 16 == 15) {
            for j in 0..<16 {
              // add
              h = wh[j]
              l = wl[j]

              a = l & 0xffff; b = l >>> 16
              c = h & 0xffff; d = h >>> 16

              h = wh[(j+9)%16]
              l = wl[(j+9)%16]

              a += l & 0xffff; b += l >>> 16
              c += h & 0xffff; d += h >>> 16

              // sigma0
              th = wh[(j+1)%16]
              tl = wl[(j+1)%16]
              
              h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7)
              l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)))

              a += l & 0xffff; b += l >>> 16
              c += h & 0xffff; d += h >>> 16

              // sigma1
              th = wh[(j+14)%16]
              tl = wl[(j+14)%16]
              
              h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6)
              l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)))

              a += l & 0xffff; b += l >>> 16
              c += h & 0xffff; d += h >>> 16

              b += a >>> 16
              c += b >>> 16
              d += c >>> 16

              wh[j] = ( (c & 0xffff) | (d << 16) )
              wl[j] = ( (a & 0xffff) | (b << 16) )
            }
          }
        }
                            
        // add
        a = 0; b = 0; c = 0; d = 0
        for k in 0..<8 {
            if( k == 0 ) {
                h = ah[0]
                l = al[0]
                a = l & 0xffff; b = l >>> 16
                c = h & 0xffff; d = h >>> 16
            }
            
            h = hh[k]
            l = hl[k]
            
            a += l & 0xffff; b += l >>> 16
            c += h & 0xffff; d += h >>> 16

            b += a >>> 16
            c += b >>> 16
            d += c >>> 16

            hh[k] = (c & 0xffff) | (d << 16)
            ah[k] = (c & 0xffff) | (d << 16)
        
            hl[k] = (a & 0xffff) | (b << 16)
            al[k] = (a & 0xffff) | (b << 16)
            
            if( k < 7 ) {
                h = ah[k+1]
                l = al[k+1]

                a = l & 0xffff; b = l >>> 16
                c = h & 0xffff; d = h >>> 16
            }
        }
                
        pos += 128
        n -= 128
      }

      return n
}

var _HH: [Int64] = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]
var _HL: [Int64] = [0xf3bcc908, 0x84caa73b, 0xfe94f82b, 0x5f1d36f1, 0xade682d1, 0x2b3e6c1f, 0xfb41bd6b, 0x137e2179]

func toIntArray(_ o:[Int64]) -> [Int] {
    var v = [Int]()
    for i in 0..<o.count {
        v.append( Int( getInt32( o[i] ) ) )
    }
    return v
}

func crypto_hash(_ out:inout [Int], _ m:[Int], _ _n: Int) -> Int {
    var hh = toIntArray( _HH )
    var hl = toIntArray( _HL )       
    var x = [Int](repeating: 0, count: 256)
    var  n = _n
    let b = n
       
    _ = crypto_hashblocks_hl(&hh, &hl, m, n)
                    
    n %= 128

    for i in 0..<n {
        x[i] = m[b-n+i]
    }
    x[n] = 128
    
    if( n<112 ) {
        n = 256-128 * 1 
    } else {
        n = 256-128 * 0 
    } 
    x[n-9] = 0
                
    ts64(&x, n-8, ((b / 0x20000000) | 0), (b << 3) )
        
    _ = crypto_hashblocks_hl(&hh, &hl, x, n)
    
    for i in 0..<8 {
        ts64(&out, 8*i, hh[i], hl[i])
    }

    return 0
    
}

func add(_ p: inout [[Int64]], _ q:[[Int64]]) {
    var a = gf()
    var b = gf()
    var c = gf()
    var d = gf()
    var e = gf()
    var f = gf()
    var g = gf()
    var h = gf()
    var t = gf()

    Z(&a, p[1], p[0])
    Z(&t, q[1], q[0])
    M(&a, a, t)
    A(&b, p[0], p[1])
    A(&t, q[0], q[1])
    M(&b, b, t)
    M(&c, p[3], q[3])
    M(&c, c, D2)
    M(&d, p[2], q[2])
    A(&d, d, d)
    Z(&e, b, a)
    Z(&f, d, c)
    A(&g, d, c)
    A(&h, b, a)

    M(&p[0], e, f)
    M(&p[1], h, g)
    M(&p[2], g, f)
    M(&p[3], e, h)
}

func cswap(_ p:inout [[Int64]], _ q:inout [[Int64]], _ b:Int) {
