public class Secp256k1 extends java.lang.Object implements WeierstrassCurve
The curve is defined in Weierstrass short form \(y^2 = x^3 + b\) over a field \(\mathbb{F}_p\). Specific parameters are taken from here.
| Modifier and Type | Class and Description |
|---|---|
static class |
Secp256k1.HashIntoSecp256k1
A hash function mapping bit strings into the group such that
|
| Modifier and Type | Field and Description |
|---|---|
static Zp.ZpElement |
b
Parameter for the weierstrass equation \(y^2 = x^3 + b\).
|
static Zp.ZpElement |
generatorX
x-coordinate of generator element.
|
static Zp.ZpElement |
generatorY
y-coordinate of generator element.
|
static java.math.BigInteger |
n
The number of elements on the curve.
|
static java.math.BigInteger |
p
The prime used to instantiate the field \(\mathbb{F}_p\).
|
static Zp |
zp
The field \(\mathbb{F}_p\) over which the curve is defined.
|
| Constructor and Description |
|---|
Secp256k1()
Initialize the curve.
|
Secp256k1(Representation repr)
Initialize the curve from a representation (not used since all parameters are fixed).
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
double |
estimateCostInvPerOp()
Estimates the number of inversions that can be done per group operation for the same cost.
|
FieldElement |
getA1()
Returns \(A1\) from the weierstrass equation
\(y^2 + A1 \cdot xy + A3 \cdot y = x^3 + A2 \cdot x^2 + A4 \cdot x + A6\).
|
FieldElement |
getA2()
Returns \(A2\) from the weierstrass equation
\(y^2 + A1 \cdot xy + A3 \cdot y = x^3 + A2 \cdot x^2 + A4 \cdot x + A6\).
|
FieldElement |
getA3()
Returns \(A3\) from the weierstrass equation
\(y^2 + A1 \cdot xy + A3 \cdot y = x^3 + A2 \cdot x^2 + A4 \cdot x + A6\).
|
FieldElement |
getA4()
Returns \(A4\) from the weierstrass equation
\(y^2 + A1 \cdot xy + A3 \cdot y = x^3 + A2 \cdot x^2 + A4 \cdot x + A6\).
|
FieldElement |
getA6()
Returns \(A6\) from the weierstrass equation
\(y^2 + A1 \cdot xy + A3 \cdot y = x^3 + A2 \cdot x^2 + A4 \cdot x + A6\).
|
EllipticCurvePoint |
getElement(FieldElement x,
FieldElement y)
Construct an point on this curve given the x- and y-coordinates.
|
Field |
getFieldOfDefinition()
Returns the base field over which the elliptic curve is defined.
|
GroupElementImpl |
getGenerator()
Returns any generator of this group if the group is cyclic and it's feasible to compute a generator.
|
GroupElementImpl |
getNeutralElement()
Returns the neutral element of this group.
|
Representation |
getRepresentation()
The representation of this object.
|
GroupElementImpl |
getUniformlyRandomElement()
Generates a uniformly random element of this group.
|
java.util.Optional<java.lang.Integer> |
getUniqueByteLength()
Returns the number of bytes returned by this structure's
UniqueByteRepresentable.getUniqueByteRepresentation(),
or an empty Optional if this structure's elements do not guarantee a fixed length. |
int |
hashCode() |
boolean |
hasPrimeSize()
Returns true if the size of this structure is known and prime.
|
GroupElementImpl |
restoreElement(Representation repr)
Restores a group element from its representation.
|
java.math.BigInteger |
size()
Retrieves number of elements in the group if possible.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitisShortFormisCommutativeexp, getUniformlyRandomNonNeutral, implementsOwnExp, implementsOwnMultiExp, multiexp, restoreFromRepresentationpublic static final java.math.BigInteger p
public static final java.math.BigInteger n
public static final Zp zp
public static final Zp.ZpElement b
public static final Zp.ZpElement generatorX
public static final Zp.ZpElement generatorY
public Secp256k1()
public Secp256k1(Representation repr)
The representation is not used, as all parameters are fixed. Hence, it can be any value.
repr - the representation to use for restoration. Not usedpublic FieldElement getA6()
WeierstrassCurvegetA6 in interface WeierstrassCurvepublic FieldElement getA4()
WeierstrassCurvegetA4 in interface WeierstrassCurvepublic FieldElement getA3()
WeierstrassCurveIs zero if the curve is given by a weierstrass equation in short form.
getA3 in interface WeierstrassCurvepublic FieldElement getA2()
WeierstrassCurveIs zero if the curve is given by a weierstrass equation in short form.
getA2 in interface WeierstrassCurvepublic FieldElement getA1()
WeierstrassCurveIs zero if the curve is given by a weierstrass equation in short form.
getA1 in interface WeierstrassCurvepublic EllipticCurvePoint getElement(FieldElement x, FieldElement y)
WeierstrassCurvegetElement in interface WeierstrassCurvex - the x-coordinatey - the y-coordinatepublic Field getFieldOfDefinition()
EllipticCurvegetFieldOfDefinition in interface EllipticCurvepublic GroupElementImpl getNeutralElement()
GroupImplgetNeutralElement in interface GroupImplpublic GroupElementImpl getUniformlyRandomElement() throws java.lang.UnsupportedOperationException
GroupImplgetUniformlyRandomElement in interface GroupImpljava.lang.UnsupportedOperationException - if the random generation cannot be donepublic GroupElementImpl restoreElement(Representation repr)
GroupImplrestoreElement in interface GroupImplpublic GroupElementImpl getGenerator() throws java.lang.UnsupportedOperationException
GroupImplRepeated calls may or may not always supply the same generator again (i.e. the output is not guaranteed to be random)!
getGenerator in interface GroupImpljava.lang.UnsupportedOperationException - if group is not cyclic or it's too hard to compute a generatorpublic java.math.BigInteger size()
throws java.lang.UnsupportedOperationException
GroupImplpublic boolean hasPrimeSize()
GroupImplhasPrimeSize in interface GroupImplpublic double estimateCostInvPerOp()
GroupImpl2 would mean that an inversion costs half as much as a group operation, on average.estimateCostInvPerOp in interface GroupImplpublic java.util.Optional<java.lang.Integer> getUniqueByteLength()
GroupImplUniqueByteRepresentable.getUniqueByteRepresentation(),
or an empty Optional if this structure's elements do not guarantee a fixed length.
For example, elements of Zp will always be represented by ceil(ceil(log(p))/8) bytes,
hence getUniqueByteLength() would return ceil(ceil(log(p))/8).
A polynomial ring would return an empty Optional since a polynomial's unique byte representation length
depends on its degree.
getUniqueByteLength in interface GroupImplgetUniqueByteRepresentation(),
or an empty Optional, if no guaranteepublic Representation getRepresentation()
RepresentableReprUtilgetRepresentation in interface RepresentableRepresentationpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object