Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(castor): update protos for prism did method #73

Merged
merged 2 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ excluded:
- PrismAPISDK
- Sources/PrismSwiftSDK/protobuf/*
- Tests/PrismSwiftSDKTests
- Castor/Sources/DIDParser/DIDGrammar/*
- Castor/Tests
- Castor/Sources/protobuf
- Apollo/Tests
- Domain/Tests
- Authenticate/Tests
- Builders/Tests
- AtalaPrismSDK/Castor/Sources/DIDParser/DIDGrammar/*
- AtalaPrismSDK/Castor/Tests
- AtalaPrismSDK/Castor/Sources/protobuf
- AtalaPrismSDK/Apollo/Tests
- AtalaPrismSDK/Domain/Tests
- AtalaPrismSDK/Authenticate/Tests
- AtalaPrismSDK/Builders/Tests
- Core/Tests
- Mercury/Tests
- Pluto/Tests
- Pollux/Tests
- PrismAgent/Tests
- Mercury/Sources/TestingConstants/*
- AtalaPrismSDK/Mercury/Tests
- AtalaPrismSDK/Pluto/Tests
- AtalaPrismSDK/Pollux/Tests
- AtalaPrismSDK/PrismAgent/Tests
- AtalaPrismSDK/Mercury/Sources/TestingConstants/*
- Sample
line_length:
ignores_comments: true
Expand Down
117 changes: 0 additions & 117 deletions Apollo/Sources/ApolloImpl+Public.swift

This file was deleted.

41 changes: 41 additions & 0 deletions AtalaPrismSDK/Apollo/Sources/Apollo.docc/Apollo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ``Apollo``

Apollo is a suite of cryptographic primitives designed to ensure the integrity, authenticity, and confidentiality of any data that is stored and processed. These primitives provide a provably secure way to protect sensitive information, and they can be used in a wide range of applications.

## Cryptographic Primitives for Data Security

### Hashing

One of the basic building blocks of cryptography is the cryptographic hash, which is used to ensure the integrity of data. Hashing is frequently used to build more complex schemes, such as Merkle trees or digital signatures. Hashes can be used on their own to ensure the integrity of large chunks of data or as a basic commitment scheme.

### Digital Signatures

Digital signatures are the equivalent of handwritten signatures in the digital world. Owners of private signing keys create signatures, and anyone can check their validity with the corresponding public verification key. Most credentials carry a signature by their issuer. Digital signatures are used to ensure the authenticity and integrity of data.

### Symmetric Encryption

Symmetric encryption allows parties to exchange information while maintaining its secrecy. Given a symmetric key shared between parties, they can communicate securely. Symmetric encryption is a basic component for building secure communication channels.

### Public-Key Encryption

Public-key encryption uses a public encryption key to encrypt data so that only the owner of the corresponding private key can decrypt it. Public-key encryption is mostly used to encrypt symmetric keys or other (short) cryptographic values because of the high computational costs.

### Accumulators

Cryptographic accumulators allow for the accumulation of multiple values into one. Merkle trees are the most common type of accumulators used in the cryptocurrency domain. Accumulators make it possible to check (and prove) whether a given value has been accumulated or not.

### MAC

Message Authentication Codes are a type of symmetric equivalent of digital signatures. If two users share a symmetric key, they can use MAC algorithms to ensure the authenticity of the messages they exchange. The main difference between MACs and digital signatures is that MACs do not provide non-repudiation.

### Key Exchange

Key exchange protocols enable two or more parties to securely negotiate a symmetric key, even if they only know each other’s public keys. Key exchange protocols are used to establish secure communication channels.

By using the Apollo suite of cryptographic primitives, developers can build secure and provably secure applications that protect sensitive data from unauthorized access, tampering, or theft.

## Topics

### <!--@START_MENU_TOKEN@-->Group<!--@END_MENU_TOKEN@-->

- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@-->
103 changes: 103 additions & 0 deletions AtalaPrismSDK/Apollo/Sources/Apollo.docc/ApolloHowTo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Apollo API Tutorial

The Apollo protocol defines a set of functions for working with cryptography and key pairs. Here's a brief explanation of each function:

- `createRandomMnemonics`: This function creates a random set of mnemonic phrases that can be used as a seed for generating a private key.

```swift
// Example usage:
let mnemonics = ApolloImpl().createRandomMnemonics()
```

- `createSeed`: This function takes in a set of mnemonics and a passphrase, and returns a seed object used to generate a private key. It may throw an error if the mnemonics or passphrase are invalid.

```swift
// Example usage:
do {
let apollo = ApolloImpl()
let mnemonics = ["word1", "word2", "word3", ...]
let passphrase = "passphrase"
let seed = try apollo.createSeed(mnemonics: mnemonics, passphrase: passphrase)
} catch {
// Handle error
}
```

- `createRandomSeed`: This function creates a random seed and a corresponding set of mnemonic phrases.

```swift
// Example usage:
let (mnemonics, seed) = ApolloImpl().createRandomSeed()
```

- `createKeyPair`: This function creates a key pair (a private and public key) using a given seed and key curve.

```swift
// Example usage:
let seed = Seed(...)
let curve = KeyCurve.secp256k1
let keyPair = ApolloImpl().createKeyPair(seed: seed, curve: curve)
```

- `createKeyPair`: This function creates a key pair using a given seed and a specified private key. It may throw an error if the private key is invalid.

```swift
// Example usage:
do {
let apollo = ApolloImpl()
let seed = Seed(...)
let privateKey = PrivateKey(...)
let keyPair = try apollo.createKeyPair(seed: seed, privateKey: privateKey)
} catch {
// Handle error
}
```

- `compressedPublicKey`: This function compresses a given public key into a shorter, more efficient form.

```swift
// Example usage:
let publicKey = PublicKey(...)
let compressedPublicKey = ApolloImpl().compressedPublicKey(publicKey: publicKey)
```

- `compressedPublicKey`: This function decompresses a given compressed public key into its original form.

```swift
// Example usage:
let compressedData = Data(...)
let decompressedPublicKey = ApolloImpl().compressedPublicKey(compressedData: compressedData)
```

- `signMessage`: This function signs a message using a given private key, returning the signature.

```swift
// Example usage:
let privateKey = PrivateKey(...)
let message = Data(...)
let signature = ApolloImpl().signMessage(privateKey: privateKey, message: message)
```

- `signMessage`: This function signs a message using a given private key, returning the signature. It may throw an error if the message is invalid.

```swift
// Example usage:
do {
let apollo = ApolloImpl()
let privateKey = PrivateKey(...)
let message = "hello world"
let signature = try apollo.signMessage(privateKey: privateKey, message: message)
} catch {
// Handle error
}
```

- `verifySignature`: This function verifies the authenticity of a signature using the corresponding public key, challenge, and signature. It returns a boolean value indicating whether the signature is valid or not.

```swift
// Example usage:
let publicKey = PublicKey(...)
let challenge = Data(...)
let signature = Signature(...)
let isValid = ApolloImpl().verifySignature(publicKey: publicKey, challenge: challenge, signature: signature)
```
Loading