Class SecpFieldElementImpl
java.lang.Object
org.bitcoinj.secp.internal.SecpFieldElementImpl
- All Implemented Interfaces:
SecpFieldElement
Implementation of
SecpFieldElement as an array of bytes.-
Constructor Summary
ConstructorsConstructorDescriptionSecpFieldElementImpl(byte[] bytes) Caller is responsible for defensively copyingbyte[]. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]checkInRange(byte[] e) ThrowIllegalArgumentExceptionif the byte array is not the length.booleaninthashCode()static byte[]Convert a BigInteger to a fixed-length byte array verifying it's a valid P256k1 field element.static booleanisInRange(byte[] e) booleanisOdd()Get the parity of the field valuebyte[]Get serialized (big-endian) field element (32 bytes unsigned)Get the field element as aBigIntegertoString()
-
Constructor Details
-
SecpFieldElementImpl
-
SecpFieldElementImpl
public SecpFieldElementImpl(byte[] bytes) Caller is responsible for defensively copyingbyte[]. This is to avoid a redundant copy. Exclusive ownership must be passed to this instance.- Parameters:
bytes- (will not be defensively copied)
-
-
Method Details
-
toBigInteger
Description copied from interface:SecpFieldElementGet the field element as aBigInteger- Specified by:
toBigIntegerin interfaceSecpFieldElement- Returns:
- field element value
-
serialize
public byte[] serialize()Description copied from interface:SecpFieldElementGet serialized (big-endian) field element (32 bytes unsigned)- Specified by:
serializein interfaceSecpFieldElement- Returns:
- serialized field element
-
isOdd
public boolean isOdd()Description copied from interface:SecpFieldElementGet the parity of the field value- Specified by:
isOddin interfaceSecpFieldElement- Returns:
trueif odd,falseif even
-
equals
-
hashCode
-
toString
-
integerTo32Bytes
Convert a BigInteger to a fixed-length byte array verifying it's a valid P256k1 field element.- Parameters:
i- an unsigned BigInteger containing a valid Secp256k1 field value- Returns:
- a 32-byte, big-endian unsigned integer value
-
isInRange
public static boolean isInRange(byte[] e) -
checkInRange
public static byte[] checkInRange(byte[] e) ThrowIllegalArgumentExceptionif the byte array is not the length.NOTE: We are not currently validating for value less than
P- Parameters:
e- unvalidated integer (byte[]format)- Returns:
- a validated integer (
byte[]format)
-