|
1 | 1 | import Foundation
|
2 | 2 |
|
3 | 3 | public protocol Apollo {
|
| 4 | + /// createRandomMnemonics creates a random set of mnemonic phrases that can be used as a seed for generating a private key. |
| 5 | + /// |
| 6 | + /// - Returns: An array of mnemonic phrases |
4 | 7 | func createRandomMnemonics() -> [String]
|
| 8 | + |
| 9 | + /// createSeed takes in a set of mnemonics and a passphrase, and returns a seed object used to generate a private key. |
| 10 | + /// This function may throw an error if the mnemonics or passphrase are invalid. |
| 11 | + /// |
| 12 | + /// - Parameters: |
| 13 | + /// - mnemonics: An array of mnemonic phrases |
| 14 | + /// - passphrase: A passphrase used to enhance the security of the seed |
| 15 | + /// - Returns: A seed object |
| 16 | + /// - Throws: An error if the mnemonics or passphrase are invalid |
5 | 17 | func createSeed(mnemonics: [String], passphrase: String) throws -> Seed
|
| 18 | + |
| 19 | + /// createRandomSeed creates a random seed and a corresponding set of mnemonic phrases. |
| 20 | + /// |
| 21 | + /// - Returns: A tuple containing an array of mnemonic phrases and a seed object |
6 | 22 | func createRandomSeed() -> (mnemonic: [String], seed: Seed)
|
| 23 | + |
| 24 | + /// createKeyPair creates a key pair (a private and public key) using a given seed and key curve. |
| 25 | + /// |
| 26 | + /// - Parameters: |
| 27 | + /// - seed: A seed object used to generate the key pair |
| 28 | + /// - curve: The key curve to use for generating the key pair |
| 29 | + /// - Returns: A key pair object containing a private and public key |
7 | 30 | func createKeyPair(seed: Seed, curve: KeyCurve) -> KeyPair
|
| 31 | + |
| 32 | + /// createKeyPair creates a key pair using a given seed and a specified private key. This function may throw an error if the private key is invalid. |
| 33 | + /// |
| 34 | + /// - Parameters: |
| 35 | + /// - seed: A seed object used to generate the key pair |
| 36 | + /// - privateKey: The private key to use for generating the key pair |
| 37 | + /// - Returns: A key pair object containing a private and public key |
| 38 | + /// - Throws: An error if the private key is invalid |
8 | 39 | func createKeyPair(seed: Seed, privateKey: PrivateKey) throws -> KeyPair
|
| 40 | + |
| 41 | + /// compressedPublicKey compresses a given public key into a shorter, more efficient form. |
| 42 | + /// |
| 43 | + /// - Parameter publicKey: The public key to compress |
| 44 | + /// - Returns: The compressed public key |
9 | 45 | func compressedPublicKey(publicKey: PublicKey) -> CompressedPublicKey
|
| 46 | + |
| 47 | + /// compressedPublicKey decompresses a given compressed public key into its original form. |
| 48 | + /// |
| 49 | + /// - Parameter compressedData: The compressed public key data |
| 50 | + /// - Returns: The decompressed public key |
10 | 51 | func compressedPublicKey(compressedData: Data) -> CompressedPublicKey
|
| 52 | + |
| 53 | + /// signMessage signs a message using a given private key, returning the signature. |
| 54 | + /// |
| 55 | + /// - Parameters: |
| 56 | + /// - privateKey: The private key to use for signing the message |
| 57 | + /// - message: The message to sign, in binary data form |
| 58 | + /// - Returns: The signature of the message |
11 | 59 | func signMessage(privateKey: PrivateKey, message: Data) -> Signature
|
| 60 | + |
| 61 | + /// signMessage signs a message using a given private key, returning the signature. This function may throw an error if the message is invalid. |
| 62 | + /// |
| 63 | + /// - Parameters: |
| 64 | + /// - privateKey: The private key to use for signing the message |
| 65 | + /// - message: The message to sign, in string form |
| 66 | + /// - Returns: The signature of the message |
| 67 | + /// - Throws: An error if the message is invalid |
12 | 68 | func signMessage(privateKey: PrivateKey, message: String) throws -> Signature
|
| 69 | + |
| 70 | + /// verifySignature verifies the authenticity of a signature using the corresponding public key, challenge, and signature. This function returns a boolean value indicating whether the signature is valid or not. |
| 71 | + /// |
| 72 | + /// - Parameters: |
| 73 | + /// - publicKey: The public key associated with the signature |
| 74 | + /// - challenge: The challenge used to generate the signature |
| 75 | + /// - signature: The signature to verify |
| 76 | + /// - Returns: A boolean value indicating whether the signature is valid or not |
13 | 77 | func verifySignature(
|
14 | 78 | publicKey: PublicKey,
|
15 | 79 | challenge: Data,
|
16 | 80 | signature: Signature
|
17 | 81 | ) -> Bool
|
| 82 | + |
| 83 | + /// getPrivateJWKJson converts a private key pair into a JSON Web Key (JWK) format with a given ID. This function may throw an error if the key pair is invalid. |
| 84 | + /// |
| 85 | + /// - Parameters: |
| 86 | + /// - id: The ID to use for the JWK |
| 87 | + /// - keyPair: The private key pair to convert to JWK format |
| 88 | + /// - Returns: The private key pair in JWK format, as a string |
| 89 | + /// - Throws: An error if the key pair is invalid |
18 | 90 | func getPrivateJWKJson(id: String, keyPair: KeyPair) throws -> String
|
| 91 | + |
| 92 | + /// getPublicJWKJson converts a public key pair into a JSON Web Key (JWK) format with a given ID. This function may throw an error if the key pair is invalid. |
| 93 | + /// |
| 94 | + /// - Parameters: |
| 95 | + /// - id: The ID to use for the JWK |
| 96 | + /// - keyPair: The public key pair to convert to JWK format |
| 97 | + /// - Returns: The public key pair in JWK format, as a string |
| 98 | + /// - Throws: An error if the key pair is invalid |
19 | 99 | func getPublicJWKJson(id: String, keyPair: KeyPair) throws -> String
|
20 | 100 | }
|
0 commit comments