Skip to content
Merged
1 change: 1 addition & 0 deletions .periphery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
retain_public: true
18 changes: 4 additions & 14 deletions Sources/DistributedMLS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import Foundation
extension DiMLS {
public protocol Client: Actor, Archivable {
associatedtype Credential: DiMLSCredential
associatedtype Invitation: DiInvitation //where Invitation.Credential == Credential
associatedtype Group: DiGroup where Group.WelcomeOutput == WelcomeOutput
associatedtype Group: DiGroup
where Group.WelcomeOutput == WelcomeOutput, Group.Credential == Credential
associatedtype WelcomeOutput: WelcomeOutputInterface
where
Group.Credential == Credential
// Invitation.WelcomeOutput == WelcomeOutput

static func create(credential: Credential) throws -> Self

Expand All @@ -38,18 +35,11 @@ extension DiMLS {

func process(
wireWelcome: Data,
keyPackageId: KeyPackageId?
keyPackageId: KeyPackageId?,
knownDependencies: [DiMLS.KeyedDependency]
) throws -> (
KeyPackageId,
WelcomeOutput
)
}
}

public protocol Archivable {
associatedtype Archive: Sendable, Codable
init(archive: Archive) throws

//helps to define this in the protocol for Actor protocols
// var archive: Archive { get throws }
}
27 changes: 0 additions & 27 deletions Sources/DistributedMLS/DiInvitation.swift

This file was deleted.

19 changes: 7 additions & 12 deletions Sources/DistributedMLS/DiMLS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
import Foundation

public enum DiMLS {
//like send group id
public typealias ReferenceID = Data
public typealias EpochID = UInt64
public typealias KeyPackageId = Data

///mirrors (is a) MLS private message in that it has an encrypted
///application message and plaintext metadata and auth data
///This is an output of the ratchet tree for a given context, which is addressed to a specific snapshot
///of the collective group.
public struct PrivateMessage<C: DiMLSCredential>: Sendable {
public let body: Data //encoded MLS Private message
public let epoch: UInt64 //we may retry transmit after a later commit
public let epoch: EpochID //we may retry transmit after a later commit
public let sender: C
public let addressees: [C]

public init(
body: Data,
epoch: UInt64,
epoch: EpochID,
sender: C,
addressees: [C]
) {
Expand All @@ -35,22 +35,17 @@ public enum DiMLS {
}
}

public enum DecryptOutput {
case control //todo: type out the control plane message
case application(plaintext: Data)
}

public struct EncryptOutput: Sendable {
//Implementation may choose to staple the commit and/or
//encrypt headers
public let privateMessage: Data
//if not stapled let the caller judge if it wants resend the commit
public let epoch: UInt64
public let epoch: EpochID
public let additionalCommits: [EpochCommit]

public init(
privateMessage: Data,
epoch: UInt64,
epoch: EpochID,
additionalCommits: [EpochCommit]
) {
self.privateMessage = privateMessage
Expand All @@ -60,10 +55,10 @@ public enum DiMLS {
}

public struct EpochCommit: Sendable, Codable {
public let epoch: UInt64
public let epoch: EpochID
public let commit: Data

public init(epoch: UInt64, commit: Data) {
public init(epoch: EpochID, commit: Data) {
self.epoch = epoch
self.commit = commit
}
Expand Down
42 changes: 26 additions & 16 deletions Sources/DistributedMLS/Group/CommitInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,43 @@
// Created by Mark @ Germ on 1/11/26.
//

import Foundation

extension DiMLS {
public struct CommitInput<C: DiMLSCredential> {
public var proposals: Set<DiMLSOperations<C>>
public var localOps: Set<DiMLSOperations<C>>
public var followOps: Set<DiMLSOperations<C>>

//psk's
struct Dependency {
let pskSource: ReferenceID
let epoch: EpochID
}
var dependencies: [Dependency]
public var dependencies: [KeyedDependency]

public var newSenderLeafNode: Bool

public init() {
proposals = []
localOps = []
followOps = []
dependencies = []
newSenderLeafNode = false
}
}

//psk's
public struct Dependency: Codable, Sendable, Hashable {
public let pskSource: ReferenceID
public let epoch: EpochID

public init(pskSource: ReferenceID, epoch: EpochID) {
self.pskSource = pskSource
self.epoch = epoch
}
}

public struct KeyedDependency: Codable, Sendable {
public let dependency: Dependency
public let keyData: Data

private init(
proposals: [DiMLSOperations<C>],
dependencies: [Dependency],
newSenderLeafNode: Bool
) {
self.proposals = .init(proposals)
self.dependencies = dependencies
self.newSenderLeafNode = newSenderLeafNode
public init(dependency: Dependency, keyData: Data) {
self.dependency = dependency
self.keyData = keyData
}
}
}
29 changes: 29 additions & 0 deletions Sources/DistributedMLS/Group/Decrypt/DecryptOutput.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// DecryptOutput.swift
// DistributedMLS
//
// Created by Mark @ Germ on 1/19/26.
//

import Foundation

extension DiMLS {
public struct DecryptOutput: Sendable {
let appPlaintext: AppPlaintext
let controlMessage: ControlMessage?
}

public struct ControlMessage: Sendable {

}

public struct AppPlaintext: Sendable {
public let application: Data
public let authenticating: Data

public init(application: Data, authenticating: Data) {
self.application = application
self.authenticating = authenticating
}
}
}
Loading
Loading