Domain
public class Domain : CustomStringConvertible, Equatable
A Domain instance contains an elliptic curve domain - either with characteristic 2 or characteristic an odd prime. Please refer [SEC 1] section 3.1.
-
Prime characteristic domain OID
Declaration
Swift
public static let OID_P: ASN1ObjectIdentifier -
Characteristic 2 domain OID
Declaration
Swift
public static let OID_2: ASN1ObjectIdentifier
-
Returns a predefined domain from its curve
Declaration
Swift
public static func instance(curve: ECCurve) -> DomainParameters
curveThe domain curve
Return Value
The corresponding domain
-
Returns a predefined domain from its OID
Throws
An unknownOid exception if oid does not match any domainDeclaration
Swift
public static func instance(oid: ASN1ObjectIdentifier) throws -> DomainParameters
oidThe domain OID
Return Value
The corresponding domain
-
Constructs a domain from its PEM encoding
Throws
An exception if the PEM contents is wrongDeclaration
Swift
public static func instance(pem: String) throws -> DomainParameters
pemThe PEM encoding of the domain
Return Value
The corresponding domain
-
Constructs an odd prime characteristic domain based on the curve y^2 = x^3 + a * x + b
Throws
A domainParameter exception if 4 * a^3 + 27 * b^2 = 0 or the generator point is not on the curveDeclaration
Swift
public static func instance(name: String, p: BInt, a: BInt, b: BInt, gx: BInt, gy: BInt, order: BInt, cofactor: Int, oid: ASN1ObjectIdentifier? = nil) throws -> DomainParameters
nameThe domain name
pThe field order - a prime greater then 3
aThe a coefficient
bThe b coefficient
gxThe generator point x-coordinate
gyThe generator point y-coordinate
orderThe curve order
cofactorThe cofactor
oidAn optional domain OID
Return Value
The domain
-
Constructs a characteristic 2 domain based on the curve y^2 + x * y = x^3 + a * x^2 + b
Throws
A domainParameter exception if b = 0 or the generator point is not on the curveDeclaration
Swift
public static func instance(name: String, rp: RP, a: BInt, b: BInt, gx: BInt, gy: BInt, order: BInt, cofactor: Int, oid: ASN1ObjectIdentifier? = nil) throws -> DomainParameters
nameThe domain name
rpThe reduction polynomial
aThe a coefficient
bThe b coefficient
gxThe generator point x-coordinate
gyThe generator point y-coordinate
orderThe curve order
cofactorThe cofactor
oidAn optional domain OID
Return Value
The domain
-
The domain name
Declaration
Swift
public let name: String -
The modulus
Declaration
Swift
public let p: BInt -
The curve a coefficient
Declaration
Swift
public let a: BInt -
The curve b coefficient
Declaration
Swift
public let b: BInt -
The generator point
Declaration
Swift
public let g: Point -
The curve order
Declaration
Swift
public let order: BInt -
The cofactor
Declaration
Swift
public let cofactor: Int -
An optional domain OID
Declaration
Swift
public let oid: ASN1ObjectIdentifier? -
Is true if self has characteristic 2, false if it has an odd prime characteristic
Declaration
Swift
public let characteristic2: Bool
-
The ASN1 encoding of self
Declaration
Swift
public var asn1: ASN1 { get } -
The PEM encoding of self
Declaration
Swift
public var pem: String { get } -
A textual representation of the ASN1 encoding of self
Declaration
Swift
public var description: String { get }
-
Equality of two Domain instances
Declaration
Swift
public static func == (d1: Domain, d2: Domain) -> BoolParameters
d1a Domain instance
d2a Domain instance
Return Value
true if d1 and d2 are equal, false otherwise
-
Tests if point is on curve
Declaration
Swift
public func contains(_ p: Point) -> BoolParameters
pThe point
Return Value
true iff p is on the domain curve
-
Encodes a Point to a byte array - please refer [SEC 1] section 2.3.3
Throws
An encodePoint exception if p is not on the curveParameters
pThe point to encode
compressIf true use compresssed encoding, if false use uncompressed encoding - false is default
Return Value
Encoding of p
-
Encodes a Point to an ASN1 structure
Throws
An encodePoint exception if p does not lie on the curveDeclaration
Swift
public func asn1EncodePoint(_ p: Point, _ compress: Bool = false) throws -> ASN1Parameters
pThe point to encode
compressIf true use compresssed encoding, if false use uncompressed encoding - false is default
Return Value
ASN1 encoding of p
-
Decodes a Point from an ASN1 octet string
Throws
An decodePoint exception if the octet string contains invalid dataDeclaration
Swift
public func asn1DecodePoint(_ asn1: ASN1OctetString) throws -> PointParameters
asn1The ASN1 octet string to decode
Return Value
The point
-
Decodes a Point from an ASN1 bit string
Throws
An decodePoint exception if the bit string contains invalid dataDeclaration
Swift
public func asn1DecodePoint(_ asn1: ASN1BitString) throws -> PointParameters
asn1The ASN1 bit string to decode
Return Value
The point
-
Explicit ASN1 encoding of self - please refer [SEC 1] appendix C.2
All domain components are included in the encoding - not just the domain OIDDeclaration
Swift
public func asn1Explicit() -> ASN1Return Value
Explicit ASN1 encoding of self
-
Generates a private- and public key pair for self
Declaration
Swift
public func makeKeyPair() -> (ECPublicKey, ECPrivateKey)Return Value
(ECPublicKey, ECPrivateKey)
Domain Class Reference