ECPrivateKey
public class ECPrivateKey : CustomStringConvertible
An Elliptic Curve private key
-
Creates a private key
Throws
An exception if s < 1 or s >= the domain orderDeclaration
Swift
public init(domain: Domain, s: BInt) throwsParameters
domainThe domain the key belongs to
sThe secret key value
-
Creates a private key from its DER encoding
Throws
An exception if the DER encoding is wrongDeclaration
Swift
public convenience init(der: Bytes) throwsParameters
derThe DER encoding of the key
-
Creates a private key from its PEM encoding
Throws
An exception if the PEM encoding is wrongDeclaration
Swift
public convenience init(pem: String) throwsParameters
pemThe PEM encoding of the key
-
The domain the key belongs to
Declaration
Swift
public let domain: Domain -
The private value - a integer number
Declaration
Swift
public let s: BInt
-
The ASN1 encoding of self
Declaration
Swift
public var asn1: ASN1 { get } -
The PEM base 64 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 }
-
Signs a byte array message with ECDSA
Declaration
Swift
public func sign(msg: Bytes, deterministic: Bool = false) -> ECSignatureParameters
msgThe message to sign
deterministicIf true generate a deterministic signature according to RFC-6979, if false generate a non-deterministic signature - false is default
Return Value
The signature
-
Signs a Data message with ECDSA
Declaration
Swift
public func sign(msg: Data, deterministic: Bool = false) -> ECSignatureParameters
msgThe message to sign
deterministicIf true generate a deterministic signature according to RFC-6979, if false generate a non-deterministic signature - false is default
Return Value
The signature
-
Decrypts a byte array message with ECIES
Throws
An exception if the message authentication fails or the message is too shortDeclaration
Parameters
msgThe bytes to decrypt
cipherThe AES cipher to use
modeThe block mode to use - GCM is default
Return Value
The decrypted message
-
Decrypts a Data message with ECIES
Throws
An exception if the message authentication fails or the message is too shortDeclaration
Parameters
msgThe data to decrypt
cipherThe AES cipher to use
modeThe block mode to use - GCM is default
Return Value
The decrypted message
-
Constructs a shared secret key using Diffie-Hellman key agreement - please refer [SEC 1] section 3.3.1
Throws
An exception if this and pubKey do not belong to the same domain or length is negativeDeclaration
Swift
public func keyAgreement(pubKey: ECPublicKey, length: Int, md: MessageDigestAlgorithm, sharedInfo: Bytes, cofactor: Bool = false) throws -> BytesParameters
pubKeyThe other party’s public key
lengthThe required length of the shared secret
mdThe message digest algorithm to use
sharedInfoInformation shared with the other party
cofactorUse cofactor version - false is default
Return Value
A byte array which is the shared secret key
ECPrivateKey Class Reference