Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > spec > ECFieldFp

 `1 /*2  * @(#)ECFieldFp.java 1.3 03/12/193  *4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.6  */7 package java.security.spec;8 9 import java.math.BigInteger ;10 import java.util.Arrays ;11 12 /**13  * This immutable class defines an elliptic curve (EC) prime 14  * finite field.15  *16  * @see ECField17  *18  * @author Valerie Peng19  * @version 1.3, 12/19/0320  *21  * @since 1.522  */23 public class ECFieldFp implements ECField {24 25     private BigInteger p;26 27     /**28      * Creates an elliptic curve prime finite field 29      * with the specified prime p.30      * @param p the prime.31      * @exception NullPointerException if p is null.32      * @exception IllegalArgumentException if p33      * is not positive.34      */ 35     public ECFieldFp(BigInteger p) {36     if (p.signum() != 1) {37         throw new IllegalArgumentException ("p is not positive");38     }39     this.p = p;40     }41 42     /**43      * Returns the field size in bits which is size of prime p44      * for this prime finite field.45      * @return the field size in bits.46      */47     public int getFieldSize() {48     return p.bitLength();49     };50 51     /**52      * Returns the prime p of this prime finite field.53      * @return the prime.54      */ 55     public BigInteger getP() {56     return p;57     }58     59     /**60      * Compares this prime finite field for equality with the61      * specified object. 62      * @param obj the object to be compared.63      * @return true if obj is an instance64      * of ECFieldFp and the prime value match, false otherwise.65      */66     public boolean equals(Object obj) {67     if (this == obj) return true;68     if (obj instanceof ECFieldFp ) {69         return (p.equals(((ECFieldFp )obj).p));70     } 71     return false;72     }73      74     /**75      * Returns a hash code value for this prime finite field.76      * @return a hash code value.77      */78     public int hashCode() {79     return p.hashCode();80     }81 }82 ` Popular Tags