Skip to main content

SimpleSignature

SimpleSignature

class SimpleSignature

A basic signature

This enumeration defines the set of simple or basic signature schemes supported by IOTA. Most signature schemes supported by IOTA end up comprising of a at least one simple signature scheme.

BCS

The BCS serialized form for this type is defined by the following ABNF:

simple-signature = bytes ; where the contents of the bytes are defined by
; <simple-signature-body>
simple-signature-body = (ed25519-flag ed25519-signature ed25519-public-key) /
(secp256k1-flag secp256k1-signature secp256k1-public-key) /
(secp256r1-flag secp256r1-signature secp256r1-public-key)

Note: Due to historical reasons, signatures are serialized slightly different from the majority of the types in IOTA. In particular if a signature is ever embedded in another structure it generally is serialized as bytes meaning it has a length prefix that defines the length of the completely serialized signature.

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.

ed25519PubKey()

func ed25519PubKey() -> Ed25519PublicKey

ed25519PubKeyOpt()

func ed25519PubKeyOpt() -> Ed25519PublicKey?

ed25519Sig()

func ed25519Sig() -> Ed25519Signature

ed25519SigOpt()

func ed25519SigOpt() -> Ed25519Signature?

hash(into:)

func hash(into hasher: inout Hasher)

Hashes the essential components of this value by feeding them into the given hasher.

Implement this method to conform to the Hashable protocol. The components used for hashing must be the same as the components compared in your type's == operator implementation. Call hasher.combine(_:) with each of these components.

  • Important: In your implementation of hash(into:), don't call finalize() on the hasher instance provided, or replace it with a different instance. Doing so may become a compile-time error in the future.

  • Parameter hasher: The hasher to use when combining the components of this instance.

isEd25519()

func isEd25519() -> Bool

isSecp256k1()

func isSecp256k1() -> Bool

isSecp256r1()

func isSecp256r1() -> Bool

scheme()

func scheme() -> SignatureScheme

secp256k1PubKey()

func secp256k1PubKey() -> Secp256k1PublicKey

secp256k1PubKeyOpt()

func secp256k1PubKeyOpt() -> Secp256k1PublicKey?

secp256k1Sig()

func secp256k1Sig() -> Secp256k1Signature

secp256k1SigOpt()

func secp256k1SigOpt() -> Secp256k1Signature?

secp256r1PubKey()

func secp256r1PubKey() -> Secp256r1PublicKey

secp256r1PubKeyOpt()

func secp256r1PubKeyOpt() -> Secp256r1PublicKey?

secp256r1Sig()

func secp256r1Sig() -> Secp256r1Signature

secp256r1SigOpt()

func secp256r1SigOpt() -> Secp256r1Signature?

signatureBytes()

func signatureBytes() -> Data

The raw signature bytes, without the scheme flag or the public key.

toBase64()

func toBase64() -> String

Base64-encode this signature as its flag || sig || pubkey bytes.

toBytes()

func toBytes() -> Data

toPublicKey()

func toPublicKey() -> PublicKey

The public key embedded in this signature.

fromBase64(base64:)

static func fromBase64(base64: String) throws -> SimpleSignature

Decode a signature from the Base64 form produced by to_base64, i.e. base64 over the flag || sig || pubkey bytes.

newEd25519(signature:publicKey:)

static func newEd25519(signature: Ed25519Signature, publicKey: Ed25519PublicKey) -> SimpleSignature

newSecp256k1(signature:publicKey:)

static func newSecp256k1(signature: Secp256k1Signature, publicKey: Secp256k1PublicKey) -> SimpleSignature

newSecp256r1(signature:publicKey:)

static func newSecp256r1(signature: Secp256r1Signature, publicKey: Secp256r1PublicKey) -> SimpleSignature

!=(_:_:)

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: SimpleSignature, other: SimpleSignature) -> 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.