-
Notifications
You must be signed in to change notification settings - Fork 4
fix: use random IVs for stored keys (put/get), matching the Dart SDK #526
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
Open
cconstab
wants to merge
16
commits into
trunk
Choose a base branch
from
fix/put-get-random-iv
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,106
−24
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2d4779c
fix: random IV for stored keys (put/get), matching the Dart SDK
1a1d663
fix: random IV for self keys too + carry ivNonce through UpdateVerbBu…
2bc6618
refactor: generate IV in put() (mirror Dart AtClientImpl._putInternal)
55a411e
test: add guarded cross-SDK IV interop test (Python <-> Dart) + opt-i…
d512358
test(interop): clear Dart local storage before run; note EE-recreate …
77617ff
ci(interop): TEMP push trigger to validate the interop workflow pre-m…
1ddf934
ci(interop): revert temp push trigger, back to workflow_dispatch only…
600900a
review: address #526 nits (pin actions, extract onboard script, deps …
ccf3d99
ci(interop): TEMP push trigger to re-validate reworked workflow
c29888e
Merge branch 'trunk' into fix/put-get-random-iv
cconstab f8ba113
ci(interop): set PYTHONPATH so onboard script + test import at_client…
b631a74
Merge branch 'fix/put-get-random-iv' of github.com:atsign-foundation/…
cconstab c00034f
ci(interop): remove temp push trigger, workflow_dispatch only [skip ci]
e1ac1d4
ci: re-run required checks (previous head was [skip ci])
cconstab e14509d
ci(interop): add concurrency group to cancel superseded runs
3744f79
Merge branch 'trunk' into fix/put-get-random-iv
cconstab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # Opt-in cross-SDK IV interop test (Python at_client <-> Dart at_client). | ||
| # Manual only (workflow_dispatch): starts the ephemeral environment container, | ||
| # onboards two test atSigns via CRAM, and runs test/interop_test.py with AT_INTEROP=1. | ||
| name: interop (Python <-> Dart) | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: interop-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| interop: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| env: | ||
| # Run the SDK from source (deps installed from poetry.lock; package not built). | ||
| PYTHONPATH: ${{ github.workspace }} | ||
| services: | ||
| ee: | ||
| image: atsigncompany/ephemeral | ||
| env: | ||
| DNS_FQDN: vip.ve.atsign.zone | ||
| FIRST_PORT: 2500 | ||
| ports: | ||
| - 64:64 | ||
| - 2500-2540:2500-2540 | ||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
|
|
||
| - name: Resolve the EE FQDN to localhost (matches the cert CN) | ||
| run: echo "127.0.0.1 vip.ve.atsign.zone" | sudo tee -a /etc/hosts | ||
|
|
||
| - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | ||
| with: | ||
| python-version: '3.14' | ||
| - uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260 # v1.7.2 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 | ||
|
|
||
| - name: Install SDK dependencies (from poetry.lock) | ||
| run: | | ||
| sudo apt-get install -y python3-poetry-plugin-export | ||
| uv venv | ||
| . .venv/bin/activate | ||
| poetry export --format requirements.txt --output requirements.txt | ||
| uv pip install --require-hashes -r requirements.txt | ||
| echo "$PWD/.venv/bin" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Wait for the EE root, then onboard @alpha and @bravo (CRAM) | ||
| env: | ||
| HOME: /tmp/eehome | ||
| run: | | ||
| mkdir -p "$HOME/.atsign/keys" | ||
| sleep 30 # let the root register the atServers | ||
| python test/interop/onboard.py @alpha @bravo | ||
|
|
||
| - name: dart pub get (interop helper) | ||
| run: dart pub get | ||
| working-directory: test/interop | ||
|
|
||
| - name: Run interop test | ||
| env: | ||
| HOME: /tmp/eehome | ||
| AT_INTEROP: '1' | ||
| AT_ROOT: vip.ve.atsign.zone:64 | ||
| AT_ROOT_DOMAIN: vip.ve.atsign.zone | ||
| run: | | ||
| rm -rf /tmp/eehome/.atsign/storage # clean Dart local state (keeps .atKeys) | ||
| python -m unittest discover -s test -p 'interop_test.py' -v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Dart tool-generated; regenerated by `dart pub get`. pubspec.lock IS committed. | ||
| .dart_tool/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Cross-SDK IV interop test | ||
|
|
||
| `test/interop_test.py` verifies that this Python SDK and the Dart | ||
| reference `at_client` interoperate for random-IV / `ivNonce` shared-key | ||
| encryption, in both directions: | ||
|
|
||
| - Python `put` shared -> Dart `get` shared (Python's random IV read by Dart) | ||
| - Dart `put` shared -> Python `get` shared (Dart's random IV read by Python) | ||
|
|
||
| This directory holds the Dart helper (`bin/iv_interop.dart` + | ||
| `pubspec.yaml`) the test shells out to. | ||
|
|
||
| ## Guarded - off by default | ||
|
|
||
| `interop_test.py` is discovered by the normal `unittest` run but **skips** | ||
| unless `AT_INTEROP=1` and a Dart SDK is on PATH, so it never affects | ||
| standard/fork CI. | ||
|
|
||
| ## Run locally | ||
|
|
||
| Prerequisites: Dart SDK; an atServer reachable (e.g. the ephemeral | ||
| environment); two onboarded atSigns with `.atKeys` under | ||
| `$HOME/.atsign/keys`. | ||
|
|
||
| ```bash | ||
| # EE example: @alpha and @bravo onboarded, keys in /tmp/eehome/.atsign/keys | ||
| HOME=/tmp/eehome AT_INTEROP=1 \ | ||
| AT_ROOT=vip.ve.atsign.zone:64 AT_ROOT_DOMAIN=vip.ve.atsign.zone \ | ||
| python -m unittest discover -s test -p 'interop_test.py' -v | ||
| ``` | ||
|
|
||
| Env (all optional, EE-friendly defaults): `AT_INTEROP_ATSIGN1` | ||
| (`@alpha`), `AT_INTEROP_ATSIGN2` (`@bravo`), `AT_ROOT` | ||
| (`vip.ve.atsign.zone:64`), `AT_ROOT_DOMAIN` (host of `AT_ROOT`). | ||
|
|
||
| > Re-running against a **recreated** EE? Clear the Dart client's local | ||
| > storage first (`rm -rf $HOME/.atsign/storage`) - it caches keys from the | ||
| > previous atServer and will otherwise fail to decrypt after re-onboarding. | ||
| > A fresh CI runner never hits this. | ||
|
|
||
| ## CI | ||
|
|
||
| An opt-in workflow is in `.github/workflows/interop.yml` (manual | ||
| `workflow_dispatch`): it starts the ephemeral environment, onboards two | ||
| atSigns, installs dependencies, and runs this test with `AT_INTEROP=1`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // Interop helper using the Dart reference at_client. Put/get self and shared keys | ||
| // so a Python peer (at_python fix/put-get-random-iv) can read/write them, proving | ||
| // the Python IV/ivNonce behavior is wire-compatible with Dart. | ||
| // | ||
| // dart run bin/iv_interop.dart --atsign @alpha --root-domain vip.ve.atsign.zone \ | ||
| // --op put-shared --key demo --value hi --shared-with @bravo | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:at_client/at_client.dart'; | ||
| import 'package:at_cli_commons/at_cli_commons.dart'; | ||
|
|
||
| const String ns = 'itest'; | ||
|
|
||
| /// Dart at_client is local-first: put writes locally then syncs to the server, and | ||
| /// get of self/own keys reads locally. For cross-SDK interop we must push after a | ||
| /// put and pull before a get, so wait until the client is in sync with the server. | ||
| Future<void> waitInSync(AtClient atClient, {int timeoutSec = 30}) async { | ||
| final sync = atClient.syncService; | ||
| for (var i = 0; i < timeoutSec; i++) { | ||
| sync.sync(); | ||
| try { | ||
| if (await sync.isInSync()) return; | ||
| } catch (_) {} | ||
| await Future.delayed(const Duration(seconds: 1)); | ||
| } | ||
| } | ||
|
|
||
| Future<void> main(List<String> args) async { | ||
| final parser = CLIBase.createArgsParser(namespace: ns) | ||
| ..addOption('op', mandatory: true) | ||
| ..addOption('key', mandatory: true) | ||
| ..addOption('value', defaultsTo: '') | ||
| ..addOption('shared-with'); | ||
| final cli = await CLIBase.fromCommandLineArgs(args, parser: parser, namespace: ns); | ||
| final atClient = cli.atClient; | ||
| final me = atClient.getCurrentAtSign()!; | ||
| final a = parser.parse(args); | ||
| final op = a['op'] as String; | ||
| final keyName = a['key'] as String; | ||
| final value = a['value'] as String; | ||
| final sw = a['shared-with'] as String?; | ||
|
|
||
| switch (op) { | ||
| case 'put-self': | ||
| final k = AtKey() | ||
| ..key = keyName | ||
| ..namespace = ns | ||
| ..sharedBy = me; | ||
| await atClient.put(k, value); | ||
| await waitInSync(atClient); // push to server | ||
| stdout.writeln('OK'); | ||
| break; | ||
| case 'get-self': | ||
| await waitInSync(atClient); // pull peer's writes | ||
| final k = AtKey() | ||
| ..key = keyName | ||
| ..namespace = ns | ||
| ..sharedBy = me; | ||
| final r = await atClient.get(k); | ||
| stdout.writeln('VALUE:${r.value}'); | ||
| break; | ||
| case 'put-shared': | ||
| final k = AtKey() | ||
| ..key = keyName | ||
| ..namespace = ns | ||
| ..sharedBy = me | ||
| ..sharedWith = sw; | ||
| await atClient.put(k, value); | ||
| await waitInSync(atClient); // push to server | ||
| stdout.writeln('OK'); | ||
| break; | ||
| case 'get-shared': | ||
| final k = AtKey() | ||
| ..key = keyName | ||
| ..namespace = ns | ||
| ..sharedBy = sw | ||
| ..sharedWith = me; | ||
| final r = await atClient.get(k); | ||
| stdout.writeln('VALUE:${r.value}'); | ||
| break; | ||
| } | ||
| exit(0); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.