Skip to content

Commit 59b4e5f

Browse files
committed
Updating interfaces
1 parent d7f4b43 commit 59b4e5f

39 files changed

Lines changed: 507 additions & 21 deletions

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ Reference: https://www.rfc-editor.org/rfc/rfc9420.html
44

55
Status
66

7-
- Interfaces only — no concrete implementations yet.
7+
- Interface-first: comprehensive RFC-shaped interfaces and registry enums implemented; no concrete cryptographic primitives included.
88
- Goal: provide a complete set of PHP interfaces that mirror RFC 9420 concepts for downstream implementations and tests.
99
Current status
1010

1111
- Interfaces: comprehensive interface-only definitions for the major RFC 9420 concepts (groups, ratchet tree, messages, proposals, commits, credentials, crypto abstractions).
1212
- Registry enums: added enum-style classes mirroring RFC tables and registries (Tables 4–7 and related): `CipherSuite`, `KEM`, `KDF`, `AEAD`, `HashAlgorithm`, `SignatureScheme`, `ExtensionType`, `ProposalType`, `CredentialType`, `EpochSecrets`, `SignatureLabels`, `PublicKeyEncryptionLabels`, `MessageWireFormat`, and `ContentType`.
1313
- Tests: a basic PHPUnit test (`tests/MLSInterfacesTest.php`) asserts presence of interfaces and method signatures; run locally with `./vendor/bin/phpunit`.
1414
- Implementations: no concrete cryptographic implementations included — those remain out of scope.
15+
- Recent API changes: `MLSPlaintextInterface::getSender()` and `FramedContentInterface::getSender()` return a `SenderInterface` (typed sender union). `KeyScheduleInterface::init()` now accepts an ordered array of PSKs (`array $psks`) to reflect RFC PSK chaining semantics. `CommitInterface::getSender()` and `ProposalInterface::getSender()` now also return `SenderInterface`.
1516

1617
Implemented (interface files) — ordered by RFC section
1718

@@ -127,6 +128,8 @@ Roadmap
127128
3. Add minimal reference implementations or adapters for HPKE/signature primitives.
128129
4. Implement end-to-end examples that exercise the KeySchedule, Commit, and Welcome flows.
129130

131+
If you'd like, I can add a short example showing how to construct a `SenderInterface` instance value (as a simple DTO) for use with these interfaces — or scaffold minimal reference implementations for `KeySchedule` and `HPKE` to exercise PSK chaining and welcome creation.
132+
130133
Contributing
131134

132135
- Add concrete implementations under `src/MLS/` and tests under `tests/`.

src/MLS/Commit/CommitCreatorInterface.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is a part of the DiscordPHP-RFC9420 project.
7+
*
8+
* Copyright (c) 2026-present Valithor Obsidion <valithor@discordphp.org>
9+
*
10+
* This file is subject to the MIT license that is bundled
11+
* with this source code in the LICENSE.md file.
12+
*/
13+
514
namespace MLS\Commit;
615

716
use MLS\Proposal\ProposalListInterface;
@@ -12,7 +21,7 @@ interface CommitCreatorInterface
1221
* Create a Commit from a (validated) proposal list.
1322
*
1423
* @param ProposalListInterface $proposals
15-
* @param array|null $path optional path information
24+
* @param array|null $path optional path information
1625
*/
1726
public function createCommit(ProposalListInterface $proposals, ?array $path = null): CommitInterface;
1827
}

src/MLS/Commit/CommitInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
namespace MLS\Commit;
1515

16+
use MLS\Message\SenderInterface;
17+
1618
interface CommitInterface
1719
{
18-
public function getSender(): string;
20+
public function getSender(): SenderInterface;
1921

2022
public function getProposals(): array;
2123

src/MLS/Commit/CommitProcessorInterface.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is a part of the DiscordPHP-RFC9420 project.
7+
*
8+
* Copyright (c) 2026-present Valithor Obsidion <valithor@discordphp.org>
9+
*
10+
* This file is subject to the MIT license that is bundled
11+
* with this source code in the LICENSE.md file.
12+
*/
13+
514
namespace MLS\Commit;
615

716
interface CommitProcessorInterface
817
{
918
/**
1019
* Process an incoming Commit and apply changes to group state.
1120
*
12-
* @param CommitInterface $commit
21+
* @param CommitInterface $commit
1322
* @return array<int,mixed> results or updated state details
1423
*/
1524
public function processCommit(CommitInterface $commit): array;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is a part of the DiscordPHP-RFC9420 project.
7+
*
8+
* Copyright (c) 2026-present Valithor Obsidion <valithor@discordphp.org>
9+
*
10+
* This file is subject to the MIT license that is bundled
11+
* with this source code in the LICENSE.md file.
12+
*/
13+
14+
namespace MLS\Commit;
15+
16+
interface UpdatePathInterface
17+
{
18+
/**
19+
* The leaf node presented in the path (serialized).
20+
*/
21+
public function getLeafNode(): string;
22+
23+
/**
24+
* Array of UpdatePathNodeInterface.
25+
* @return UpdatePathNodeInterface[]
26+
*/
27+
public function getNodes(): array;
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is a part of the DiscordPHP-RFC9420 project.
7+
*
8+
* Copyright (c) 2026-present Valithor Obsidion <valithor@discordphp.org>
9+
*
10+
* This file is subject to the MIT license that is bundled
11+
* with this source code in the LICENSE.md file.
12+
*/
13+
14+
namespace MLS\Commit;
15+
16+
interface UpdatePathInterface
17+
{
18+
/**
19+
* The leaf node presented in the path (serialized).
20+
*/
21+
public function getLeafNode(): string;
22+
23+
/**
24+
* Array of UpdatePathNodeInterface.
25+
* @return UpdatePathNodeInterface[]
26+
*/
27+
public function getNodes(): array;
28+
}

src/MLS/Crypto/KeyScheduleInterface.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515

1616
interface KeyScheduleInterface
1717
{
18-
public function init(string $psk, CipherSuiteInterface $suite): void;
18+
/**
19+
* Initialize the key schedule.
20+
*
21+
* @param string[] $psks Ordered list of PSKs (may be empty)
22+
*/
23+
public function init(array $psks, CipherSuiteInterface $suite): void;
1924

2025
public function deriveWelcomeSecret(string $epochSecret): string;
2126

src/MLS/Enums/AEAD.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is a part of the DiscordPHP-RFC9420 project.
7+
*
8+
* Copyright (c) 2026-present Valithor Obsidion <valithor@discordphp.org>
9+
*
10+
* This file is subject to the MIT license that is bundled
11+
* with this source code in the LICENSE.md file.
12+
*/
13+
514
namespace MLS\Enums;
615

716
/**
8-
* AEAD identifiers referenced by MLS cipher suites (RFC 9420 Table 7)
17+
* AEAD identifiers referenced by MLS cipher suites (RFC 9420 Table 7).
918
*/
1019
final class AEAD
1120
{

src/MLS/Enums/CipherSuite.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is a part of the DiscordPHP-RFC9420 project.
7+
*
8+
* Copyright (c) 2026-present Valithor Obsidion <valithor@discordphp.org>
9+
*
10+
* This file is subject to the MIT license that is bundled
11+
* with this source code in the LICENSE.md file.
12+
*/
13+
514
namespace MLS\Enums;
615

716
/**
8-
* MLS Cipher Suites (RFC 9420 - Section 17.1, Tables 6 & 7)
17+
* MLS Cipher Suites (RFC 9420 - Section 17.1, Tables 6 & 7).
918
*/
1019
final class CipherSuite
1120
{

src/MLS/Enums/CredentialType.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is a part of the DiscordPHP-RFC9420 project.
7+
*
8+
* Copyright (c) 2026-present Valithor Obsidion <valithor@discordphp.org>
9+
*
10+
* This file is subject to the MIT license that is bundled
11+
* with this source code in the LICENSE.md file.
12+
*/
13+
514
namespace MLS\Enums;
615

716
/**

0 commit comments

Comments
 (0)