• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.bouncycastle.math.raw;
2 
3 
4 public abstract class Nat512
5 {
mul(int[] x, int[] y, int[] zz)6     public static void mul(int[] x, int[] y, int[] zz)
7     {
8         Nat256.mul(x, y, zz);
9         Nat256.mul(x, 8, y, 8, zz, 16);
10 
11         int c24 = Nat256.addToEachOther(zz, 8, zz, 16);
12         int c16 = c24 + Nat256.addTo(zz, 0, zz, 8, 0);
13         c24 += Nat256.addTo(zz, 24, zz, 16, c16);
14 
15         int[] dx = Nat256.create(), dy = Nat256.create();
16         boolean neg = Nat256.diff(x, 8, x, 0, dx, 0) != Nat256.diff(y, 8, y, 0, dy, 0);
17 
18         int[] tt = Nat256.createExt();
19         Nat256.mul(dx, dy, tt);
20 
21         c24 += neg ? Nat.addTo(16, tt, 0, zz, 8) : Nat.subFrom(16, tt, 0, zz, 8);
22         Nat.addWordAt(32, c24, zz, 24);
23     }
24 
square(int[] x, int[] zz)25     public static void square(int[] x, int[] zz)
26     {
27         Nat256.square(x, zz);
28         Nat256.square(x, 8, zz, 16);
29 
30         int c24 = Nat256.addToEachOther(zz, 8, zz, 16);
31         int c16 = c24 + Nat256.addTo(zz, 0, zz, 8, 0);
32         c24 += Nat256.addTo(zz, 24, zz, 16, c16);
33 
34         int[] dx = Nat256.create();
35         Nat256.diff(x, 8, x, 0, dx, 0);
36 
37         int[] tt = Nat256.createExt();
38         Nat256.square(dx, tt);
39 
40         c24 += Nat.subFrom(16, tt, 0, zz, 8);
41         Nat.addWordAt(32, c24, zz, 24);
42     }
43 }
44