Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java')
-rw-r--r--src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java69
1 files changed, 50 insertions, 19 deletions
diff --git a/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java b/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java
index 70722cd8..be51d0af 100644
--- a/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java
+++ b/src/main/java/org/bouncycastle/pqc/crypto/ntru/NTRUSigningPublicKeyParameters.java
@@ -18,58 +18,70 @@ public class NTRUSigningPublicKeyParameters
/**
* Constructs a new public key from a polynomial
- * @param h the polynomial <code>h</code> which determines the key
+ *
+ * @param h the polynomial <code>h</code> which determines the key
* @param params the NtruSign parameters to use
*/
- public NTRUSigningPublicKeyParameters(IntegerPolynomial h, NTRUSigningParameters params) {
+ public NTRUSigningPublicKeyParameters(IntegerPolynomial h, NTRUSigningParameters params)
+ {
super(false);
this.h = h;
this.params = params;
}
-
+
/**
* Converts a byte array to a polynomial <code>h</code> and constructs a new public key
- * @param b an encoded polynomial
+ *
+ * @param b an encoded polynomial
* @param params the NtruSign parameters to use
*/
- public NTRUSigningPublicKeyParameters(byte[] b, NTRUSigningParameters params) {
+ public NTRUSigningPublicKeyParameters(byte[] b, NTRUSigningParameters params)
+ {
super(false);
h = IntegerPolynomial.fromBinary(b, params.N, params.q);
this.params = params;
}
-
+
/**
* Reads a polynomial <code>h</code> from an input stream and constructs a new public key
- * @param is an input stream
+ *
+ * @param is an input stream
* @param params the NtruSign parameters to use
*/
- public NTRUSigningPublicKeyParameters(InputStream is, NTRUSigningParameters params) throws IOException {
+ public NTRUSigningPublicKeyParameters(InputStream is, NTRUSigningParameters params)
+ throws IOException
+ {
super(false);
h = IntegerPolynomial.fromBinary(is, params.N, params.q);
this.params = params;
}
-
/**
* Converts the key to a byte array
+ *
* @return the encoded key
*/
- public byte[] getEncoded() {
+ public byte[] getEncoded()
+ {
return h.toBinary(params.q);
}
-
+
/**
* Writes the key to an output stream
+ *
* @param os an output stream
* @throws IOException
*/
- public void writeTo(OutputStream os) throws IOException {
+ public void writeTo(OutputStream os)
+ throws IOException
+ {
os.write(getEncoded());
}
@Override
- public int hashCode() {
+ public int hashCode()
+ {
final int prime = 31;
int result = 1;
result = prime * result + ((h == null) ? 0 : h.hashCode());
@@ -78,24 +90,43 @@ public class NTRUSigningPublicKeyParameters
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(Object obj)
+ {
if (this == obj)
+ {
return true;
+ }
if (obj == null)
+ {
return false;
+ }
if (getClass() != obj.getClass())
+ {
return false;
- NTRUSigningPublicKeyParameters other = (NTRUSigningPublicKeyParameters) obj;
- if (h == null) {
+ }
+ NTRUSigningPublicKeyParameters other = (NTRUSigningPublicKeyParameters)obj;
+ if (h == null)
+ {
if (other.h != null)
+ {
return false;
- } else if (!h.equals(other.h))
+ }
+ }
+ else if (!h.equals(other.h))
+ {
return false;
- if (params == null) {
+ }
+ if (params == null)
+ {
if (other.params != null)
+ {
return false;
- } else if (!params.equals(other.params))
+ }
+ }
+ else if (!params.equals(other.params))
+ {
return false;
+ }
return true;
}
} \ No newline at end of file