File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
main/java/org/bouncycastle/crypto/params
test/java/org/bouncycastle/crypto/kems/test Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 33import java .math .BigInteger ;
44import java .security .SecureRandom ;
55
6+ import org .bouncycastle .math .ec .ECPoint ;
67import org .bouncycastle .util .BigIntegers ;
78
89/**
@@ -23,22 +24,31 @@ public class SAKKEPrivateKeyParameters
2324 extends AsymmetricKeyParameter
2425{
2526 private static final BigInteger qMinOne = SAKKEPublicKeyParameters .q .subtract (BigInteger .ONE );
26- /** The associated public key parameters. */
27+ /**
28+ * The associated public key parameters.
29+ */
2730 private final SAKKEPublicKeyParameters publicParams ;
28- /** The private key scalar (master secret). */
31+ /**
32+ * The private key scalar (master secret).
33+ */
2934 private final BigInteger z ; // KMS Public Key: Z = [z]P
3035
3136 /**
3237 * Constructs a SAKKE private key with a given private value and associated public parameters.
3338 *
34- * @param z The private key scalar.
39+ * @param z The private key scalar.
3540 * @param publicParams The associated public key parameters.
3641 */
3742 public SAKKEPrivateKeyParameters (BigInteger z , SAKKEPublicKeyParameters publicParams )
3843 {
3944 super (true );
4045 this .z = z ;
4146 this .publicParams = publicParams ;
47+ ECPoint computed_Z = publicParams .getPoint ().multiply (z ).normalize ();
48+ if (!computed_Z .equals (publicParams .getZ ()))
49+ {
50+ throw new IllegalStateException ("public key and private key of SAKKE do not match" );
51+ }
4252 }
4353
4454 /**
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public void performTest()
3939 throws Exception
4040 {
4141 testTestVector ();
42- for (int i = 0 ; i < 100 ; ++i )
42+ for (int i = 0 ; i < 1 ; ++i )
4343 {
4444 testRandom ();
4545 }
You can’t perform that action at this time.
0 commit comments