Secp256r1PrivateKey
Secp256r1PrivateKey
class Secp256r1PrivateKey
init(bytes:)
convenience init(bytes: Data) throws
debugDescription
var debugDescription: String { get }
A textual representation of this instance, suitable for debugging.
Calling this property directly is discouraged. Instead, convert an
instance of any type to a string by using the String(reflecting:)
initializer. This initializer works with any type, and uses the custom
debugDescription property for types that conform to
CustomDebugStringConvertible:
struct Point: CustomDebugStringConvertible {
let x: Int, y: Int
var debugDescription: String {
return "(\(x), \(y))"
}
}
let p = Point(x: 21, y: 30)
let s = String(reflecting: p)
print(s)
// Prints "(21, 30)"
The conversion of p to a string in the assignment to s uses the
Point type's debugDescription property.
publicKey()
func publicKey() -> Secp256r1PublicKey
Get the public key corresponding to this private key.
scheme()
func scheme() -> SignatureScheme
signPersonalMessage(message:)
func signPersonalMessage(message: PersonalMessage) throws -> UserSignature
Sign a personal message and return a UserSignature.
signTransaction(transaction:)
func signTransaction(transaction: Transaction) throws -> UserSignature
Sign a transaction and return a UserSignature.
toBech32()
func toBech32() throws -> String
Encode this private key as flag || privkey in Bech32 starting with
"iotaprivkey" to a string.
toBytes()
func toBytes() -> Data
Serialize this private key to bytes.
toDer()
func toDer() throws -> Data
Serialize this private key as DER-encoded PKCS#8
toPem()
func toPem() throws -> String
Serialize this private key as PEM-encoded PKCS#8
trySign(message:)
func trySign(message: Data) throws -> Secp256r1Signature
Sign a message and return a Secp256r1Signature.
trySignSimple(message:)
func trySignSimple(message: Data) throws -> SimpleSignature
Sign a message and return a SimpleSignature.
trySignUser(message:)
func trySignUser(message: Data) throws -> UserSignature
Sign a message and return a UserSignature.
verifyingKey()
func verifyingKey() -> Secp256r1VerifyingKey
fromBech32(value:)
static func fromBech32(value: String) throws -> Secp256r1PrivateKey
Decode a private key from flag || privkey in Bech32 starting with
"iotaprivkey".
fromDer(bytes:)
static func fromDer(bytes: Data) throws -> Secp256r1PrivateKey
Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).
fromMnemonic(phrase:accountIndex:password:)
static func fromMnemonic(phrase: String, accountIndex: UInt64 = UInt64(0), password: String = "") throws -> Secp256r1PrivateKey
Construct the private key from a mnemonic phrase
fromMnemonicWithPath(phrase:path:password:)
static func fromMnemonicWithPath(phrase: String, path: String, password: String = "") throws -> Secp256r1PrivateKey
Create an instance from a mnemonic phrase and a derivation path like
"m/74'/4218'/0'/0/0"
fromPem(s:)
static func fromPem(s: String) throws -> Secp256r1PrivateKey
Deserialize PKCS#8-encoded private key from PEM.
random()
static func random() -> Secp256r1PrivateKey
Generate a new random Secp256r1PrivateKey
!=(_:_:)
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
Inequality is the inverse of equality. For any values a and b, a != b
implies that a == b is false.
This is the default implementation of the not-equal-to operator (!=)
for any type that conforms to Equatable.
- Parameters:
- lhs: A value to compare.
- rhs: Another value to compare.
==(_:_:)
static func == (self: Secp256r1PrivateKey, other: Secp256r1PrivateKey) -> Bool
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values a and b,
a == b implies that a != b is false.
- Parameters:
- lhs: A value to compare.
- rhs: Another value to compare.