├── .github ├── ISSUE_TEMPLATE │ ├── new-release-checklist.md │ └── okapi-change.md └── workflows │ ├── assign-issues-to-project.yml │ ├── buf-push.yml │ ├── build-dart.yml │ ├── build-dotnet.yml │ ├── build-golang.yml │ ├── build-java.yml │ ├── build-libs.yml │ ├── build-proto.yml │ ├── build-python.yml │ ├── build-wasm.yml │ ├── release-dart.yml │ ├── release-dotnet.yml │ ├── release-golang.yml │ ├── release-java.yml │ ├── release-libs.yml │ ├── release-python.yml │ ├── release-rust.yml │ ├── release-swift.yml │ └── release-wasm.yml ├── .gitignore ├── .gitmodules ├── CODE_OF_CONDUCT.md ├── Initialize.ps1 ├── Initialize.py ├── LICENSE ├── README.md ├── SECURITY.md ├── android └── README.md ├── buf.work.yml ├── dart ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── lib │ ├── okapi.dart │ ├── okapi_native.dart │ └── proto │ │ ├── google │ │ └── protobuf │ │ │ ├── any.pb.dart │ │ │ ├── any.pbenum.dart │ │ │ ├── any.pbjson.dart │ │ │ ├── any.pbserver.dart │ │ │ ├── api.pb.dart │ │ │ ├── api.pbenum.dart │ │ │ ├── api.pbjson.dart │ │ │ ├── api.pbserver.dart │ │ │ ├── compiler │ │ │ ├── plugin.pb.dart │ │ │ ├── plugin.pbenum.dart │ │ │ ├── plugin.pbjson.dart │ │ │ └── plugin.pbserver.dart │ │ │ ├── descriptor.pb.dart │ │ │ ├── descriptor.pbenum.dart │ │ │ ├── descriptor.pbjson.dart │ │ │ ├── descriptor.pbserver.dart │ │ │ ├── duration.pb.dart │ │ │ ├── duration.pbenum.dart │ │ │ ├── duration.pbjson.dart │ │ │ ├── duration.pbserver.dart │ │ │ ├── empty.pb.dart │ │ │ ├── empty.pbenum.dart │ │ │ ├── empty.pbjson.dart │ │ │ ├── empty.pbserver.dart │ │ │ ├── field_mask.pb.dart │ │ │ ├── field_mask.pbenum.dart │ │ │ ├── field_mask.pbjson.dart │ │ │ ├── field_mask.pbserver.dart │ │ │ ├── source_context.pb.dart │ │ │ ├── source_context.pbenum.dart │ │ │ ├── source_context.pbjson.dart │ │ │ ├── source_context.pbserver.dart │ │ │ ├── struct.pb.dart │ │ │ ├── struct.pbenum.dart │ │ │ ├── struct.pbjson.dart │ │ │ ├── struct.pbserver.dart │ │ │ ├── timestamp.pb.dart │ │ │ ├── timestamp.pbenum.dart │ │ │ ├── timestamp.pbjson.dart │ │ │ ├── timestamp.pbserver.dart │ │ │ ├── type.pb.dart │ │ │ ├── type.pbenum.dart │ │ │ ├── type.pbjson.dart │ │ │ ├── type.pbserver.dart │ │ │ ├── wrappers.pb.dart │ │ │ ├── wrappers.pbenum.dart │ │ │ ├── wrappers.pbjson.dart │ │ │ └── wrappers.pbserver.dart │ │ ├── okapi │ │ ├── examples │ │ │ └── v1 │ │ │ │ ├── examples.pb.dart │ │ │ │ ├── examples.pbenum.dart │ │ │ │ ├── examples.pbjson.dart │ │ │ │ └── examples.pbserver.dart │ │ ├── hashing │ │ │ └── v1 │ │ │ │ ├── hashing.pb.dart │ │ │ │ ├── hashing.pbenum.dart │ │ │ │ ├── hashing.pbjson.dart │ │ │ │ └── hashing.pbserver.dart │ │ ├── keys │ │ │ └── v1 │ │ │ │ ├── keys.pb.dart │ │ │ │ ├── keys.pbenum.dart │ │ │ │ ├── keys.pbjson.dart │ │ │ │ └── keys.pbserver.dart │ │ ├── metadata │ │ │ ├── metadata.pb.dart │ │ │ ├── metadata.pbenum.dart │ │ │ ├── metadata.pbjson.dart │ │ │ └── metadata.pbserver.dart │ │ ├── proofs │ │ │ └── v1 │ │ │ │ ├── proofs.pb.dart │ │ │ │ ├── proofs.pbenum.dart │ │ │ │ ├── proofs.pbjson.dart │ │ │ │ └── proofs.pbserver.dart │ │ ├── security │ │ │ └── v1 │ │ │ │ ├── security.pb.dart │ │ │ │ ├── security.pbenum.dart │ │ │ │ ├── security.pbjson.dart │ │ │ │ └── security.pbserver.dart │ │ └── transport │ │ │ └── v1 │ │ │ ├── transport.pb.dart │ │ │ ├── transport.pbenum.dart │ │ │ ├── transport.pbjson.dart │ │ │ └── transport.pbserver.dart │ │ └── pbmse │ │ └── v1 │ │ ├── pbmse.pb.dart │ │ ├── pbmse.pbenum.dart │ │ ├── pbmse.pbjson.dart │ │ └── pbmse.pbserver.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── dart_test.dart ├── devops ├── BuildLibraries.ps1 ├── build_sdks.py ├── build_winget.py ├── generate_proto_files.py ├── requirements.txt └── resources │ └── markdown.tmpl ├── docs ├── _static │ ├── bad-form.png │ ├── extra.css │ ├── images │ │ └── trust-triangle.png │ ├── javascripts │ │ └── config.js │ ├── logo-title.svg │ ├── logo.png │ ├── named-triangle.png │ ├── proto.json │ ├── stack.png │ ├── trust-ecosystem-interop.jpg │ ├── trust-ecosystem.png │ └── trust-triangle.png ├── didcomm-grpc.md ├── images │ ├── design-approach-1.png │ ├── design-approach-1.puml │ └── didcomm-arch-diag.png └── reference │ └── proto │ └── index.md ├── dotnet ├── .gitignore ├── BuildAndTest.ps1 ├── Directory.Build.props ├── Library │ └── Okapi │ │ ├── ByteBuffer.cs │ │ ├── DIDComm.cs │ │ ├── DIDCommException.cs │ │ ├── DIDKey.cs │ │ ├── ExternError.cs │ │ ├── Hashing.cs │ │ ├── LDProofs.cs │ │ ├── Native.cs │ │ ├── Oberon.cs │ │ ├── Okapi.csproj │ │ ├── OkapiMetadata.cs │ │ ├── UnmanagedMemory.cs │ │ └── build │ │ ├── android │ │ └── Okapi.Net.targets │ │ ├── ios │ │ └── Okapi.Net.targets │ │ ├── maccatalyst │ │ └── Okapi.Net.targets │ │ └── net │ │ └── Okapi.Net.targets ├── Okapi.sln ├── README.md ├── Tests │ └── Okapi.Tests │ │ ├── DidCommTests.cs │ │ ├── HashingTests.cs │ │ ├── KeyTests.cs │ │ ├── LdProofsTests.cs │ │ ├── MetadataTests.cs │ │ ├── OberonTests.cs │ │ └── Okapi.Tests.csproj └── global.json ├── go ├── .gitignore ├── README.md ├── go.mod ├── go.sum ├── okapi │ ├── README.md │ ├── didcomm.go │ ├── didkey.go │ ├── didkey_test.go │ ├── examples │ │ └── v1 │ │ │ └── examples │ │ │ └── examples.pb.go │ ├── hashing.go │ ├── hashing │ │ └── v1 │ │ │ └── hashing │ │ │ └── hashing.pb.go │ ├── hashing_test.go │ ├── keys │ │ └── v1 │ │ │ └── keys │ │ │ └── keys.pb.go │ ├── ldproofs.go │ ├── ldproofs_test.go │ ├── metadata.go │ ├── metadata │ │ └── metadata.pb.go │ ├── metadata_test.go │ ├── native.go │ ├── native_call.go │ ├── native_call_windows.go │ ├── oberon.go │ ├── oberon_test.go │ ├── proofs │ │ └── v1 │ │ │ └── proofs │ │ │ └── proofs.pb.go │ ├── security │ │ └── v1 │ │ │ └── security │ │ │ └── security.pb.go │ └── transport │ │ └── v1 │ │ └── transport │ │ └── transport.pb.go └── pbmse │ └── v1 │ └── pbmse │ └── pbmse.pb.go ├── include ├── module.modulemap └── okapi.h ├── java ├── AndroidManifest.xml ├── AndroidValues.xml ├── R.txt ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ └── java │ │ └── trinsic │ │ └── okapi │ │ ├── DidComm.java │ │ ├── DidException.java │ │ ├── DidKey.java │ │ ├── Examples.java │ │ ├── ExternError.java │ │ ├── Hashing.java │ │ ├── LdProofs.java │ │ ├── Oberon.java │ │ ├── OkapiByteBuffer.java │ │ ├── OkapiMetadata.java │ │ ├── OkapiNative.java │ │ ├── examples │ │ └── v1 │ │ │ ├── BasicMessageKt.kt │ │ │ ├── Examples.java │ │ │ └── ExamplesKt.kt │ │ ├── hashing │ │ └── v1 │ │ │ ├── Blake3DeriveKeyRequestKt.kt │ │ │ ├── Blake3DeriveKeyResponseKt.kt │ │ │ ├── Blake3HashRequestKt.kt │ │ │ ├── Blake3HashResponseKt.kt │ │ │ ├── Blake3KeyedHashRequestKt.kt │ │ │ ├── Blake3KeyedHashResponseKt.kt │ │ │ ├── Hashing.java │ │ │ ├── HashingKt.kt │ │ │ ├── SHA256HashRequestKt.kt │ │ │ └── SHA256HashResponseKt.kt │ │ ├── keys │ │ └── v1 │ │ │ ├── GenerateKeyRequestKt.kt │ │ │ ├── GenerateKeyResponseKt.kt │ │ │ ├── JsonWebKeyKt.kt │ │ │ ├── Keys.java │ │ │ ├── KeysKt.kt │ │ │ ├── ResolveRequestKt.kt │ │ │ └── ResolveResponseKt.kt │ │ ├── metadata │ │ ├── Metadata.java │ │ ├── MetadataKt.kt │ │ ├── MetadataRequestKt.kt │ │ └── MetadataResponseKt.kt │ │ ├── pbmse │ │ └── v1 │ │ │ ├── EncryptedMessageKt.kt │ │ │ ├── EncryptionHeaderKt.kt │ │ │ ├── EncryptionRecipientKt.kt │ │ │ ├── Pbmse.java │ │ │ ├── PbmseKt.kt │ │ │ ├── SignatureHeaderKt.kt │ │ │ ├── SignatureKt.kt │ │ │ └── SignedMessageKt.kt │ │ ├── proofs │ │ └── v1 │ │ │ ├── CreateProofRequestKt.kt │ │ │ ├── CreateProofResponseKt.kt │ │ │ ├── Proofs.java │ │ │ ├── ProofsKt.kt │ │ │ ├── VerifyProofRequestKt.kt │ │ │ └── VerifyProofResponseKt.kt │ │ ├── security │ │ └── v1 │ │ │ ├── BlindOberonTokenRequestKt.kt │ │ │ ├── BlindOberonTokenResponseKt.kt │ │ │ ├── CreateOberonKeyRequestKt.kt │ │ │ ├── CreateOberonKeyResponseKt.kt │ │ │ ├── CreateOberonProofRequestKt.kt │ │ │ ├── CreateOberonProofResponseKt.kt │ │ │ ├── CreateOberonTokenRequestKt.kt │ │ │ ├── CreateOberonTokenResponseKt.kt │ │ │ ├── Security.java │ │ │ ├── SecurityKt.kt │ │ │ ├── UnBlindOberonTokenRequestKt.kt │ │ │ ├── UnBlindOberonTokenResponseKt.kt │ │ │ ├── VerifyOberonProofRequestKt.kt │ │ │ ├── VerifyOberonProofResponseKt.kt │ │ │ ├── VerifyOberonTokenRequestKt.kt │ │ │ └── VerifyOberonTokenResponseKt.kt │ │ └── transport │ │ └── v1 │ │ ├── CoreMessageKt.kt │ │ ├── PackRequestKt.kt │ │ ├── PackResponseKt.kt │ │ ├── SignRequestKt.kt │ │ ├── SignResponseKt.kt │ │ ├── Transport.java │ │ ├── TransportKt.kt │ │ ├── UnpackRequestKt.kt │ │ ├── UnpackResponseKt.kt │ │ ├── VerifyRequestKt.kt │ │ └── VerifyResponseKt.kt │ └── test │ └── java │ ├── Base58.java │ ├── HashingTest.java │ ├── Hex.java │ ├── LdProofTest.java │ ├── OberonTest.java │ └── OkapiNativeTest.java ├── libs └── README.md ├── native ├── .cargo │ ├── _config.toml │ └── config ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md ├── build.rs ├── rustfmt.toml ├── src │ ├── didcomm │ │ ├── aesgcm.rs │ │ ├── mod.rs │ │ └── xchacha.rs │ ├── didkey │ │ └── mod.rs │ ├── ffi │ │ ├── didcomm.rs │ │ ├── didkey.rs │ │ ├── hashing.rs │ │ ├── ldproofs.rs │ │ ├── metadata.rs │ │ ├── mod.rs │ │ ├── oberon.rs │ │ └── utils.rs │ ├── hashing │ │ └── mod.rs │ ├── ldproofs │ │ └── mod.rs │ ├── lib.rs │ ├── macros.rs │ ├── metadata │ │ └── mod.rs │ ├── oberon │ │ └── mod.rs │ ├── proto │ │ ├── google_protobuf.rs │ │ ├── mod.rs │ │ ├── okapi │ │ │ ├── mod.rs │ │ │ ├── okapi_examples.rs │ │ │ ├── okapi_hashing.rs │ │ │ ├── okapi_keys.rs │ │ │ ├── okapi_metadata.rs │ │ │ ├── okapi_proofs.rs │ │ │ ├── okapi_security.rs │ │ │ └── okapi_transport.rs │ │ ├── pbmse.rs │ │ └── pbmse │ │ │ └── pbmse.rs │ └── tests │ │ ├── keys.rs │ │ ├── mod.rs │ │ ├── oberon.rs │ │ ├── pack.rs │ │ ├── sign.rs │ │ └── utils.rs └── wix │ └── main.wxs ├── package-lock.json ├── proto ├── README.md ├── buf.md ├── buf.yaml ├── okapi │ ├── examples │ │ └── v1 │ │ │ └── examples.proto │ ├── hashing │ │ └── v1 │ │ │ └── hashing.proto │ ├── keys │ │ └── v1 │ │ │ └── keys.proto │ ├── metadata │ │ └── metadata.proto │ ├── proofs │ │ └── v1 │ │ │ └── proofs.proto │ ├── security │ │ └── v1 │ │ │ └── security.proto │ └── transport │ │ └── v1 │ │ └── transport.proto └── pbmse │ └── v1 │ └── pbmse.proto ├── python ├── .gitignore ├── README.md ├── pyproject.toml ├── requirements.txt ├── setup.cfg ├── tests │ ├── __init__.py │ ├── okapi_demo.py │ ├── test_hash.py │ ├── test_keys.py │ ├── test_ldproofs.py │ └── test_oberon.py └── trinsicokapi │ ├── __init__.py │ ├── __main__.py │ ├── didcomm.py │ ├── didkey.py │ ├── hashing.py │ ├── ldproofs.py │ ├── metadata.py │ ├── oberon.py │ ├── okapi_utils.py │ ├── proto │ ├── __init__.py │ ├── okapi │ │ ├── __init__.py │ │ ├── examples │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── hashing │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── keys │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── metadata │ │ │ └── __init__.py │ │ ├── proofs │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── security │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ └── transport │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ └── __init__.py │ └── pbmse │ │ ├── __init__.py │ │ └── v1 │ │ └── __init__.py │ └── wrapper.py ├── renovate.json └── wasm ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── packages └── okapi │ ├── .config │ ├── jest.config.cjs │ └── karma.conf.cjs │ ├── Generate-Proto.ps1 │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── spec │ └── support │ │ └── jasmine-browser.json │ ├── src │ ├── README.md │ ├── index.ts │ └── proto │ │ ├── google │ │ ├── index.d.ts │ │ └── protobuf │ │ │ └── struct.ts │ │ ├── index.d.ts │ │ ├── index.ts │ │ ├── okapi │ │ ├── examples │ │ │ └── v1 │ │ │ │ └── examples.ts │ │ ├── hashing │ │ │ └── v1 │ │ │ │ └── hashing.ts │ │ ├── keys │ │ │ └── v1 │ │ │ │ └── keys.ts │ │ ├── metadata │ │ │ └── metadata.ts │ │ ├── proofs │ │ │ └── v1 │ │ │ │ └── proofs.ts │ │ ├── security │ │ │ └── v1 │ │ │ │ └── security.ts │ │ └── transport │ │ │ └── v1 │ │ │ └── transport.ts │ │ └── pbmse │ │ ├── index.d.ts │ │ └── v1 │ │ └── pbmse.ts │ ├── test │ ├── helpers │ │ └── jasmine-helper.ts │ └── web.spec.ts │ ├── tsconfig.json │ └── tsconfig.web.json └── src ├── didcomm.rs ├── didkey.rs ├── hashing.rs ├── ldproofs.rs ├── lib.rs ├── metadata.rs └── oberon.rs /.github/ISSUE_TEMPLATE/okapi-change.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Okapi Change 3 | about: Changes to the Okapi language bindings, eg a new function to wrap. 4 | title: '' 5 | labels: '' 6 | assignees: fundthmcalculus 7 | 8 | --- 9 | 10 | *** TODO: Describe changes *** 11 | 12 | Languages: 13 | - [ ] .NET 14 | - [ ] Go 15 | - [ ] Java 16 | - [ ] Dart 17 | - [ ] Python 18 | - [ ] Swift 19 | - [ ] Wasm 20 | -------------------------------------------------------------------------------- /.github/workflows/assign-issues-to-project.yml: -------------------------------------------------------------------------------- 1 | name: Assign Issues to Project 2 | on: 3 | workflow_dispatch: 4 | pull_request: 5 | branches: 6 | - main 7 | issues: 8 | types: [ opened, reopened, closed ] 9 | 10 | permissions: 11 | actions: read 12 | repository-projects: write 13 | issues: write 14 | contents: write 15 | 16 | jobs: 17 | assign_issues_action: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v3 21 | - uses: trinsic-id/assign-issues-to-project@v0.1.2 22 | id: assignissues 23 | with: 24 | githubToken: ${{ secrets.API_GITHUB_TOKEN }} 25 | projectNumber: 4 26 | orgName: trinsic-id 27 | repoName: okapi # TODO - ${{ github.event.repository.name }} ? 28 | -------------------------------------------------------------------------------- /.github/workflows/buf-push.yml: -------------------------------------------------------------------------------- 1 | name: Push to buf.build 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths: 7 | - "proto/**" 8 | workflow_dispatch: 9 | 10 | jobs: 11 | push: 12 | runs-on: ubuntu-latest 13 | environment: 14 | name: buf.build 15 | steps: 16 | - uses: actions/checkout@v3 17 | - uses: bufbuild/buf-setup-action@v1 18 | - uses: bufbuild/buf-push-action@v1 19 | with: 20 | input: 'proto' 21 | buf_token: ${{ secrets.BUF_BUILD_TOKEN }} 22 | 23 | compile_proto: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - uses: actions/checkout@v3 27 | - name: Set up Python 3.9 28 | uses: actions/setup-python@v4 29 | with: 30 | python-version: 3.9 31 | - name: Set up Go 32 | uses: actions/setup-go@v3 33 | with: 34 | go-version: ^1.16 35 | - name: Install Protoc 36 | uses: arduino/setup-protoc@v1 37 | with: 38 | repo-token: ${{ secrets.GITHUB_TOKEN }} 39 | - name: Install protobuf plugins 40 | run: | 41 | go install google.golang.org/protobuf/cmd/protoc-gen-go@latest 42 | pip install -r ./devops/requirements.txt 43 | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH 44 | - name: Compile proto files 45 | run: | 46 | git checkout -b update-protobuf-generated-files 47 | git config --global user.name 'Github Action Runner' 48 | git config --global user.email 'trinsic.github.bot@users.noreply.github.com' 49 | python ./devops/generate_proto_files.py 50 | git add . 51 | git commit -m "Proto file changes" 52 | git push --set-upstream origin update-protobuf-generated-files 53 | -------------------------------------------------------------------------------- /.github/workflows/build-dart.yml: -------------------------------------------------------------------------------- 1 | name: Dart 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | pull_request: 7 | paths: 8 | - "dart/**" 9 | - "proto/**" 10 | - ".github/workflows/*dart*" 11 | - "devops/**" 12 | push: 13 | branches: 14 | - main 15 | paths: 16 | - "dart/**" 17 | - "proto/**" 18 | - ".github/workflows/*dart*" 19 | - "devops/**" 20 | 21 | jobs: 22 | build-and-test-dart: 23 | name: Test Dart code 24 | runs-on: ${{ matrix.os-artifact[0] }} 25 | strategy: 26 | fail-fast: false 27 | matrix: 28 | os-artifact: [ [ubuntu-latest, linux], [windows-latest, windows], [macos-latest, macos] ] 29 | steps: 30 | - uses: actions/checkout@v3 31 | - name: Set up Dart 32 | uses: dart-lang/setup-dart@v1 33 | - name: Set up Python 34 | uses: actions/setup-python@v4 35 | with: 36 | python-version: 3.9 37 | cache: pip 38 | 39 | - name: Download workflow artifact 40 | uses: dawidd6/action-download-artifact@v2 41 | with: 42 | workflow: "build-libs.yml" 43 | path: ./libs/${{ matrix.os-artifact[1] }} 44 | github_token: ${{ secrets.GITHUB_TOKEN }} 45 | name: ${{ matrix.os-artifact[1] }} 46 | 47 | - name: Install Dart dependencies 48 | run: dart pub get 49 | shell: pwsh 50 | working-directory: dart 51 | 52 | - name: Build, Test, Pack 53 | run: | 54 | python ../devops/build_sdks.py --language=dart 55 | dart pub global activate coverage 56 | dart run coverage:test_with_coverage 57 | shell: pwsh 58 | working-directory: dart 59 | env: 60 | API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} 61 | OKAPI_LIBRARY_PATH: "${{ github.workspace }}/libs" 62 | - name: "Upload coverage to Codecov" 63 | uses: codecov/codecov-action@v3 64 | with: 65 | fail_ci_if_error: true 66 | directory: dart 67 | token: ${{ secrets.CODECOV_TOKEN }} 68 | -------------------------------------------------------------------------------- /.github/workflows/build-dotnet.yml: -------------------------------------------------------------------------------- 1 | name: .NET 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | pull_request: 7 | paths: 8 | - "dotnet/**" 9 | - "proto/**" 10 | - ".github/workflows/*dotnet*" 11 | - "devops/**" 12 | push: 13 | branches: 14 | - main 15 | paths: 16 | - "dotnet/**" 17 | - "proto/**" 18 | - ".github/workflows/*dotnet*" 19 | - "devops/**" 20 | 21 | jobs: 22 | build-and-test-dotnet: 23 | name: Build, Test 24 | runs-on: ${{ matrix.os-artifact[0] }} 25 | # runs-on: macos-latest 26 | strategy: 27 | fail-fast: false 28 | matrix: 29 | os-artifact: [ [windows-latest, windows], [macos-latest, macos] ] # [ubuntu-latest, linux] - doesn't support ios 30 | steps: 31 | - name: Checkout 32 | uses: actions/checkout@v3 33 | - name: Download workflow artifact 34 | uses: dawidd6/action-download-artifact@v2 35 | with: 36 | workflow: "build-libs.yml" 37 | path: ./libs/${{ matrix.os-artifact[1] }} 38 | github_token: ${{ secrets.GITHUB_TOKEN }} 39 | name: ${{ matrix.os-artifact[1] }} 40 | - uses: actions/setup-dotnet@v2 41 | with: 42 | dotnet-version: '6.0.x' 43 | - name: Build and Test coverage 44 | run: | 45 | dotnet workload install macos ios maccatalyst 46 | ./BuildAndTest.ps1 47 | working-directory: ./dotnet 48 | shell: pwsh 49 | - name: "Upload coverage to Codecov" 50 | uses: codecov/codecov-action@v3 51 | with: 52 | fail_ci_if_error: true 53 | directory: dotnet 54 | token: ${{ secrets.CODECOV_TOKEN }} 55 | -------------------------------------------------------------------------------- /.github/workflows/build-golang.yml: -------------------------------------------------------------------------------- 1 | name: Golang 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | pull_request: 7 | paths: 8 | - "go/**" 9 | - "proto/**" 10 | - ".github/workflows/*golang*" 11 | - "devops/**" 12 | push: 13 | branches: 14 | - main 15 | paths: 16 | - "go/**" 17 | - "proto/**" 18 | - ".github/workflows/*golang*" 19 | - "devops/**" 20 | 21 | jobs: 22 | build-and-test-golang: 23 | name: Build, Test 24 | runs-on: ${{ matrix.os-artifact[0] }} 25 | strategy: 26 | fail-fast: false 27 | matrix: 28 | os-artifact: [ [ubuntu-latest, linux], [windows-latest, windows-gnu], [macos-latest, macos] ] 29 | steps: 30 | - uses: actions/checkout@v3 31 | - name: Download workflow artifact 32 | uses: dawidd6/action-download-artifact@v2 33 | with: 34 | workflow: "build-libs.yml" 35 | path: ./libs/${{ matrix.os-artifact[1] }} 36 | github_token: ${{ secrets.GITHUB_TOKEN }} 37 | name: ${{ matrix.os-artifact[1] }} 38 | - name: Set up Go (default) 39 | uses: actions/setup-go@v3 40 | with: 41 | go-version: ^1.17 42 | - name: Set up Python 43 | uses: actions/setup-python@v4 44 | with: 45 | python-version: 3.9 46 | - name: Build and Test Golang 47 | run: | 48 | go version 49 | python ../../devops/build_sdks.py --language=golang 50 | go build 51 | go get .out 52 | go test -v -race -covermode atomic -coverprofile coverage.out 53 | shell: pwsh 54 | working-directory: go/okapi 55 | env: 56 | OKAPI_LIBRARY_PATH: "${{ github.workspace }}/libs" 57 | API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} 58 | GO111MODULE: on 59 | - name: "Upload coverage to Codecov" 60 | uses: codecov/codecov-action@v3 61 | with: 62 | fail_ci_if_error: true 63 | directory: go/okapi 64 | token: ${{ secrets.CODECOV_TOKEN }} 65 | -------------------------------------------------------------------------------- /.github/workflows/build-java.yml: -------------------------------------------------------------------------------- 1 | name: Java 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | pull_request: 7 | paths: 8 | - "java/**" 9 | - "proto/**" 10 | - ".github/workflows/*java*" 11 | - "devops/**" 12 | push: 13 | branches: 14 | - main 15 | paths: 16 | - "java/**" 17 | - "proto/**" 18 | - ".github/workflows/*java*" 19 | - "devops/**" 20 | 21 | jobs: 22 | build-and-test-java: 23 | name: Build, Test 24 | runs-on: ${{ matrix.os-artifact[0] }} 25 | strategy: 26 | fail-fast: false 27 | matrix: 28 | os-artifact: [ [ubuntu-latest, linux], [windows-latest, windows], [macos-latest, macos] ] 29 | java-version: [ '11', '16', '17' ] 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | - name: Set up JDK 34 | uses: actions/setup-java@v3 35 | with: 36 | java-version: ${{ matrix.java-version }} 37 | distribution: 'temurin' 38 | cache: 'gradle' 39 | - name: Set up Python 40 | uses: actions/setup-python@v4 41 | with: 42 | python-version: 3.9 43 | - name: Download workflow artifact 44 | uses: dawidd6/action-download-artifact@v2 45 | with: 46 | workflow: "build-libs.yml" 47 | path: ./libs/${{ matrix.os-artifact[1] }} 48 | github_token: ${{ secrets.GITHUB_TOKEN }} 49 | name: ${{ matrix.os-artifact[1] }} 50 | - name: Build with Gradle 51 | run: | 52 | python ../devops/build_sdks.py --language=java 53 | gradle build 54 | shell: pwsh 55 | working-directory: java 56 | env: 57 | API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} 58 | OKAPI_LIBRARY_PATH: "${{ github.workspace }}/libs" 59 | - name: "Upload coverage to Codecov" 60 | uses: codecov/codecov-action@v3 61 | with: 62 | fail_ci_if_error: true 63 | directory: java/build/reports/jacoco/test 64 | token: ${{ secrets.CODECOV_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/build-wasm.yml: -------------------------------------------------------------------------------- 1 | name: Wasm 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | pull_request: 7 | paths: 8 | - "wasm/**" 9 | - "proto/**" 10 | - ".github/workflows/*wasm*" 11 | - "devops/**" 12 | push: 13 | branches: 14 | - main 15 | paths: 16 | - "wasm/**" 17 | - "proto/**" 18 | - ".github/workflows/*wasm*" 19 | - "devops/**" 20 | 21 | jobs: 22 | build_test: 23 | name: Build, Test 24 | runs-on: ${{ matrix.os }} 25 | strategy: 26 | fail-fast: false 27 | matrix: 28 | os: [ ubuntu-latest, macos-latest ] # windows-latest has issues with wasm-pack.exe 29 | node-version: [ 14, 16, 18 ] 30 | target: [ 'node', 'browser' ] 31 | defaults: 32 | run: 33 | working-directory: ./wasm 34 | steps: 35 | - uses: actions/checkout@v3 36 | - name: Setup protoc 37 | uses: arduino/setup-protoc@v1 38 | with: 39 | repo-token: ${{ secrets.GITHUB_TOKEN }} 40 | - uses: jetli/wasm-pack-action@v0.3.0 41 | with: 42 | version: 'latest' 43 | - uses: actions/setup-node@v3 44 | name: Setup Node v${{ matrix.node-version }} 45 | with: 46 | node-version: ${{ matrix.node-version }} 47 | - run: | 48 | rustup toolchain uninstall stable 49 | rustup toolchain install stable 50 | rustup toolchain install stable --target wasm32-unknown-unknown 51 | - run: | 52 | npm install 53 | npm run build:proto 54 | npm run build:wasm:${{ matrix.target }} 55 | npm run test:${{ matrix.target }} 56 | shell: pwsh 57 | working-directory: ./wasm/packages/okapi 58 | - name: "Upload coverage to Codecov" 59 | uses: codecov/codecov-action@v3 60 | with: 61 | fail_ci_if_error: true 62 | directory: ./wasm/packages/okapi 63 | token: ${{ secrets.CODECOV_TOKEN }} 64 | if: ${{ matrix.target == 'node' }} -------------------------------------------------------------------------------- /.github/workflows/release-dart.yml: -------------------------------------------------------------------------------- 1 | name: Dart (release) 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | packageVersion: 7 | description: 'Version to build' 8 | required: true 9 | default: '' 10 | workflow_run: 11 | workflows: ["Release Platform Libraries"] 12 | branches: ["main", "v?.*"] 13 | types: 14 | - completed 15 | 16 | jobs: 17 | release-dart: 18 | name: Release Dart Package 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: actions/checkout@v3 22 | - name: Set up Dart 23 | uses: dart-lang/setup-dart@v1 24 | - name: Set up Python 25 | uses: actions/setup-python@v4 26 | with: 27 | python-version: 3.9 28 | - uses: trinsic-id/set-version@v0.1 29 | id: setversion 30 | with: 31 | githubToken: ${{ secrets.API_GITHUB_TOKEN }} 32 | overrideVersion: ${{ github.event.inputs.packageVersion }} 33 | - name: release-downloader 34 | uses: robinraju/release-downloader@v1 35 | with: 36 | repository: trinsic-id/okapi 37 | latest: true 38 | token: ${{ secrets.API_GITHUB_TOKEN }} 39 | fileName: "libs.zip" 40 | 41 | - name: Install Dart dependencies 42 | run: dart pub get 43 | shell: pwsh 44 | working-directory: dart 45 | 46 | - name: Build, Test, Pack 47 | run: | 48 | python ../devops/build_sdks.py --language=dart 49 | dart pub publish --dry-run 50 | shell: pwsh 51 | working-directory: dart 52 | env: 53 | API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} 54 | LD_LIBRARY_PATH: "${{ github.workspace }}/libs" 55 | -------------------------------------------------------------------------------- /.github/workflows/release-golang.yml: -------------------------------------------------------------------------------- 1 | name: "Golang (release)" 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | inputs: 7 | packageVersion: 8 | description: 'Version to build' 9 | required: true 10 | default: '' 11 | 12 | jobs: 13 | publish_go_tag: 14 | name: Tag golang 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v3 18 | - uses: trinsic-id/set-version@v0.1 19 | id: setversion 20 | with: 21 | githubToken: ${{ secrets.API_GITHUB_TOKEN }} 22 | overrideVersion: ${{ github.event.inputs.packageVersion }} 23 | - name: Create tag 24 | run: | 25 | git tag "go/v${{ steps.setversion.outputs.packageVersion }}" main 26 | git push origin "go/v${{ steps.setversion.outputs.packageVersion }}" -------------------------------------------------------------------------------- /.github/workflows/release-libs.yml: -------------------------------------------------------------------------------- 1 | name: "Release Platform Libraries" 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: [published, prereleased] 7 | 8 | jobs: 9 | publish_binaries_bundle: 10 | name: Upload libs.zip artifact 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: dawidd6/action-download-artifact@v2 14 | with: 15 | workflow: "build-libs.yml" 16 | path: ./libs 17 | branch: main 18 | - run: Compress-Archive -Path ./libs -DestinationPath ./libs.zip 19 | shell: pwsh 20 | - run: | 21 | $json = Invoke-WebRequest 'https://api.github.com/repos/trinsic-id/okapi/releases/latest' ` 22 | -Headers @{ "Authorization" = "Token $env:API_GITHUB_TOKEN"} | ConvertFrom-Json 23 | $version = $json.tag_name 24 | echo "RELEASE_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append 25 | shell: pwsh 26 | env: 27 | API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} 28 | - uses: svenstaro/upload-release-action@v2 29 | with: 30 | repo_token: ${{ secrets.GITHUB_TOKEN }} 31 | file: ./libs.zip 32 | asset_name: libs.zip 33 | tag: ${{ env.RELEASE_VERSION }} 34 | overwrite: true 35 | body: "Okapi binaries bundle" 36 | 37 | release-dotnet-wrapper: 38 | uses: ./.github/workflows/release-dotnet.yml 39 | needs: publish_binaries_bundle 40 | 41 | release-golang-wrapper: 42 | uses: ./.github/workflows/release-golang.yml 43 | needs: publish_binaries_bundle 44 | 45 | release-java-wrapper: 46 | uses: ./.github/workflows/release-java.yml 47 | needs: publish_binaries_bundle 48 | 49 | release-python-wrapper: 50 | uses: ./.github/workflows/release-python.yml 51 | needs: publish_binaries_bundle 52 | 53 | release-rust-wrapper: 54 | uses: ./.github/workflows/release-rust.yml 55 | needs: publish_binaries_bundle 56 | 57 | release-swift-wrapper: 58 | uses: ./.github/workflows/release-swift.yml 59 | needs: publish_binaries_bundle 60 | 61 | release-wasm-wrapper: 62 | uses: ./.github/workflows/release-wasm.yml 63 | needs: publish_binaries_bundle 64 | -------------------------------------------------------------------------------- /.github/workflows/release-python.yml: -------------------------------------------------------------------------------- 1 | name: "Python (release)" 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | inputs: 7 | packageVersion: 8 | description: 'Version to build' 9 | required: true 10 | default: '' 11 | 12 | jobs: 13 | release_pypi: 14 | name: Python Package deploy 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@master 18 | - name: Set up Python 3.9 19 | uses: actions/setup-python@v4 20 | with: 21 | python-version: 3.9 22 | - uses: trinsic-id/set-version@v0.1 23 | id: setversion 24 | with: 25 | githubToken: ${{ secrets.API_GITHUB_TOKEN }} 26 | overrideVersion: ${{ github.event.inputs.packageVersion }} 27 | - name: release-downloader 28 | uses: robinraju/release-downloader@v1 29 | with: 30 | repository: trinsic-id/okapi 31 | latest: true 32 | token: ${{ secrets.API_GITHUB_TOKEN }} 33 | fileName: "libs.zip" 34 | - name: Build, Test, Pack 35 | run: | 36 | python -m pip install -r requirements.txt 37 | python ../devops/build_sdks.py --package-version=${{ steps.setversion.outputs.packageVersion }} --language=python 38 | python -m build --sdist --wheel --outdir dist/ . 39 | shell: pwsh 40 | working-directory: python 41 | env: 42 | LD_LIBRARY_PATH: "${{ github.workspace }}/libs" 43 | API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} 44 | - name: Publish distribution 📦 to PyPI 45 | uses: pypa/gh-action-pypi-publish@master 46 | with: 47 | user: __token__ 48 | password: ${{ secrets.PYPI_API_TOKEN }} 49 | packages_dir: ./python/dist 50 | -------------------------------------------------------------------------------- /.github/workflows/release-wasm.yml: -------------------------------------------------------------------------------- 1 | name: "Wasm (release)" 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | inputs: 7 | packageVersion: 8 | description: 'Version to build' 9 | required: true 10 | default: '' # For beta release: v1.0.0-rc[N] N=release candidate number https://kevinkreuzer.medium.com/publishing-a-beta-or-alpha-version-to-npm-46035b630dd7 11 | 12 | jobs: 13 | publish_npm: 14 | name: Publish Npm 15 | environment: 16 | name: npmjs.com 17 | runs-on: ubuntu-latest 18 | strategy: 19 | matrix: 20 | target: ['node', 'browser' ] 21 | defaults: 22 | run: 23 | working-directory: ./wasm 24 | shell: pwsh 25 | steps: 26 | - uses: actions/checkout@v3 27 | - name: Setup protoc 28 | uses: arduino/setup-protoc@v1 29 | with: 30 | repo-token: ${{ secrets.GITHUB_TOKEN }} 31 | - uses: jetli/wasm-pack-action@v0.3.0 32 | with: 33 | version: 'latest' 34 | - run: | 35 | rustup toolchain uninstall stable 36 | rustup toolchain install stable 37 | rustup toolchain install stable --target wasm32-unknown-unknown 38 | - uses: trinsic-id/set-version@v0.1 39 | id: setversion 40 | with: 41 | githubToken: ${{ secrets.API_GITHUB_TOKEN }} 42 | overrideVersion: ${{ github.event.inputs.packageVersion }} 43 | - run: npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} 44 | - run: | 45 | npm install 46 | npm run rename:${{ matrix.target }} 47 | npm version ${{ steps.setversion.outputs.packageVersion }} --no-git-tag-version --yes 48 | npm run build:proto 49 | npm run build:wasm:${{ matrix.target }} 50 | npm run package:${{ matrix.target }} 51 | npm publish --no-git-tag-version --yes --no-verify-access 52 | shell: pwsh 53 | working-directory: ./wasm/packages/okapi 54 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "swift"] 2 | path = swift 3 | url = https://github.com/trinsic-id/okapi-swift.git 4 | -------------------------------------------------------------------------------- /Initialize.ps1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env pwsh 2 | 3 | # This script initializes the repository by downloading the latest pre-built 4 | # libraries from the "okapi" github repo. These libraries are required to compile 5 | # some of the language specific wrappers. 6 | 7 | Set-Location $PSScriptRoot 8 | 9 | $Json = Invoke-WebRequest -Uri 'https://api.github.com/repos/trinsic-id/okapi/releases/latest' | ConvertFrom-Json 10 | $Asset = $Json.assets | Where-Object name -eq "libs.zip" 11 | 12 | if (Test-Path ./libs) { 13 | Remove-Item -Recurse -Exclude README.md ./libs 14 | } 15 | 16 | Invoke-WebRequest -Uri $Asset.browser_download_url -Out libs.zip 17 | Expand-Archive -Path libs.zip -DestinationPath ./ -Force 18 | Remove-Item -Path ./libs.zip 19 | -------------------------------------------------------------------------------- /Initialize.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # REQ: Translates Initialize.ps1 for Linux. <> 4 | 5 | from io import BytesIO 6 | from json import dumps, loads 7 | from os.path import dirname 8 | from urllib.request import Request, urlopen 9 | from zipfile import ZipFile 10 | 11 | request = Request("https://api.github.com/repos/trinsic-id/okapi/releases/latest") 12 | decoded = urlopen(request).read().decode("utf-8") 13 | assets = loads(decoded)["assets"] 14 | asset = [e for e in assets if e["name"] == "libs.zip"][0] 15 | 16 | print(dumps(asset, indent=2, sort_keys=True)) 17 | 18 | request = Request(asset["browser_download_url"]) 19 | read = urlopen(request).read() 20 | bytes = BytesIO(read) 21 | zip = ZipFile(bytes) 22 | 23 | print(zip.namelist()) 24 | 25 | dir = dirname(__file__) 26 | zip.extractall(dir) 27 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | We support only the latest release of the okapi binaries, which is dependent on upstream vulnerabilities being patched. Prior to `1.4.0`, there is an upstream vulnerability in the oberon library. 6 | 7 | | Version | Supported | 8 | | ------- | ------------------ | 9 | | 1.5.0 | :white_check_mark: | 10 | | 1.4.0 | :white_check_mark: | 11 | | < 1.4.0 | :x: | 12 | 13 | ## Reporting a Vulnerability 14 | 15 | Open an issue detailing the security concerns, or email `sec` + `ur` + `ity` [at] `trinsic.id` 16 | -------------------------------------------------------------------------------- /android/README.md: -------------------------------------------------------------------------------- 1 | Go here for the android okapi/trinsic services example application: 2 | https://github.com/trinsic-id/sdk-examples/tree/main/android -------------------------------------------------------------------------------- /buf.work.yml: -------------------------------------------------------------------------------- 1 | version: v1 2 | directories: 3 | - proto 4 | -------------------------------------------------------------------------------- /dart/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub. 2 | .dart_tool/ 3 | .packages 4 | 5 | # Conventional directory for build output. 6 | build/ 7 | -------------------------------------------------------------------------------- /dart/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.6.0 2 | ### Features/Improvements 3 | * native support for token verification by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/418 4 | * Okapi 419 `oberon_verify_token` language wrappers by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/420 5 | * Remove LdProofs.VerifyProof by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/425 6 | * expose the rust cargo.toml version string by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/422 7 | * Okapi 423 expose okapi metadata lang bindings by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/426 8 | 9 | ### Internal 10 | * Set up protoc for wasm actions by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/411 11 | * protoc rate limit remove by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/412 12 | * Release action rename by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/414 13 | * fix release action to handle beta releases by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/415 14 | * Okapi 1.6.0 RC2 by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/417 15 | * release wrappers when native libs are released automatically by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/428 16 | * Build WASM with emcc 2.x by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/429 17 | * 409 release dart by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/427 18 | * Various dart fixes by @fundthmcalculus in https://github.com/trinsic-id/okapi/pull/430 19 | 20 | 21 | **Full Changelog**: https://github.com/trinsic-id/okapi/compare/v1.5.0...v1.5.1 22 | 23 | ## 0.1.0 24 | 25 | - Default number of local development, similar to the native okapi binaries 26 | -------------------------------------------------------------------------------- /dart/README.md: -------------------------------------------------------------------------------- 1 | Dart bindings for okapi binary -------------------------------------------------------------------------------- /dart/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/any.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/any.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/any.pbjson.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/any.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | import 'dart:core' as $core; 9 | import 'dart:convert' as $convert; 10 | import 'dart:typed_data' as $typed_data; 11 | 12 | @$core.Deprecated('Use anyDescriptor instead') 13 | const Any$json = const { 14 | '1': 'Any', 15 | '2': const [ 16 | const {'1': 'type_url', '3': 1, '4': 1, '5': 9, '10': 'typeUrl'}, 17 | const {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, 18 | ], 19 | }; 20 | 21 | /// Descriptor for `Any`. Decode as a `google.protobuf.DescriptorProto`. 22 | final $typed_data.Uint8List anyDescriptor = $convert.base64Decode( 23 | 'CgNBbnkSGQoIdHlwZV91cmwYASABKAlSB3R5cGVVcmwSFAoFdmFsdWUYAiABKAxSBXZhbHVl'); 24 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/any.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/any.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'any.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/api.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/api.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/api.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/api.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'api.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/compiler/plugin.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/compiler/plugin.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | 8 | // ignore_for_file: UNDEFINED_SHOWN_NAME 9 | import 'dart:core' as $core; 10 | import 'package:protobuf/protobuf.dart' as $pb; 11 | 12 | class CodeGeneratorResponse_Feature extends $pb.ProtobufEnum { 13 | static const CodeGeneratorResponse_Feature FEATURE_NONE = 14 | CodeGeneratorResponse_Feature._( 15 | 0, 16 | const $core.bool.fromEnvironment('protobuf.omit_enum_names') 17 | ? '' 18 | : 'FEATURE_NONE'); 19 | static const CodeGeneratorResponse_Feature FEATURE_PROTO3_OPTIONAL = 20 | CodeGeneratorResponse_Feature._( 21 | 1, 22 | const $core.bool.fromEnvironment('protobuf.omit_enum_names') 23 | ? '' 24 | : 'FEATURE_PROTO3_OPTIONAL'); 25 | 26 | static const $core.List values = 27 | [ 28 | FEATURE_NONE, 29 | FEATURE_PROTO3_OPTIONAL, 30 | ]; 31 | 32 | static final $core.Map<$core.int, CodeGeneratorResponse_Feature> _byValue = 33 | $pb.ProtobufEnum.initByValue(values); 34 | static CodeGeneratorResponse_Feature? valueOf($core.int value) => 35 | _byValue[value]; 36 | 37 | const CodeGeneratorResponse_Feature._($core.int v, $core.String n) 38 | : super(v, n); 39 | } 40 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/compiler/plugin.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/compiler/plugin.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'plugin.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/descriptor.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/descriptor.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'descriptor.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/duration.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/duration.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/duration.pbjson.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/duration.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | import 'dart:core' as $core; 9 | import 'dart:convert' as $convert; 10 | import 'dart:typed_data' as $typed_data; 11 | 12 | @$core.Deprecated('Use durationDescriptor instead') 13 | const Duration$json = const { 14 | '1': 'Duration', 15 | '2': const [ 16 | const {'1': 'seconds', '3': 1, '4': 1, '5': 3, '10': 'seconds'}, 17 | const {'1': 'nanos', '3': 2, '4': 1, '5': 5, '10': 'nanos'}, 18 | ], 19 | }; 20 | 21 | /// Descriptor for `Duration`. Decode as a `google.protobuf.DescriptorProto`. 22 | final $typed_data.Uint8List durationDescriptor = $convert.base64Decode( 23 | 'CghEdXJhdGlvbhIYCgdzZWNvbmRzGAEgASgDUgdzZWNvbmRzEhQKBW5hbm9zGAIgASgFUgVuYW5vcw=='); 24 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/duration.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/duration.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'duration.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/empty.pb.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/empty.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | 8 | import 'dart:core' as $core; 9 | 10 | import 'package:protobuf/protobuf.dart' as $pb; 11 | 12 | class Empty extends $pb.GeneratedMessage { 13 | static final $pb.BuilderInfo _i = $pb.BuilderInfo( 14 | const $core.bool.fromEnvironment('protobuf.omit_message_names') 15 | ? '' 16 | : 'Empty', 17 | package: const $pb.PackageName( 18 | const $core.bool.fromEnvironment('protobuf.omit_message_names') 19 | ? '' 20 | : 'google.protobuf'), 21 | createEmptyInstance: create) 22 | ..hasRequiredFields = false; 23 | 24 | Empty._() : super(); 25 | factory Empty() => create(); 26 | factory Empty.fromBuffer($core.List<$core.int> i, 27 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 28 | create()..mergeFromBuffer(i, r); 29 | factory Empty.fromJson($core.String i, 30 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 31 | create()..mergeFromJson(i, r); 32 | @$core.Deprecated('Using this can add significant overhead to your binary. ' 33 | 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' 34 | 'Will be removed in next major version') 35 | Empty clone() => Empty()..mergeFromMessage(this); 36 | @$core.Deprecated('Using this can add significant overhead to your binary. ' 37 | 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 38 | 'Will be removed in next major version') 39 | Empty copyWith(void Function(Empty) updates) => 40 | super.copyWith((message) => updates(message as Empty)) 41 | as Empty; // ignore: deprecated_member_use 42 | $pb.BuilderInfo get info_ => _i; 43 | @$core.pragma('dart2js:noInline') 44 | static Empty create() => Empty._(); 45 | Empty createEmptyInstance() => create(); 46 | static $pb.PbList createRepeated() => $pb.PbList(); 47 | @$core.pragma('dart2js:noInline') 48 | static Empty getDefault() => 49 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 50 | static Empty? _defaultInstance; 51 | } 52 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/empty.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/empty.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/empty.pbjson.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/empty.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | import 'dart:core' as $core; 9 | import 'dart:convert' as $convert; 10 | import 'dart:typed_data' as $typed_data; 11 | 12 | @$core.Deprecated('Use emptyDescriptor instead') 13 | const Empty$json = const { 14 | '1': 'Empty', 15 | }; 16 | 17 | /// Descriptor for `Empty`. Decode as a `google.protobuf.DescriptorProto`. 18 | final $typed_data.Uint8List emptyDescriptor = 19 | $convert.base64Decode('CgVFbXB0eQ=='); 20 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/empty.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/empty.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'empty.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/field_mask.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/field_mask.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/field_mask.pbjson.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/field_mask.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | import 'dart:core' as $core; 9 | import 'dart:convert' as $convert; 10 | import 'dart:typed_data' as $typed_data; 11 | 12 | @$core.Deprecated('Use fieldMaskDescriptor instead') 13 | const FieldMask$json = const { 14 | '1': 'FieldMask', 15 | '2': const [ 16 | const {'1': 'paths', '3': 1, '4': 3, '5': 9, '10': 'paths'}, 17 | ], 18 | }; 19 | 20 | /// Descriptor for `FieldMask`. Decode as a `google.protobuf.DescriptorProto`. 21 | final $typed_data.Uint8List fieldMaskDescriptor = 22 | $convert.base64Decode('CglGaWVsZE1hc2sSFAoFcGF0aHMYASADKAlSBXBhdGhz'); 23 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/field_mask.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/field_mask.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'field_mask.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/source_context.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/source_context.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/source_context.pbjson.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/source_context.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | import 'dart:core' as $core; 9 | import 'dart:convert' as $convert; 10 | import 'dart:typed_data' as $typed_data; 11 | 12 | @$core.Deprecated('Use sourceContextDescriptor instead') 13 | const SourceContext$json = const { 14 | '1': 'SourceContext', 15 | '2': const [ 16 | const {'1': 'file_name', '3': 1, '4': 1, '5': 9, '10': 'fileName'}, 17 | ], 18 | }; 19 | 20 | /// Descriptor for `SourceContext`. Decode as a `google.protobuf.DescriptorProto`. 21 | final $typed_data.Uint8List sourceContextDescriptor = $convert.base64Decode( 22 | 'Cg1Tb3VyY2VDb250ZXh0EhsKCWZpbGVfbmFtZRgBIAEoCVIIZmlsZU5hbWU='); 23 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/source_context.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/source_context.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'source_context.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/struct.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/struct.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | 8 | // ignore_for_file: UNDEFINED_SHOWN_NAME 9 | import 'dart:core' as $core; 10 | import 'package:protobuf/protobuf.dart' as $pb; 11 | 12 | class NullValue extends $pb.ProtobufEnum { 13 | static const NullValue NULL_VALUE = NullValue._( 14 | 0, 15 | const $core.bool.fromEnvironment('protobuf.omit_enum_names') 16 | ? '' 17 | : 'NULL_VALUE'); 18 | 19 | static const $core.List values = [ 20 | NULL_VALUE, 21 | ]; 22 | 23 | static final $core.Map<$core.int, NullValue> _byValue = 24 | $pb.ProtobufEnum.initByValue(values); 25 | static NullValue? valueOf($core.int value) => _byValue[value]; 26 | 27 | const NullValue._($core.int v, $core.String n) : super(v, n); 28 | } 29 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/struct.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/struct.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'struct.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/timestamp.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/timestamp.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/timestamp.pbjson.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/timestamp.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | import 'dart:core' as $core; 9 | import 'dart:convert' as $convert; 10 | import 'dart:typed_data' as $typed_data; 11 | 12 | @$core.Deprecated('Use timestampDescriptor instead') 13 | const Timestamp$json = const { 14 | '1': 'Timestamp', 15 | '2': const [ 16 | const {'1': 'seconds', '3': 1, '4': 1, '5': 3, '10': 'seconds'}, 17 | const {'1': 'nanos', '3': 2, '4': 1, '5': 5, '10': 'nanos'}, 18 | ], 19 | }; 20 | 21 | /// Descriptor for `Timestamp`. Decode as a `google.protobuf.DescriptorProto`. 22 | final $typed_data.Uint8List timestampDescriptor = $convert.base64Decode( 23 | 'CglUaW1lc3RhbXASGAoHc2Vjb25kcxgBIAEoA1IHc2Vjb25kcxIUCgVuYW5vcxgCIAEoBVIFbmFub3M='); 24 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/timestamp.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/timestamp.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'timestamp.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/type.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/type.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'type.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/wrappers.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/wrappers.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields 7 | -------------------------------------------------------------------------------- /dart/lib/proto/google/protobuf/wrappers.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: google/protobuf/wrappers.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package 7 | 8 | export 'wrappers.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/examples/v1/examples.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/examples/v1/examples.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/examples/v1/examples.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/examples/v1/examples.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | import 'dart:async' as $async; 9 | 10 | import 'package:protobuf/protobuf.dart' as $pb; 11 | 12 | import 'dart:core' as $core; 13 | import '../../../pbmse/v1/pbmse.pb.dart' as $2; 14 | import 'examples.pbjson.dart'; 15 | 16 | export 'examples.pb.dart'; 17 | 18 | abstract class SecureExampleServiceBase extends $pb.GeneratedService { 19 | $async.Future<$2.EncryptedMessage> unary( 20 | $pb.ServerContext ctx, $2.EncryptedMessage request); 21 | $async.Future<$2.EncryptedMessage> serverStreaming( 22 | $pb.ServerContext ctx, $2.EncryptedMessage request); 23 | 24 | $pb.GeneratedMessage createRequest($core.String method) { 25 | switch (method) { 26 | case 'Unary': 27 | return $2.EncryptedMessage(); 28 | case 'ServerStreaming': 29 | return $2.EncryptedMessage(); 30 | default: 31 | throw $core.ArgumentError('Unknown method: $method'); 32 | } 33 | } 34 | 35 | $async.Future<$pb.GeneratedMessage> handleCall($pb.ServerContext ctx, 36 | $core.String method, $pb.GeneratedMessage request) { 37 | switch (method) { 38 | case 'Unary': 39 | return this.unary(ctx, request as $2.EncryptedMessage); 40 | case 'ServerStreaming': 41 | return this.serverStreaming(ctx, request as $2.EncryptedMessage); 42 | default: 43 | throw $core.ArgumentError('Unknown method: $method'); 44 | } 45 | } 46 | 47 | $core.Map<$core.String, $core.dynamic> get $json => 48 | SecureExampleServiceBase$json; 49 | $core.Map<$core.String, $core.Map<$core.String, $core.dynamic>> 50 | get $messageJson => SecureExampleServiceBase$messageJson; 51 | } 52 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/hashing/v1/hashing.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/hashing/v1/hashing.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/hashing/v1/hashing.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/hashing/v1/hashing.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | export 'hashing.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/keys/v1/keys.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/keys/v1/keys.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | export 'keys.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/metadata/metadata.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/metadata/metadata.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/metadata/metadata.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/metadata/metadata.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | export 'metadata.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/proofs/v1/proofs.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/proofs/v1/proofs.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | // ignore_for_file: UNDEFINED_SHOWN_NAME 9 | import 'dart:core' as $core; 10 | import 'package:protobuf/protobuf.dart' as $pb; 11 | 12 | class LdSuite extends $pb.ProtobufEnum { 13 | static const LdSuite LD_SUITE_UNSPECIFIED = LdSuite._( 14 | 0, 15 | const $core.bool.fromEnvironment('protobuf.omit_enum_names') 16 | ? '' 17 | : 'LD_SUITE_UNSPECIFIED'); 18 | static const LdSuite LD_SUITE_JCSED25519SIGNATURE2020 = LdSuite._( 19 | 1, 20 | const $core.bool.fromEnvironment('protobuf.omit_enum_names') 21 | ? '' 22 | : 'LD_SUITE_JCSED25519SIGNATURE2020'); 23 | 24 | static const $core.List values = [ 25 | LD_SUITE_UNSPECIFIED, 26 | LD_SUITE_JCSED25519SIGNATURE2020, 27 | ]; 28 | 29 | static final $core.Map<$core.int, LdSuite> _byValue = 30 | $pb.ProtobufEnum.initByValue(values); 31 | static LdSuite? valueOf($core.int value) => _byValue[value]; 32 | 33 | const LdSuite._($core.int v, $core.String n) : super(v, n); 34 | } 35 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/proofs/v1/proofs.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/proofs/v1/proofs.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | export 'proofs.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/security/v1/security.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/security/v1/security.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/security/v1/security.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/security/v1/security.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | export 'security.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/transport/v1/transport.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/transport/v1/transport.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | -------------------------------------------------------------------------------- /dart/lib/proto/okapi/transport/v1/transport.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: okapi/transport/v1/transport.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | export 'transport.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/lib/proto/pbmse/v1/pbmse.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: pbmse/v1/pbmse.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | export 'pbmse.pb.dart'; 9 | -------------------------------------------------------------------------------- /dart/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: okapi_dart 2 | description: Dart language bindings for okapi 3 | version: 1.6.1 4 | homepage: 'https://github.com/trinsic-id/okapi/' 5 | 6 | environment: 7 | sdk: '>=2.16.2 <3.0.0' 8 | 9 | 10 | dependencies: 11 | ffi: ^2.0.0 12 | protobuf: ^2.0.0 13 | path: ^1.8.1 14 | fixnum: ^1.0.1 15 | 16 | dev_dependencies: 17 | lints: any 18 | test: ^1.16.0 19 | convert: any 20 | fast_base58: any 21 | coverage: ^1.3.2 -------------------------------------------------------------------------------- /devops/build_winget.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | import yaml 4 | import requests 5 | import json 6 | 7 | # This only runs if you have the winget-pkgs repository downloaded. 8 | okapi_winget_path = r"C:\work\winget-pkgs\manifests\t\trinsic\okapi" 9 | existing_version = sorted(os.listdir(okapi_winget_path))[-1] 10 | 11 | # Go to github releases, get the latest 12 | data = requests.get(r"https://api.github.com/repos/trinsic-id/okapi/releases") 13 | release_json = json.loads(data.content) 14 | release_version = str(release_json[0]["name"]).replace("v", "") 15 | # TODO - Get the provided version 16 | 17 | # Create new version dir 18 | release_manifest = os.path.join(okapi_winget_path, release_version) 19 | shutil.rmtree(release_manifest, ignore_errors=True) 20 | shutil.copytree( 21 | os.path.join(okapi_winget_path, existing_version), 22 | release_manifest, 23 | dirs_exist_ok=True, 24 | ) 25 | 26 | # Update the yaml files 27 | installer_yaml_file = os.path.join(release_manifest, "trinsic.okapi.installer.yaml") 28 | with open(installer_yaml_file, "r") as f: 29 | installer_doc = yaml.load(f) 30 | 31 | installer_doc["PackageVersion"] = release_version 32 | installer_doc["Installers"][0]["InstallerUrl"] = [ 33 | asset["browser_download_url"] 34 | for asset in release_json[0]["assets"] 35 | if str(asset["browser_download_url"]).endswith(".msi") 36 | ][0] 37 | # Write the installer doc back out 38 | with open(installer_yaml_file, "w") as f: 39 | yaml.dump(installer_doc, f) 40 | -------------------------------------------------------------------------------- /devops/requirements.txt: -------------------------------------------------------------------------------- 1 | git+https://github.com/danielgtaylor/python-betterproto.git@master#egg=betterproto[compiler] 2 | grpcio-tools 3 | requests==2.31.0 4 | PyYAML==6.0 5 | gql[all]==3.4.0 6 | python-dateutil==2.8.2 7 | -------------------------------------------------------------------------------- /docs/_static/bad-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/_static/bad-form.png -------------------------------------------------------------------------------- /docs/_static/images/trust-triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/_static/images/trust-triangle.png -------------------------------------------------------------------------------- /docs/_static/javascripts/config.js: -------------------------------------------------------------------------------- 1 | document$.subscribe(() => { 2 | hljs.highlightAll(); 3 | }); 4 | 5 | 6 | function expandSubField(btn) { 7 | const MESSAGES = { 8 | "message": "child attributes", 9 | "enum": "enum values" 10 | } 11 | 12 | const type = btn.getAttribute("data-sub-type"); 13 | 14 | if(!type) { 15 | return; 16 | } 17 | 18 | const typeMessage = MESSAGES[type]; 19 | 20 | let expandContainer = btn.parentElement.querySelector(".proto-field-sub-child"); 21 | if(!expandContainer) { 22 | console.log("Btn has nothing to expand into!"); 23 | return; 24 | } 25 | 26 | if(expandContainer.classList.contains("hidden")) { 27 | expandContainer.classList.remove("hidden"); 28 | btn.innerText = "Hide " + typeMessage; 29 | } else { 30 | expandContainer.classList.add("hidden"); 31 | btn.innerText = "Show " + typeMessage; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /docs/_static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/_static/logo.png -------------------------------------------------------------------------------- /docs/_static/named-triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/_static/named-triangle.png -------------------------------------------------------------------------------- /docs/_static/stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/_static/stack.png -------------------------------------------------------------------------------- /docs/_static/trust-ecosystem-interop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/_static/trust-ecosystem-interop.jpg -------------------------------------------------------------------------------- /docs/_static/trust-ecosystem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/_static/trust-ecosystem.png -------------------------------------------------------------------------------- /docs/_static/trust-triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/_static/trust-triangle.png -------------------------------------------------------------------------------- /docs/images/design-approach-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/images/design-approach-1.png -------------------------------------------------------------------------------- /docs/images/design-approach-1.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | Alice -> [Send Message] 3 | [Send Message] -> (Encrypt) 4 | note right of (Encrypt) : Using a key exchange from\nAlice and Bob's DID docs 5 | (Encrypt) .. (Decrypt): Wire Transport 6 | (Decrypt) -> [Receive Message] 7 | [Receive Message] -> Bob 8 | @enduml -------------------------------------------------------------------------------- /docs/images/didcomm-arch-diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/docs/images/didcomm-arch-diag.png -------------------------------------------------------------------------------- /dotnet/.gitignore: -------------------------------------------------------------------------------- 1 | !Library/Okapi/build/** -------------------------------------------------------------------------------- /dotnet/BuildAndTest.ps1: -------------------------------------------------------------------------------- 1 | # Runs the tests and collects coverage results 2 | dotnet build -f net6.0 3 | if ($LASTEXITCODE -lt 0) { 4 | exit $LASTEXITCODE 5 | } 6 | dotnet test --% /p:CollectCoverage=true /p:CoverletOutput=./ /p:CoverletOutputFormat=cobertura 7 | if ($LASTEXITCODE -ge 0 -Or $LASTEXITCODE -le 1) { 8 | exit 0 9 | } else { 10 | exit $LASTEXITCODE 11 | } -------------------------------------------------------------------------------- /dotnet/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Trinsic Engineering Team 5 | Trinsic 6 | Apache-2.0 7 | https://github.com/trinsic-id/okapi 8 | BBS+ Ursa ZKP 9 | Okapi 10 | https://github.com/trinsic-id/okapi.git 11 | git 12 | 1.0.0 13 | true 14 | snupkg 15 | 16 | 17 | 18 | 19 | full 20 | latest 21 | $(NoWarn);1591 22 | disable 23 | false 24 | 25 | -------------------------------------------------------------------------------- /dotnet/Library/Okapi/ByteBuffer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Okapi; 5 | 6 | [StructLayout(LayoutKind.Sequential)] 7 | internal struct ByteBuffer 8 | { 9 | public long Length; 10 | public IntPtr Data; 11 | } -------------------------------------------------------------------------------- /dotnet/Library/Okapi/DIDComm.cs: -------------------------------------------------------------------------------- 1 | using Okapi.Transport.V1; 2 | 3 | namespace Okapi.Transport; 4 | 5 | public static class DIDComm 6 | { 7 | public static PackResponse Pack(PackRequest request) 8 | { 9 | return Native.Call(request, Native.didcomm_pack); 10 | } 11 | 12 | public static UnpackResponse Unpack(UnpackRequest request) 13 | { 14 | return Native.Call(request, Native.didcomm_unpack); 15 | } 16 | 17 | public static SignResponse Sign(SignRequest request) 18 | { 19 | return Native.Call(request, Native.didcomm_sign); 20 | } 21 | 22 | public static VerifyResponse Verify(VerifyRequest request) 23 | { 24 | return Native.Call(request, Native.didcomm_verify); 25 | } 26 | } -------------------------------------------------------------------------------- /dotnet/Library/Okapi/DIDCommException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Okapi; 5 | 6 | [Serializable] 7 | public class DIDCommException : Exception 8 | { 9 | public DIDCommException() 10 | { 11 | } 12 | 13 | public DIDCommException(int code, string message) : this(message) 14 | { 15 | Code = code; 16 | } 17 | 18 | public DIDCommException(string message) : base(message) 19 | { 20 | } 21 | 22 | public DIDCommException(string message, Exception inner) : base(message, inner) 23 | { 24 | } 25 | 26 | protected DIDCommException( 27 | SerializationInfo info, 28 | StreamingContext context) : base(info, context) 29 | { 30 | } 31 | 32 | public int Code { get; } 33 | } -------------------------------------------------------------------------------- /dotnet/Library/Okapi/DIDKey.cs: -------------------------------------------------------------------------------- 1 | using Okapi.Keys.V1; 2 | 3 | namespace Okapi.Keys; 4 | 5 | public static class DIDKey 6 | { 7 | /// 8 | /// Generate new key 9 | /// 10 | /// 11 | /// 12 | public static GenerateKeyResponse Generate(GenerateKeyRequest request) 13 | { 14 | return Native.Call(request, Native.didkey_generate); 15 | } 16 | 17 | public static ResolveResponse Resolve(ResolveRequest request) 18 | { 19 | return Native.Call(request, Native.didkey_resolve); 20 | } 21 | } -------------------------------------------------------------------------------- /dotnet/Library/Okapi/ExternError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Okapi; 5 | 6 | [StructLayout(LayoutKind.Sequential)] 7 | internal struct ExternError 8 | { 9 | internal int Code; 10 | internal IntPtr Message; 11 | } -------------------------------------------------------------------------------- /dotnet/Library/Okapi/Hashing.cs: -------------------------------------------------------------------------------- 1 | using Okapi.Hashing.V1; 2 | 3 | namespace Okapi.Hashing; 4 | 5 | public static class Blake3 6 | { 7 | public static Blake3HashResponse Hash(Blake3HashRequest request) 8 | { 9 | return Native.Call(request, Native.blake3_hash); 10 | } 11 | 12 | public static Blake3KeyedHashResponse KeyedHash(Blake3KeyedHashRequest request) 13 | { 14 | return Native.Call(request, Native.blake3_keyed_hash); 15 | } 16 | 17 | public static Blake3DeriveKeyResponse DeriveKey(Blake3DeriveKeyRequest request) 18 | { 19 | return Native.Call(request, Native.blake3_derive_key); 20 | } 21 | } 22 | 23 | public static class Sha256 24 | { 25 | public static SHA256HashResponse Hash(SHA256HashRequest request) 26 | { 27 | return Native.Call(request, Native.sha256_hash); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /dotnet/Library/Okapi/LDProofs.cs: -------------------------------------------------------------------------------- 1 | using Okapi.Proofs.V1; 2 | 3 | namespace Okapi.Proofs; 4 | 5 | public static class LDProofs 6 | { 7 | /// 8 | /// Generate new key 9 | /// 10 | /// 11 | /// 12 | public static CreateProofResponse CreateProof(CreateProofRequest request) 13 | { 14 | return Native.Call(request, Native.ldproofs_create_proof); 15 | } 16 | } -------------------------------------------------------------------------------- /dotnet/Library/Okapi/Oberon.cs: -------------------------------------------------------------------------------- 1 | using Okapi.Security.V1; 2 | 3 | namespace Okapi.Security; 4 | 5 | public static class Oberon 6 | { 7 | public static CreateOberonKeyResponse CreateKey(CreateOberonKeyRequest request) 8 | { 9 | return Native.Call(request, Native.oberon_create_key); 10 | } 11 | 12 | public static CreateOberonTokenResponse CreateToken(CreateOberonTokenRequest request) 13 | { 14 | return Native.Call(request, Native.oberon_create_token); 15 | } 16 | 17 | public static CreateOberonProofResponse CreateProof(CreateOberonProofRequest request) 18 | { 19 | return Native.Call(request, Native.oberon_create_proof); 20 | } 21 | 22 | public static VerifyOberonProofResponse VerifyProof(VerifyOberonProofRequest request) 23 | { 24 | return Native.Call(request, Native.oberon_verify_proof); 25 | } 26 | 27 | public static BlindOberonTokenResponse BlindToken(BlindOberonTokenRequest request) 28 | { 29 | return Native.Call(request, Native.oberon_blind_token); 30 | } 31 | 32 | public static UnBlindOberonTokenResponse UnblindToken(UnBlindOberonTokenRequest request) 33 | { 34 | return Native.Call(request, Native.oberon_unblind_token); 35 | } 36 | 37 | public static VerifyOberonTokenResponse VerifyToken(VerifyOberonTokenRequest request) 38 | { 39 | return Native.Call(request, Native.oberon_verify_token); 40 | } 41 | } -------------------------------------------------------------------------------- /dotnet/Library/Okapi/OkapiMetadata.cs: -------------------------------------------------------------------------------- 1 | using Okapi.Proofs.V1; 2 | 3 | namespace Okapi.Metadata; 4 | 5 | public static class OkapiMetadata 6 | { 7 | /// 8 | /// Generate new key 9 | /// 10 | /// 11 | /// 12 | public static MetadataResponse GetMetadata() 13 | { 14 | return Native.Call(new MetadataRequest(), Native.okapi_metadata); 15 | } 16 | } -------------------------------------------------------------------------------- /dotnet/Library/Okapi/build/android/Okapi.Net.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Always 7 | arm64-v8a 8 | 9 | 10 | 11 | Always 12 | armeabi-v7a 13 | 14 | 15 | 16 | Always 17 | x86 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /dotnet/Library/Okapi/build/ios/Okapi.Net.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Static 7 | True 8 | 9 | 10 | 11 | 12 | 13 | Static 14 | True 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /dotnet/Library/Okapi/build/maccatalyst/Okapi.Net.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Static 7 | True 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /dotnet/Library/Okapi/build/net/Okapi.Net.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Always 6 | okapi.dll 7 | false 8 | 9 | 10 | Always 11 | libokapi.so 12 | false 13 | 14 | 15 | Always 16 | libokapi.dylib 17 | false 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /dotnet/README.md: -------------------------------------------------------------------------------- 1 | # Okapi for .NET 2 | 3 | ## Usage 4 | 5 | ``` 6 | dotnet add package Okapi.Net 7 | ``` 8 | 9 | ## To build nuget package 10 | 11 | ``` 12 | msbuild /p:SkipNativeLibsCopy=true /p:Configuration=Release /t:build,pack 13 | ``` 14 | -------------------------------------------------------------------------------- /dotnet/Tests/Okapi.Tests/DidCommTests.cs: -------------------------------------------------------------------------------- 1 | using Google.Protobuf; 2 | using Okapi.Examples.V1; 3 | using Okapi.Keys.V1; 4 | using Okapi.Transport; 5 | using Okapi.Transport.V1; 6 | using Pbmse.V1; 7 | using Xunit; 8 | 9 | namespace Okapi.Tests; 10 | 11 | public class DidCommTests 12 | { 13 | [Fact] 14 | public void TestPack() 15 | { 16 | var message = new BasicMessage { Text = "Hello world" }; 17 | 18 | var encryptedMessage = DIDComm.Pack(new PackRequest 19 | { Plaintext = message.ToByteString(), SenderKey = Alice.SecretKey, ReceiverKey = Bob.PublicKey, Mode = EncryptionMode.Direct }); 20 | 21 | Assert.NotNull(encryptedMessage); 22 | } 23 | } 24 | 25 | // From Greeter example 26 | public static class Alice 27 | { 28 | private const string KeyId = 29 | "did:key:z6LSskw3r3441B8YnhcB1LKxmRqpEiyZH3Prpb6No1fHTze6#z6LSskw3r3441B8YnhcB1LKxmRqpEiyZH3Prpb6No1fHTze6"; 30 | 31 | public static JsonWebKey SecretKey = new() 32 | { 33 | Kid = KeyId, 34 | Kty = "OKP", 35 | Crv = "X25519", 36 | D = "oLio1cRmNIgQePHHJFeCdw0-j4ZtJBH0HVQU8fXahVs" 37 | }; 38 | 39 | public static JsonWebKey PublicKey = new() 40 | { 41 | Kid = KeyId, 42 | Kty = "OKP", 43 | Crv = "X25519", 44 | X = "7vLvUiaXEUgajINpIomBTwQtQCnf-r7cptpKTEWHzjs" 45 | }; 46 | } 47 | 48 | public static class Bob 49 | { 50 | private const string KeyId = 51 | "did:key:z6LSgKhoYDRJJaJ84wHjnW67r8RTaLExHhzrFZgd3Hh1md7j#z6LSgKhoYDRJJaJ84wHjnW67r8RTaLExHhzrFZgd3Hh1md7j"; 52 | 53 | public static JsonWebKey SecretKey = new() 54 | { 55 | Kid = KeyId, 56 | Kty = "OKP", 57 | Crv = "X25519", 58 | D = "cLH0xA7mdSp5zcxSOVepnMuFtJSWZtRI0PoR2cET420" 59 | }; 60 | 61 | public static JsonWebKey PublicKey = new() 62 | { 63 | Kid = KeyId, 64 | Kty = "OKP", 65 | Crv = "X25519", 66 | X = "RQvhX5wPpmHdd97FxvC_xK3GB0VpyLhN5xQN45EwjXY" 67 | }; 68 | } -------------------------------------------------------------------------------- /dotnet/Tests/Okapi.Tests/LdProofsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using FluentAssertions; 4 | using Google.Protobuf; 5 | using Google.Protobuf.WellKnownTypes; 6 | using Newtonsoft.Json.Linq; 7 | using Okapi.Keys; 8 | using Okapi.Keys.V1; 9 | using Okapi.Proofs; 10 | using Okapi.Proofs.V1; 11 | using Xunit; 12 | 13 | namespace Okapi.Tests; 14 | 15 | public class LdProofsTests 16 | { 17 | [Fact] 18 | public void GenerateCapabilityInvocationProofWithJcs() 19 | { 20 | var capability = new JObject 21 | { 22 | { "@context", "https://w3id.org/security/v2" }, 23 | { "target", "urn:trinsic:wallets:noop" }, 24 | { 25 | "proof", new JObject 26 | { 27 | { "created", DateTime.UtcNow.ToString("s") } 28 | } 29 | } 30 | }; 31 | 32 | var key = DIDKey.Generate(new GenerateKeyRequest { KeyType = KeyType.Ed25519 }); 33 | var signingKey = key.Key.First(x => x.Crv == "Ed25519"); 34 | 35 | var signedCapability = LDProofs.CreateProof(new CreateProofRequest 36 | { 37 | Key = signingKey, 38 | Document = capability.ToStruct(), 39 | Suite = LdSuite.Jcsed25519Signature2020 40 | }); 41 | 42 | signedCapability.Should().NotBeNull(); 43 | signedCapability.SignedDocument.Should().NotBeNull(); 44 | } 45 | } 46 | 47 | public static class JTokenExtensions 48 | { 49 | /// 50 | /// Converts to struct. 51 | /// 52 | /// The jobj. 53 | /// 54 | public static Struct ToStruct(this JToken token) 55 | { 56 | return JsonParser.Default.Parse(token.ToString()); 57 | } 58 | } -------------------------------------------------------------------------------- /dotnet/Tests/Okapi.Tests/MetadataTests.cs: -------------------------------------------------------------------------------- 1 | using Google.Protobuf; 2 | using Okapi.Examples.V1; 3 | using Okapi.Keys.V1; 4 | using Okapi.Metadata; 5 | using Okapi.Transport; 6 | using Okapi.Transport.V1; 7 | using Pbmse.V1; 8 | using Xunit; 9 | 10 | namespace Okapi.Tests; 11 | 12 | public class MetadataTests 13 | { 14 | [Fact] 15 | public void TestGetMetadata() 16 | { 17 | var response = OkapiMetadata.GetMetadata(); 18 | Assert.NotNull(response); 19 | Assert.False(string.IsNullOrWhiteSpace(response.Version)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dotnet/Tests/Okapi.Tests/Okapi.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | false 6 | 7 | 8 | 9 | 4 10 | 11 | 12 | 13 | 14 | 15 | 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | all 18 | 19 | 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | all 22 | 23 | 24 | runtime; build; native; contentfiles; analyzers; buildtransitive 25 | all 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /dotnet/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "6.0.100", 4 | "rollForward": "latestFeature", 5 | "allowPrerelease": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /go/.gitignore: -------------------------------------------------------------------------------- 1 | *.dylib 2 | *.so 3 | *.dll -------------------------------------------------------------------------------- /go/README.md: -------------------------------------------------------------------------------- 1 | # Okapi Go Bindings 2 | 3 | ## Usage 4 | 5 | ``` 6 | go get https://github.com/trinsic-id/okapi/go 7 | ``` 8 | 9 | ## Dependencies 10 | 11 | The bindings use `cgo` to call into the native functionality. We maintain pre-built packages for some systems. 12 | 13 | ### Homebrew (MacOS and Linux) 14 | 15 | We maintain a Homebrew Tap with bottles for MacOS and Linux. To install run: 16 | 17 | ``` 18 | brew install trinsic-id/tap/okapi 19 | ``` 20 | 21 | ### `dpkg` for Linux 22 | 23 | You can find .deb packages for your platform with [each release](https://github.com/trinsic-id/okapi/releases). These can be installed using `dpkg`. 24 | Choose the package for your architecture. 25 | The packages will install the required libraries and header files. 26 | 27 | ``` 28 | wget https://github.com/trinsic-id/okapi/releases/download/v1.1.0/okapi_1.1.0_amd64.deb 29 | 30 | dpkg -i okapi_1.1.0_amd64.deb 31 | ``` 32 | -------------------------------------------------------------------------------- /go/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/trinsic-id/okapi/go 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/btcsuite/btcutil v1.0.2 7 | github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf 8 | github.com/stretchr/testify v1.8.0 9 | google.golang.org/protobuf v1.28.1 10 | ) 11 | 12 | require ( 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/pmezard/go-difflib v1.0.0 // indirect 15 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect 16 | gopkg.in/yaml.v3 v3.0.1 // indirect 17 | ) 18 | -------------------------------------------------------------------------------- /go/okapi/README.md: -------------------------------------------------------------------------------- 1 | 1. To find the latest binary packages, go to the [output of the action](https://github.com/trinsic-id/okapi/actions/workflows/build-libs.yml) 2 | 2. Click on the latest successful run, scroll down to the artifacts 3 | 3. Download `C_header` for `okapi.h` 4 | 4. Dowwnload the OS appropriate artifact (Windows-GNU not Windows) -------------------------------------------------------------------------------- /go/okapi/didcomm.go: -------------------------------------------------------------------------------- 1 | package okapi 2 | 3 | import "github.com/trinsic-id/okapi/go/okapi/transport/v1/transport" 4 | 5 | // DidCommer implements the DIDComm Messaging protocol 6 | type DidCommer interface { 7 | Pack(request *transport.PackRequest) (*transport.PackResponse, error) 8 | Unpack(request *transport.UnpackRequest) (*transport.UnpackResponse, error) 9 | Sign(request *transport.SignRequest) (*transport.SignResponse, error) 10 | Verify(request *transport.VerifyRequest) (*transport.VerifyResponse, error) 11 | } 12 | 13 | // DidComm implements the DIDComm Messaging protocol 14 | func DidComm() DidCommer { 15 | return &didComm{} 16 | } 17 | 18 | type didComm struct{} 19 | 20 | func (d *didComm) Pack(request *transport.PackRequest) (*transport.PackResponse, error) { 21 | response := transport.PackResponse{} 22 | err := callOkapiNative(request, &response, "didcomm_pack") 23 | return &response, err 24 | } 25 | 26 | func (d *didComm) Unpack(request *transport.UnpackRequest) (*transport.UnpackResponse, error) { 27 | response := transport.UnpackResponse{} 28 | err := callOkapiNative(request, &response, "didcomm_unpack") 29 | return &response, err 30 | } 31 | 32 | func (d *didComm) Sign(request *transport.SignRequest) (*transport.SignResponse, error) { 33 | response := transport.SignResponse{} 34 | err := callOkapiNative(request, &response, "didcomm_sign") 35 | return &response, err 36 | } 37 | 38 | func (d *didComm) Verify(request *transport.VerifyRequest) (*transport.VerifyResponse, error) { 39 | response := transport.VerifyResponse{} 40 | err := callOkapiNative(request, &response, "didcomm_verify") 41 | return &response, err 42 | } 43 | -------------------------------------------------------------------------------- /go/okapi/didkey.go: -------------------------------------------------------------------------------- 1 | package okapi 2 | 3 | import "github.com/trinsic-id/okapi/go/okapi/keys/v1/keys" 4 | 5 | // DidKeyer is the interface that groups the did:key functions 6 | type DidKeyer interface { 7 | Generate(request *keys.GenerateKeyRequest) (*keys.GenerateKeyResponse, error) 8 | Resolve(request *keys.ResolveRequest) (*keys.ResolveResponse, error) 9 | } 10 | 11 | // DidKey returns a DidKeyer that can generate and resolve did:keys 12 | func DidKey() DidKeyer { 13 | return &didKey{} 14 | } 15 | 16 | type didKey struct{} 17 | 18 | func (d *didKey) Generate(request *keys.GenerateKeyRequest) (*keys.GenerateKeyResponse, error) { 19 | response := keys.GenerateKeyResponse{} 20 | err := callOkapiNative(request, &response, "didkey_generate") 21 | return &response, err 22 | } 23 | 24 | func (d *didKey) Resolve(request *keys.ResolveRequest) (*keys.ResolveResponse, error) { 25 | response := keys.ResolveResponse{} 26 | err := callOkapiNative(request, &response, "didkey_resolve") 27 | return &response, err 28 | } 29 | -------------------------------------------------------------------------------- /go/okapi/hashing.go: -------------------------------------------------------------------------------- 1 | package okapi 2 | 3 | import "github.com/trinsic-id/okapi/go/okapi/hashing/v1/hashing" 4 | 5 | // Hasher implements Blake3 and Sha2 hash functions 6 | type Hasher interface { 7 | Sha256Hash(request *hashing.SHA256HashRequest) (*hashing.SHA256HashResponse, error) 8 | Blake3Hash(request *hashing.Blake3HashRequest) (*hashing.Blake3HashResponse, error) 9 | Blake3KeyedHash(request *hashing.Blake3KeyedHashRequest) (*hashing.Blake3KeyedHashResponse, error) 10 | Blake3DeriveKey(request *hashing.Blake3DeriveKeyRequest) (*hashing.Blake3DeriveKeyResponse, error) 11 | } 12 | 13 | // Hashing implements Blake3 and Sha2 hash functions 14 | func Hashing() Hasher { 15 | return &hasher{} 16 | } 17 | 18 | type hasher struct{} 19 | 20 | func (h *hasher) Sha256Hash(request *hashing.SHA256HashRequest) (*hashing.SHA256HashResponse, error) { 21 | response := hashing.SHA256HashResponse{} 22 | err := callOkapiNative(request, &response, "sha256_hash") 23 | return &response, err 24 | } 25 | 26 | func (h *hasher) Blake3Hash(request *hashing.Blake3HashRequest) (*hashing.Blake3HashResponse, error) { 27 | response := hashing.Blake3HashResponse{} 28 | err := callOkapiNative(request, &response, "blake3_hash") 29 | return &response, err 30 | } 31 | 32 | func (h *hasher) Blake3KeyedHash(request *hashing.Blake3KeyedHashRequest) (*hashing.Blake3KeyedHashResponse, error) { 33 | response := hashing.Blake3KeyedHashResponse{} 34 | err := callOkapiNative(request, &response, "blake3_keyed_hash") 35 | return &response, err 36 | } 37 | 38 | func (h *hasher) Blake3DeriveKey(request *hashing.Blake3DeriveKeyRequest) (*hashing.Blake3DeriveKeyResponse, error) { 39 | response := hashing.Blake3DeriveKeyResponse{} 40 | err := callOkapiNative(request, &response, "blake3_derive_key") 41 | return &response, err 42 | } 43 | -------------------------------------------------------------------------------- /go/okapi/ldproofs.go: -------------------------------------------------------------------------------- 1 | package okapi 2 | 3 | import "github.com/trinsic-id/okapi/go/okapi/proofs/v1/proofs" 4 | 5 | // LdProofer implements Linked-Data Proofs 6 | type LdProofer interface { 7 | CreateProof(request *proofs.CreateProofRequest) (*proofs.CreateProofResponse, error) 8 | } 9 | 10 | // LdProofs implements Linked-Data Proofs 11 | func LdProofs() LdProofer { 12 | return &ldProofs{} 13 | } 14 | 15 | type ldProofs struct{} 16 | 17 | func (l *ldProofs) CreateProof(request *proofs.CreateProofRequest) (*proofs.CreateProofResponse, error) { 18 | response := proofs.CreateProofResponse{} 19 | err := callOkapiNative(request, &response, "ldproofs_create_proof") 20 | return &response, err 21 | } 22 | -------------------------------------------------------------------------------- /go/okapi/ldproofs_test.go: -------------------------------------------------------------------------------- 1 | package okapi 2 | 3 | import ( 4 | "github.com/trinsic-id/okapi/go/okapi/keys/v1/keys" 5 | "github.com/trinsic-id/okapi/go/okapi/proofs/v1/proofs" 6 | "testing" 7 | "time" 8 | 9 | "github.com/stretchr/testify/assert" 10 | "google.golang.org/protobuf/types/known/structpb" 11 | ) 12 | 13 | func TestGenerateCapabilityInvocationProofWithJCS(t *testing.T) { 14 | assert := assert.New(t) 15 | dk := DidKey() 16 | ldp := LdProofs() 17 | 18 | proofStruct, err := structpb.NewStruct(map[string]interface{}{ 19 | "@context": "https://w3id.org/security/v2", 20 | "target": "urn:trinsic:wallets:noop", 21 | "proof": map[string]interface{}{ 22 | "created": time.Now().Format(time.RFC3339), 23 | }, 24 | }) 25 | if !assert.Nil(err) { 26 | return 27 | } 28 | 29 | request := keys.GenerateKeyRequest{KeyType: keys.KeyType_KEY_TYPE_ED25519} 30 | response, err := dk.Generate(&request) 31 | if !assert.Nil(err) { 32 | return 33 | } 34 | 35 | signingKey := &keys.JsonWebKey{} 36 | for _, key := range response.Key { 37 | if key.Crv == "Ed25519" { 38 | signingKey = key 39 | break 40 | } 41 | } 42 | signedCapability, err := ldp.CreateProof(&proofs.CreateProofRequest{ 43 | Document: proofStruct, 44 | Key: signingKey, 45 | Suite: proofs.LdSuite_LD_SUITE_JCSED25519SIGNATURE2020, 46 | }) 47 | if !assert.Nil(err) { 48 | return 49 | } 50 | assert.NotNil(signedCapability) 51 | assert.NotNil(signedCapability.SignedDocument) 52 | } 53 | -------------------------------------------------------------------------------- /go/okapi/metadata.go: -------------------------------------------------------------------------------- 1 | package okapi 2 | 3 | import "github.com/trinsic-id/okapi/go/okapi/metadata" 4 | 5 | // Metadataer implements Linked-Data Proofs 6 | type OkapiMetadataer interface { 7 | GetMetadata() (*metadata.MetadataResponse, error) 8 | } 9 | 10 | // OkapiMetadata implements Linked-Data Proofs 11 | func OkapiMetadata() OkapiMetadataer { 12 | return &okapiMetadata{} 13 | } 14 | 15 | type okapiMetadata struct{} 16 | 17 | func (o okapiMetadata) GetMetadata() (*metadata.MetadataResponse, error) { 18 | request := &metadata.MetadataRequest{} 19 | response := metadata.MetadataResponse{} 20 | err := callOkapiNative(request, &response, "okapi_metadata") 21 | return &response, err 22 | } 23 | -------------------------------------------------------------------------------- /go/okapi/metadata_test.go: -------------------------------------------------------------------------------- 1 | package okapi 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "github.com/trinsic-id/okapi/go/okapi/keys/v1/keys" 6 | "testing" 7 | ) 8 | 9 | func TestOkapiMetadataVersion(t *testing.T) { 10 | assert := assert.New(t) 11 | om := OkapiMetadata() 12 | 13 | request := keys.GenerateKeyRequest{} 14 | request.KeyType = keys.KeyType_KEY_TYPE_ED25519 15 | request.Seed = []byte{1, 2, 3} 16 | 17 | response, err := om.GetMetadata() 18 | assert.Nil(err) 19 | assert.NotNil(response) 20 | assert.NotNil(response.Version) 21 | assert.True(len(response.Version) > 0) 22 | } 23 | -------------------------------------------------------------------------------- /go/okapi/native_call_windows.go: -------------------------------------------------------------------------------- 1 | package okapi 2 | 3 | import ( 4 | "google.golang.org/protobuf/proto" 5 | "syscall" 6 | "unsafe" 7 | ) 8 | 9 | func callOkapiNative(request proto.Message, response proto.Message, funcName string) error { 10 | requestBuffer, responseBuffer, errorBuffer, err := createBuffersFromMessage(request) 11 | if err != nil { 12 | return wrapError("Failed to create buffers", err) 13 | } 14 | dll := syscall.MustLoadDLL(getLibraryPath()) 15 | okapiFunc := dll.MustFindProc(funcName) 16 | _, _, err = okapiFunc.Call(uintptr(unsafe.Pointer(&requestBuffer)), uintptr(unsafe.Pointer(&responseBuffer)), uintptr(unsafe.Pointer(&errorBuffer))) 17 | if err != syscall.Errno(0x0) { 18 | // Actually check the syscall.Errno to see if it's a real error 19 | return err 20 | } 21 | err = unmarshalResponse(responseBuffer, response) 22 | if err != nil { 23 | return wrapError("Failed to unmarshal response", err) 24 | } 25 | return createError(errorBuffer) 26 | } 27 | 28 | func byteBufferFree(responseBuffer ByteBuffer) error { 29 | dll := syscall.MustLoadDLL(getLibraryPath()) 30 | okapiFunc := dll.MustFindProc("okapi_bytebuffer_free") 31 | _, _, err := okapiFunc.Call(uintptr(unsafe.Pointer(&responseBuffer))) 32 | if err != syscall.Errno(0x0) { 33 | // Actually check the syscall.Errno to see if it's a real error 34 | return err 35 | } 36 | return nil 37 | } 38 | 39 | func okapiStringFree(s uintptr) error { 40 | dll := syscall.MustLoadDLL(getLibraryPath()) 41 | okapiFunc := dll.MustFindProc("okapi_string_free") 42 | _, _, err := okapiFunc.Call(s) 43 | if err != syscall.Errno(0x0) { 44 | // Actually check the syscall.Errno to see if it's a real error 45 | return err 46 | } 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /include/module.modulemap: -------------------------------------------------------------------------------- 1 | module OkapiNative { 2 | header "okapi.h" 3 | export * 4 | } -------------------------------------------------------------------------------- /java/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /java/AndroidValues.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Trinsic Okapi bindings 4 | 5 | -------------------------------------------------------------------------------- /java/R.txt: -------------------------------------------------------------------------------- 1 | int string trinsic_library_appname 0xff00ff00 -------------------------------------------------------------------------------- /java/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/java/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /java/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /java/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'okapi' 2 | 3 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/DidException.java: -------------------------------------------------------------------------------- 1 | package trinsic.okapi; 2 | 3 | public class DidException extends Exception { 4 | public int ErrorCode = 0; 5 | 6 | public DidException(int errorCode, String message) { 7 | super(message); 8 | this.ErrorCode = errorCode; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/DidKey.java: -------------------------------------------------------------------------------- 1 | package trinsic.okapi; 2 | 3 | import com.google.protobuf.InvalidProtocolBufferException; 4 | import trinsic.okapi.keys.v1.Keys; 5 | 6 | public class DidKey extends OkapiNative { 7 | public static Keys.GenerateKeyResponse generate(Keys.GenerateKeyRequest request) 8 | throws DidException, InvalidProtocolBufferException { 9 | OkapiByteBuffer.ByValue requestBuffer = messageToBuffer(request); 10 | OkapiByteBuffer responseBuffer = new OkapiByteBuffer(); 11 | ExternError errBuffer = new ExternError(); 12 | var result = getNativeLibrary().didkey_generate(requestBuffer, responseBuffer, errBuffer); 13 | errBuffer.raiseError(result); 14 | return Keys.GenerateKeyResponse.parseFrom(bufferToByteArray(responseBuffer)); 15 | } 16 | 17 | public static Keys.ResolveResponse resolve(Keys.ResolveRequest request) 18 | throws DidException, InvalidProtocolBufferException { 19 | OkapiByteBuffer.ByValue requestBuffer = messageToBuffer(request); 20 | OkapiByteBuffer responseBuffer = new OkapiByteBuffer(); 21 | ExternError errBuffer = new ExternError(); 22 | var result = getNativeLibrary().didkey_resolve(requestBuffer, responseBuffer, errBuffer); 23 | errBuffer.raiseError(result); 24 | return Keys.ResolveResponse.parseFrom(bufferToByteArray(responseBuffer)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/ExternError.java: -------------------------------------------------------------------------------- 1 | package trinsic.okapi; 2 | 3 | import com.sun.jna.Pointer; 4 | import com.sun.jna.Structure; 5 | import com.sun.jna.Structure.FieldOrder; 6 | 7 | @FieldOrder({"code", "message"}) 8 | public class ExternError extends Structure { 9 | public int code; 10 | public Pointer message; 11 | 12 | public void raiseError(int errorCode) throws DidException { 13 | if (errorCode == 0 && this.code == 0) return; 14 | 15 | // Create the string, then dump the backing store. 16 | var messageString = this.message.getString(0, "UTF-8"); 17 | OkapiNative.getNativeLibrary().okapi_string_free(this.message); 18 | throw new DidException(this.code, "return code=" + errorCode + " message: " + messageString); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/LdProofs.java: -------------------------------------------------------------------------------- 1 | package trinsic.okapi; 2 | 3 | import com.google.protobuf.InvalidProtocolBufferException; 4 | import trinsic.okapi.proofs.v1.Proofs; 5 | 6 | public class LdProofs extends OkapiNative { 7 | public static Proofs.CreateProofResponse createProof(Proofs.CreateProofRequest request) 8 | throws DidException, InvalidProtocolBufferException { 9 | OkapiByteBuffer.ByValue requestBuffer = messageToBuffer(request); 10 | OkapiByteBuffer responseBuffer = new OkapiByteBuffer(); 11 | ExternError errBuffer = new ExternError(); 12 | var result = getNativeLibrary().ldproofs_create_proof(requestBuffer, responseBuffer, errBuffer); 13 | errBuffer.raiseError(result); 14 | return Proofs.CreateProofResponse.parseFrom(bufferToByteArray(responseBuffer)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/OkapiByteBuffer.java: -------------------------------------------------------------------------------- 1 | package trinsic.okapi; 2 | 3 | import com.sun.jna.Memory; 4 | import com.sun.jna.Pointer; 5 | import com.sun.jna.Structure; 6 | import com.sun.jna.Structure.FieldOrder; 7 | 8 | @FieldOrder({"len", "data"}) 9 | public class OkapiByteBuffer extends Structure { 10 | public static class ByValue extends OkapiByteBuffer implements Structure.ByValue {} 11 | 12 | public long len; 13 | public Pointer data; 14 | 15 | public void setData(byte[] toByteArray) { 16 | this.len = toByteArray.length; 17 | if (this.len == 0) return; 18 | this.data = new Memory(this.len); 19 | this.data.write(0, toByteArray, 0, toByteArray.length); 20 | } 21 | 22 | public byte[] getData() { 23 | byte[] returnData = new byte[(int) this.len]; 24 | this.data.read(0, returnData, 0, returnData.length); 25 | return returnData; 26 | } 27 | 28 | public ByValue byValue() { 29 | ByValue byvalueStruct = new OkapiByteBuffer.ByValue(); 30 | byvalueStruct.len = this.len; 31 | byvalueStruct.data = this.data; 32 | return byvalueStruct; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/OkapiMetadata.java: -------------------------------------------------------------------------------- 1 | package trinsic.okapi; 2 | 3 | import com.google.protobuf.InvalidProtocolBufferException; 4 | import trinsic.okapi.metadata.Metadata; 5 | 6 | public class OkapiMetadata extends OkapiNative { 7 | public static Metadata.MetadataResponse getMetadata() 8 | throws DidException, InvalidProtocolBufferException { 9 | var request = Metadata.MetadataRequest.getDefaultInstance(); 10 | OkapiByteBuffer.ByValue requestBuffer = messageToBuffer(request); 11 | OkapiByteBuffer responseBuffer = new OkapiByteBuffer(); 12 | ExternError errBuffer = new ExternError(); 13 | var result = getNativeLibrary().oberon_create_key(requestBuffer, responseBuffer, errBuffer); 14 | errBuffer.raiseError(result); 15 | return Metadata.MetadataResponse.parseFrom(bufferToByteArray(responseBuffer)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/examples/v1/BasicMessageKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/examples/v1/examples.proto 3 | 4 | package trinsic.okapi.examples.v1 5 | 6 | @kotlin.jvm.JvmName("-initializebasicMessage") 7 | public inline fun basicMessage( 8 | block: trinsic.okapi.examples.v1.BasicMessageKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.examples.v1.Examples.BasicMessage = 10 | trinsic.okapi.examples.v1.BasicMessageKt.Dsl._create( 11 | trinsic.okapi.examples.v1.Examples.BasicMessage.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object BasicMessageKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.examples.v1.Examples.BasicMessage.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create(builder: trinsic.okapi.examples.v1.Examples.BasicMessage.Builder): Dsl = 26 | Dsl(builder) 27 | } 28 | 29 | @kotlin.jvm.JvmSynthetic 30 | @kotlin.PublishedApi 31 | internal fun _build(): trinsic.okapi.examples.v1.Examples.BasicMessage = _builder.build() 32 | 33 | /** string text = 1; */ 34 | public var text: kotlin.String 35 | @JvmName("getText") get() = _builder.getText() 36 | @JvmName("setText") 37 | set(value) { 38 | _builder.setText(value) 39 | } 40 | /** string text = 1; */ 41 | public fun clearText() { 42 | _builder.clearText() 43 | } 44 | } 45 | } 46 | 47 | @kotlin.jvm.JvmSynthetic 48 | public inline fun trinsic.okapi.examples.v1.Examples.BasicMessage.copy( 49 | block: trinsic.okapi.examples.v1.BasicMessageKt.Dsl.() -> kotlin.Unit 50 | ): trinsic.okapi.examples.v1.Examples.BasicMessage = 51 | trinsic.okapi.examples.v1.BasicMessageKt.Dsl._create(this.toBuilder()) 52 | .apply { block() } 53 | ._build() 54 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/examples/v1/ExamplesKt.kt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/hashing/v1/Blake3DeriveKeyResponseKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/hashing/v1/hashing.proto 3 | 4 | package trinsic.okapi.hashing.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeblake3DeriveKeyResponse") 7 | public inline fun blake3DeriveKeyResponse( 8 | block: trinsic.okapi.hashing.v1.Blake3DeriveKeyResponseKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.hashing.v1.Hashing.Blake3DeriveKeyResponse = 10 | trinsic.okapi.hashing.v1.Blake3DeriveKeyResponseKt.Dsl._create( 11 | trinsic.okapi.hashing.v1.Hashing.Blake3DeriveKeyResponse.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object Blake3DeriveKeyResponseKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.hashing.v1.Hashing.Blake3DeriveKeyResponse.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.hashing.v1.Hashing.Blake3DeriveKeyResponse.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.hashing.v1.Hashing.Blake3DeriveKeyResponse = 33 | _builder.build() 34 | 35 | /** bytes digest = 1; */ 36 | public var digest: com.google.protobuf.ByteString 37 | @JvmName("getDigest") get() = _builder.getDigest() 38 | @JvmName("setDigest") 39 | set(value) { 40 | _builder.setDigest(value) 41 | } 42 | /** bytes digest = 1; */ 43 | public fun clearDigest() { 44 | _builder.clearDigest() 45 | } 46 | } 47 | } 48 | 49 | @kotlin.jvm.JvmSynthetic 50 | public inline fun trinsic.okapi.hashing.v1.Hashing.Blake3DeriveKeyResponse.copy( 51 | block: trinsic.okapi.hashing.v1.Blake3DeriveKeyResponseKt.Dsl.() -> kotlin.Unit 52 | ): trinsic.okapi.hashing.v1.Hashing.Blake3DeriveKeyResponse = 53 | trinsic.okapi.hashing.v1.Blake3DeriveKeyResponseKt.Dsl._create(this.toBuilder()) 54 | .apply { block() } 55 | ._build() 56 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/hashing/v1/Blake3HashRequestKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/hashing/v1/hashing.proto 3 | 4 | package trinsic.okapi.hashing.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeblake3HashRequest") 7 | public inline fun blake3HashRequest( 8 | block: trinsic.okapi.hashing.v1.Blake3HashRequestKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.hashing.v1.Hashing.Blake3HashRequest = 10 | trinsic.okapi.hashing.v1.Blake3HashRequestKt.Dsl._create( 11 | trinsic.okapi.hashing.v1.Hashing.Blake3HashRequest.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object Blake3HashRequestKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.hashing.v1.Hashing.Blake3HashRequest.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.hashing.v1.Hashing.Blake3HashRequest.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.hashing.v1.Hashing.Blake3HashRequest = _builder.build() 33 | 34 | /** bytes data = 1; */ 35 | public var data: com.google.protobuf.ByteString 36 | @JvmName("getData") get() = _builder.getData() 37 | @JvmName("setData") 38 | set(value) { 39 | _builder.setData(value) 40 | } 41 | /** bytes data = 1; */ 42 | public fun clearData() { 43 | _builder.clearData() 44 | } 45 | } 46 | } 47 | 48 | @kotlin.jvm.JvmSynthetic 49 | public inline fun trinsic.okapi.hashing.v1.Hashing.Blake3HashRequest.copy( 50 | block: trinsic.okapi.hashing.v1.Blake3HashRequestKt.Dsl.() -> kotlin.Unit 51 | ): trinsic.okapi.hashing.v1.Hashing.Blake3HashRequest = 52 | trinsic.okapi.hashing.v1.Blake3HashRequestKt.Dsl._create(this.toBuilder()) 53 | .apply { block() } 54 | ._build() 55 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/hashing/v1/Blake3HashResponseKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/hashing/v1/hashing.proto 3 | 4 | package trinsic.okapi.hashing.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeblake3HashResponse") 7 | public inline fun blake3HashResponse( 8 | block: trinsic.okapi.hashing.v1.Blake3HashResponseKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.hashing.v1.Hashing.Blake3HashResponse = 10 | trinsic.okapi.hashing.v1.Blake3HashResponseKt.Dsl._create( 11 | trinsic.okapi.hashing.v1.Hashing.Blake3HashResponse.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object Blake3HashResponseKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.hashing.v1.Hashing.Blake3HashResponse.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.hashing.v1.Hashing.Blake3HashResponse.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.hashing.v1.Hashing.Blake3HashResponse = _builder.build() 33 | 34 | /** bytes digest = 1; */ 35 | public var digest: com.google.protobuf.ByteString 36 | @JvmName("getDigest") get() = _builder.getDigest() 37 | @JvmName("setDigest") 38 | set(value) { 39 | _builder.setDigest(value) 40 | } 41 | /** bytes digest = 1; */ 42 | public fun clearDigest() { 43 | _builder.clearDigest() 44 | } 45 | } 46 | } 47 | 48 | @kotlin.jvm.JvmSynthetic 49 | public inline fun trinsic.okapi.hashing.v1.Hashing.Blake3HashResponse.copy( 50 | block: trinsic.okapi.hashing.v1.Blake3HashResponseKt.Dsl.() -> kotlin.Unit 51 | ): trinsic.okapi.hashing.v1.Hashing.Blake3HashResponse = 52 | trinsic.okapi.hashing.v1.Blake3HashResponseKt.Dsl._create(this.toBuilder()) 53 | .apply { block() } 54 | ._build() 55 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/hashing/v1/Blake3KeyedHashResponseKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/hashing/v1/hashing.proto 3 | 4 | package trinsic.okapi.hashing.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeblake3KeyedHashResponse") 7 | public inline fun blake3KeyedHashResponse( 8 | block: trinsic.okapi.hashing.v1.Blake3KeyedHashResponseKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.hashing.v1.Hashing.Blake3KeyedHashResponse = 10 | trinsic.okapi.hashing.v1.Blake3KeyedHashResponseKt.Dsl._create( 11 | trinsic.okapi.hashing.v1.Hashing.Blake3KeyedHashResponse.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object Blake3KeyedHashResponseKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.hashing.v1.Hashing.Blake3KeyedHashResponse.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.hashing.v1.Hashing.Blake3KeyedHashResponse.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.hashing.v1.Hashing.Blake3KeyedHashResponse = 33 | _builder.build() 34 | 35 | /** bytes digest = 1; */ 36 | public var digest: com.google.protobuf.ByteString 37 | @JvmName("getDigest") get() = _builder.getDigest() 38 | @JvmName("setDigest") 39 | set(value) { 40 | _builder.setDigest(value) 41 | } 42 | /** bytes digest = 1; */ 43 | public fun clearDigest() { 44 | _builder.clearDigest() 45 | } 46 | } 47 | } 48 | 49 | @kotlin.jvm.JvmSynthetic 50 | public inline fun trinsic.okapi.hashing.v1.Hashing.Blake3KeyedHashResponse.copy( 51 | block: trinsic.okapi.hashing.v1.Blake3KeyedHashResponseKt.Dsl.() -> kotlin.Unit 52 | ): trinsic.okapi.hashing.v1.Hashing.Blake3KeyedHashResponse = 53 | trinsic.okapi.hashing.v1.Blake3KeyedHashResponseKt.Dsl._create(this.toBuilder()) 54 | .apply { block() } 55 | ._build() 56 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/hashing/v1/HashingKt.kt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/hashing/v1/SHA256HashRequestKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/hashing/v1/hashing.proto 3 | 4 | package trinsic.okapi.hashing.v1 5 | 6 | @kotlin.jvm.JvmName("-initializesHA256HashRequest") 7 | public inline fun sHA256HashRequest( 8 | block: trinsic.okapi.hashing.v1.SHA256HashRequestKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.hashing.v1.Hashing.SHA256HashRequest = 10 | trinsic.okapi.hashing.v1.SHA256HashRequestKt.Dsl._create( 11 | trinsic.okapi.hashing.v1.Hashing.SHA256HashRequest.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object SHA256HashRequestKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.hashing.v1.Hashing.SHA256HashRequest.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.hashing.v1.Hashing.SHA256HashRequest.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.hashing.v1.Hashing.SHA256HashRequest = _builder.build() 33 | 34 | /** bytes data = 1; */ 35 | public var data: com.google.protobuf.ByteString 36 | @JvmName("getData") get() = _builder.getData() 37 | @JvmName("setData") 38 | set(value) { 39 | _builder.setData(value) 40 | } 41 | /** bytes data = 1; */ 42 | public fun clearData() { 43 | _builder.clearData() 44 | } 45 | } 46 | } 47 | 48 | @kotlin.jvm.JvmSynthetic 49 | public inline fun trinsic.okapi.hashing.v1.Hashing.SHA256HashRequest.copy( 50 | block: trinsic.okapi.hashing.v1.SHA256HashRequestKt.Dsl.() -> kotlin.Unit 51 | ): trinsic.okapi.hashing.v1.Hashing.SHA256HashRequest = 52 | trinsic.okapi.hashing.v1.SHA256HashRequestKt.Dsl._create(this.toBuilder()) 53 | .apply { block() } 54 | ._build() 55 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/hashing/v1/SHA256HashResponseKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/hashing/v1/hashing.proto 3 | 4 | package trinsic.okapi.hashing.v1 5 | 6 | @kotlin.jvm.JvmName("-initializesHA256HashResponse") 7 | public inline fun sHA256HashResponse( 8 | block: trinsic.okapi.hashing.v1.SHA256HashResponseKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.hashing.v1.Hashing.SHA256HashResponse = 10 | trinsic.okapi.hashing.v1.SHA256HashResponseKt.Dsl._create( 11 | trinsic.okapi.hashing.v1.Hashing.SHA256HashResponse.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object SHA256HashResponseKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.hashing.v1.Hashing.SHA256HashResponse.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.hashing.v1.Hashing.SHA256HashResponse.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.hashing.v1.Hashing.SHA256HashResponse = _builder.build() 33 | 34 | /** bytes digest = 1; */ 35 | public var digest: com.google.protobuf.ByteString 36 | @JvmName("getDigest") get() = _builder.getDigest() 37 | @JvmName("setDigest") 38 | set(value) { 39 | _builder.setDigest(value) 40 | } 41 | /** bytes digest = 1; */ 42 | public fun clearDigest() { 43 | _builder.clearDigest() 44 | } 45 | } 46 | } 47 | 48 | @kotlin.jvm.JvmSynthetic 49 | public inline fun trinsic.okapi.hashing.v1.Hashing.SHA256HashResponse.copy( 50 | block: trinsic.okapi.hashing.v1.SHA256HashResponseKt.Dsl.() -> kotlin.Unit 51 | ): trinsic.okapi.hashing.v1.Hashing.SHA256HashResponse = 52 | trinsic.okapi.hashing.v1.SHA256HashResponseKt.Dsl._create(this.toBuilder()) 53 | .apply { block() } 54 | ._build() 55 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/keys/v1/KeysKt.kt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/keys/v1/ResolveRequestKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/keys/v1/keys.proto 3 | 4 | package trinsic.okapi.keys.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeresolveRequest") 7 | public inline fun resolveRequest( 8 | block: trinsic.okapi.keys.v1.ResolveRequestKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.keys.v1.Keys.ResolveRequest = 10 | trinsic.okapi.keys.v1.ResolveRequestKt.Dsl._create( 11 | trinsic.okapi.keys.v1.Keys.ResolveRequest.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object ResolveRequestKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor(private val _builder: trinsic.okapi.keys.v1.Keys.ResolveRequest.Builder) { 20 | public companion object { 21 | @kotlin.jvm.JvmSynthetic 22 | @kotlin.PublishedApi 23 | internal fun _create(builder: trinsic.okapi.keys.v1.Keys.ResolveRequest.Builder): Dsl = 24 | Dsl(builder) 25 | } 26 | 27 | @kotlin.jvm.JvmSynthetic 28 | @kotlin.PublishedApi 29 | internal fun _build(): trinsic.okapi.keys.v1.Keys.ResolveRequest = _builder.build() 30 | 31 | /** string did = 1; */ 32 | public var did: kotlin.String 33 | @JvmName("getDid") get() = _builder.getDid() 34 | @JvmName("setDid") 35 | set(value) { 36 | _builder.setDid(value) 37 | } 38 | /** string did = 1; */ 39 | public fun clearDid() { 40 | _builder.clearDid() 41 | } 42 | } 43 | } 44 | 45 | @kotlin.jvm.JvmSynthetic 46 | public inline fun trinsic.okapi.keys.v1.Keys.ResolveRequest.copy( 47 | block: trinsic.okapi.keys.v1.ResolveRequestKt.Dsl.() -> kotlin.Unit 48 | ): trinsic.okapi.keys.v1.Keys.ResolveRequest = 49 | trinsic.okapi.keys.v1.ResolveRequestKt.Dsl._create(this.toBuilder()).apply { block() }._build() 50 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/metadata/MetadataKt.kt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/metadata/MetadataRequestKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/metadata/metadata.proto 3 | 4 | package trinsic.okapi.metadata 5 | 6 | @kotlin.jvm.JvmName("-initializemetadataRequest") 7 | public inline fun metadataRequest( 8 | block: trinsic.okapi.metadata.MetadataRequestKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.metadata.Metadata.MetadataRequest = 10 | trinsic.okapi.metadata.MetadataRequestKt.Dsl._create( 11 | trinsic.okapi.metadata.Metadata.MetadataRequest.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object MetadataRequestKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.metadata.Metadata.MetadataRequest.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create(builder: trinsic.okapi.metadata.Metadata.MetadataRequest.Builder): Dsl = 26 | Dsl(builder) 27 | } 28 | 29 | @kotlin.jvm.JvmSynthetic 30 | @kotlin.PublishedApi 31 | internal fun _build(): trinsic.okapi.metadata.Metadata.MetadataRequest = _builder.build() 32 | } 33 | } 34 | 35 | @kotlin.jvm.JvmSynthetic 36 | public inline fun trinsic.okapi.metadata.Metadata.MetadataRequest.copy( 37 | block: trinsic.okapi.metadata.MetadataRequestKt.Dsl.() -> kotlin.Unit 38 | ): trinsic.okapi.metadata.Metadata.MetadataRequest = 39 | trinsic.okapi.metadata.MetadataRequestKt.Dsl._create(this.toBuilder()) 40 | .apply { block() } 41 | ._build() 42 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/pbmse/v1/PbmseKt.kt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/pbmse/v1/SignatureKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: pbmse/v1/pbmse.proto 3 | 4 | package trinsic.okapi.pbmse.v1 5 | 6 | @kotlin.jvm.JvmName("-initializesignature") 7 | public inline fun signature( 8 | block: trinsic.okapi.pbmse.v1.SignatureKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.pbmse.v1.Pbmse.Signature = 10 | trinsic.okapi.pbmse.v1.SignatureKt.Dsl._create( 11 | trinsic.okapi.pbmse.v1.Pbmse.Signature.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object SignatureKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor(private val _builder: trinsic.okapi.pbmse.v1.Pbmse.Signature.Builder) { 20 | public companion object { 21 | @kotlin.jvm.JvmSynthetic 22 | @kotlin.PublishedApi 23 | internal fun _create(builder: trinsic.okapi.pbmse.v1.Pbmse.Signature.Builder): Dsl = 24 | Dsl(builder) 25 | } 26 | 27 | @kotlin.jvm.JvmSynthetic 28 | @kotlin.PublishedApi 29 | internal fun _build(): trinsic.okapi.pbmse.v1.Pbmse.Signature = _builder.build() 30 | 31 | /** bytes header = 1; */ 32 | public var header: com.google.protobuf.ByteString 33 | @JvmName("getHeader") get() = _builder.getHeader() 34 | @JvmName("setHeader") 35 | set(value) { 36 | _builder.setHeader(value) 37 | } 38 | /** bytes header = 1; */ 39 | public fun clearHeader() { 40 | _builder.clearHeader() 41 | } 42 | 43 | /** bytes signature = 3; */ 44 | public var signature: com.google.protobuf.ByteString 45 | @JvmName("getSignature") get() = _builder.getSignature() 46 | @JvmName("setSignature") 47 | set(value) { 48 | _builder.setSignature(value) 49 | } 50 | /** bytes signature = 3; */ 51 | public fun clearSignature() { 52 | _builder.clearSignature() 53 | } 54 | } 55 | } 56 | 57 | @kotlin.jvm.JvmSynthetic 58 | public inline fun trinsic.okapi.pbmse.v1.Pbmse.Signature.copy( 59 | block: trinsic.okapi.pbmse.v1.SignatureKt.Dsl.() -> kotlin.Unit 60 | ): trinsic.okapi.pbmse.v1.Pbmse.Signature = 61 | trinsic.okapi.pbmse.v1.SignatureKt.Dsl._create(this.toBuilder()).apply { block() }._build() 62 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/proofs/v1/ProofsKt.kt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/proofs/v1/VerifyProofRequestKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/proofs/v1/proofs.proto 3 | 4 | package trinsic.okapi.proofs.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeverifyProofRequest") 7 | public inline fun verifyProofRequest( 8 | block: trinsic.okapi.proofs.v1.VerifyProofRequestKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.proofs.v1.Proofs.VerifyProofRequest = 10 | trinsic.okapi.proofs.v1.VerifyProofRequestKt.Dsl._create( 11 | trinsic.okapi.proofs.v1.Proofs.VerifyProofRequest.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object VerifyProofRequestKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.proofs.v1.Proofs.VerifyProofRequest.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.proofs.v1.Proofs.VerifyProofRequest.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.proofs.v1.Proofs.VerifyProofRequest = _builder.build() 33 | } 34 | } 35 | 36 | @kotlin.jvm.JvmSynthetic 37 | public inline fun trinsic.okapi.proofs.v1.Proofs.VerifyProofRequest.copy( 38 | block: trinsic.okapi.proofs.v1.VerifyProofRequestKt.Dsl.() -> kotlin.Unit 39 | ): trinsic.okapi.proofs.v1.Proofs.VerifyProofRequest = 40 | trinsic.okapi.proofs.v1.VerifyProofRequestKt.Dsl._create(this.toBuilder()) 41 | .apply { block() } 42 | ._build() 43 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/proofs/v1/VerifyProofResponseKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/proofs/v1/proofs.proto 3 | 4 | package trinsic.okapi.proofs.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeverifyProofResponse") 7 | public inline fun verifyProofResponse( 8 | block: trinsic.okapi.proofs.v1.VerifyProofResponseKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.proofs.v1.Proofs.VerifyProofResponse = 10 | trinsic.okapi.proofs.v1.VerifyProofResponseKt.Dsl._create( 11 | trinsic.okapi.proofs.v1.Proofs.VerifyProofResponse.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object VerifyProofResponseKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.proofs.v1.Proofs.VerifyProofResponse.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.proofs.v1.Proofs.VerifyProofResponse.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.proofs.v1.Proofs.VerifyProofResponse = _builder.build() 33 | } 34 | } 35 | 36 | @kotlin.jvm.JvmSynthetic 37 | public inline fun trinsic.okapi.proofs.v1.Proofs.VerifyProofResponse.copy( 38 | block: trinsic.okapi.proofs.v1.VerifyProofResponseKt.Dsl.() -> kotlin.Unit 39 | ): trinsic.okapi.proofs.v1.Proofs.VerifyProofResponse = 40 | trinsic.okapi.proofs.v1.VerifyProofResponseKt.Dsl._create(this.toBuilder()) 41 | .apply { block() } 42 | ._build() 43 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/security/v1/SecurityKt.kt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/transport/v1/TransportKt.kt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/transport/v1/UnpackResponseKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/transport/v1/transport.proto 3 | 4 | package trinsic.okapi.transport.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeunpackResponse") 7 | public inline fun unpackResponse( 8 | block: trinsic.okapi.transport.v1.UnpackResponseKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.transport.v1.Transport.UnpackResponse = 10 | trinsic.okapi.transport.v1.UnpackResponseKt.Dsl._create( 11 | trinsic.okapi.transport.v1.Transport.UnpackResponse.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object UnpackResponseKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.transport.v1.Transport.UnpackResponse.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.transport.v1.Transport.UnpackResponse.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.transport.v1.Transport.UnpackResponse = _builder.build() 33 | 34 | /** bytes plaintext = 1; */ 35 | public var plaintext: com.google.protobuf.ByteString 36 | @JvmName("getPlaintext") get() = _builder.getPlaintext() 37 | @JvmName("setPlaintext") 38 | set(value) { 39 | _builder.setPlaintext(value) 40 | } 41 | /** bytes plaintext = 1; */ 42 | public fun clearPlaintext() { 43 | _builder.clearPlaintext() 44 | } 45 | } 46 | } 47 | 48 | @kotlin.jvm.JvmSynthetic 49 | public inline fun trinsic.okapi.transport.v1.Transport.UnpackResponse.copy( 50 | block: trinsic.okapi.transport.v1.UnpackResponseKt.Dsl.() -> kotlin.Unit 51 | ): trinsic.okapi.transport.v1.Transport.UnpackResponse = 52 | trinsic.okapi.transport.v1.UnpackResponseKt.Dsl._create(this.toBuilder()) 53 | .apply { block() } 54 | ._build() 55 | -------------------------------------------------------------------------------- /java/src/main/java/trinsic/okapi/transport/v1/VerifyResponseKt.kt: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: okapi/transport/v1/transport.proto 3 | 4 | package trinsic.okapi.transport.v1 5 | 6 | @kotlin.jvm.JvmName("-initializeverifyResponse") 7 | public inline fun verifyResponse( 8 | block: trinsic.okapi.transport.v1.VerifyResponseKt.Dsl.() -> kotlin.Unit 9 | ): trinsic.okapi.transport.v1.Transport.VerifyResponse = 10 | trinsic.okapi.transport.v1.VerifyResponseKt.Dsl._create( 11 | trinsic.okapi.transport.v1.Transport.VerifyResponse.newBuilder()) 12 | .apply { block() } 13 | ._build() 14 | 15 | public object VerifyResponseKt { 16 | @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) 17 | @com.google.protobuf.kotlin.ProtoDslMarker 18 | public class Dsl 19 | private constructor( 20 | private val _builder: trinsic.okapi.transport.v1.Transport.VerifyResponse.Builder 21 | ) { 22 | public companion object { 23 | @kotlin.jvm.JvmSynthetic 24 | @kotlin.PublishedApi 25 | internal fun _create( 26 | builder: trinsic.okapi.transport.v1.Transport.VerifyResponse.Builder 27 | ): Dsl = Dsl(builder) 28 | } 29 | 30 | @kotlin.jvm.JvmSynthetic 31 | @kotlin.PublishedApi 32 | internal fun _build(): trinsic.okapi.transport.v1.Transport.VerifyResponse = _builder.build() 33 | 34 | /** bool is_valid = 1; */ 35 | public var isValid: kotlin.Boolean 36 | @JvmName("getIsValid") get() = _builder.getIsValid() 37 | @JvmName("setIsValid") 38 | set(value) { 39 | _builder.setIsValid(value) 40 | } 41 | /** bool is_valid = 1; */ 42 | public fun clearIsValid() { 43 | _builder.clearIsValid() 44 | } 45 | } 46 | } 47 | 48 | @kotlin.jvm.JvmSynthetic 49 | public inline fun trinsic.okapi.transport.v1.Transport.VerifyResponse.copy( 50 | block: trinsic.okapi.transport.v1.VerifyResponseKt.Dsl.() -> kotlin.Unit 51 | ): trinsic.okapi.transport.v1.Transport.VerifyResponse = 52 | trinsic.okapi.transport.v1.VerifyResponseKt.Dsl._create(this.toBuilder()) 53 | .apply { block() } 54 | ._build() 55 | -------------------------------------------------------------------------------- /java/src/test/java/Hex.java: -------------------------------------------------------------------------------- 1 | public class Hex { 2 | // Source: 3 | // https://stackoverflow.com/questions/9655181/how-to-convert-a-byte-array-to-a-hex-string-in-java 4 | /* s must be an even-length string. */ 5 | public static byte[] hexStringToByteArray(String s) { 6 | int len = s.length(); 7 | byte[] data = new byte[len / 2]; 8 | for (int i = 0; i < len; i += 2) { 9 | data[i / 2] = 10 | (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); 11 | } 12 | return data; 13 | } 14 | 15 | private static final char[] HEX_ARRAY = "0123456789abcdef".toCharArray(); 16 | 17 | public static String bytesToHex(byte[] bytes) { 18 | char[] hexChars = new char[bytes.length * 2]; 19 | for (int j = 0; j < bytes.length; j++) { 20 | int v = bytes[j] & 0xFF; 21 | hexChars[j * 2] = HEX_ARRAY[v >>> 4]; 22 | hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; 23 | } 24 | return new String(hexChars); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java/src/test/java/LdProofTest.java: -------------------------------------------------------------------------------- 1 | import com.google.protobuf.InvalidProtocolBufferException; 2 | import com.google.protobuf.Struct; 3 | import com.google.protobuf.Value; 4 | import java.time.Instant; 5 | import java.util.HashMap; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import trinsic.okapi.DidException; 9 | import trinsic.okapi.DidKey; 10 | import trinsic.okapi.LdProofs; 11 | import trinsic.okapi.keys.v1.Keys; 12 | import trinsic.okapi.proofs.v1.Proofs; 13 | 14 | public class LdProofTest { 15 | private static Value stringValue(String s) { 16 | return Value.newBuilder().setStringValue(s).build(); 17 | } 18 | 19 | @Test 20 | public void testGenerateCapabilityInvocationProofWithJcs() 21 | throws InvalidProtocolBufferException, DidException { 22 | var proofDict = new HashMap(); 23 | proofDict.put("created", stringValue(Instant.now().toString())); 24 | var proofStruct = Struct.newBuilder().putAllFields(proofDict).build(); 25 | var proofValue = Value.newBuilder().setStructValue(proofStruct).build(); 26 | 27 | var capabilityDict = new HashMap(); 28 | capabilityDict.put("@context", stringValue("https://w3id.org/security/v2")); 29 | capabilityDict.put("target", stringValue("urn:trinsic:wallets:noop")); 30 | capabilityDict.put("proof", proofValue); 31 | 32 | var capability = Struct.newBuilder().putAllFields(capabilityDict).build(); 33 | System.out.println(capability); 34 | 35 | var request = 36 | Keys.GenerateKeyRequest.newBuilder().setKeyType(Keys.KeyType.KEY_TYPE_ED25519).build(); 37 | var response = DidKey.generate(request); 38 | var signingKey = 39 | response.getKeyList().stream() 40 | .takeWhile(jsonWebKey -> jsonWebKey.getCrv().equals("Ed25519")) 41 | .findFirst() 42 | .get(); 43 | 44 | var proofRequest = 45 | Proofs.CreateProofRequest.newBuilder() 46 | .setDocument(capability) 47 | .setKey(signingKey) 48 | .setSuite(Proofs.LdSuite.LD_SUITE_JCSED25519SIGNATURE2020) 49 | .build(); 50 | var signedCapability = LdProofs.createProof(proofRequest); 51 | 52 | Assertions.assertNotNull(signedCapability); 53 | Assertions.assertNotNull(signedCapability.getSignedDocument()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /libs/README.md: -------------------------------------------------------------------------------- 1 | # Static Libraries 2 | 3 | To download the latest libraries, run the PowerShell script `Initialize.ps1` in the root of the repo 4 | 5 | ```ps 6 | ./Initialize.ps1 7 | ``` -------------------------------------------------------------------------------- /native/.cargo/_config.toml: -------------------------------------------------------------------------------- 1 | [source.crates-io] 2 | replace-with = "vendored-sources" 3 | 4 | [source.vendored-sources] 5 | directory = "vendor" 6 | -------------------------------------------------------------------------------- /native/.cargo/config: -------------------------------------------------------------------------------- 1 | [target.armv7-unknown-linux-gnueabihf] 2 | linker = "arm-linux-gnueabihf-gcc" 3 | 4 | [target.aarch64-unknown-linux-gnu] 5 | linker = "aarch64-linux-gnu-gcc" -------------------------------------------------------------------------------- /native/.gitignore: -------------------------------------------------------------------------------- 1 | vendor -------------------------------------------------------------------------------- /native/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "okapi" 3 | version = "0.1.0" 4 | authors = ["Tomislav Markovski ", "Scott Phillips "] 5 | edition = "2018" 6 | # ensure this is not checked in as "true" as it will 7 | # cause vendored libraries to fail compilation due 8 | # to dependency on protoc compiler 9 | # if you need to compile .proto files, use this line: 10 | #build = "build.rs" 11 | build = false 12 | 13 | [package.metadata.deb] 14 | maintainer = "Tomislav Markovski " 15 | copyright = "2021-2022, Trinsic " 16 | license-file = ["../LICENSE", "4"] 17 | extended-description = """\ 18 | Collection of tools that support workflows for \ 19 | authentic data and identity management.""" 20 | depends = "$auto" 21 | section = "utility" 22 | priority = "optional" 23 | assets = [ 24 | ["target/release/libokapi.so", "usr/local/lib/", "644"], 25 | ["target/release/libokapi.a", "usr/local/lib/", "644"], 26 | ["../include/okapi.h", "usr/local/include/", "644"], 27 | ] 28 | 29 | [dependencies] 30 | chacha20poly1305 = "0.10.1" 31 | ffi-support = "0.4" 32 | prost = "0.11" 33 | prost-types = "0.11.1" 34 | base64 = "0.13.0" 35 | hex = "0.4.3" 36 | getrandom = { version = "0.2.7", features = ["js"] } 37 | regex = "1" 38 | did-key = "0.1" 39 | serde = "1.0" 40 | serde_json = "1.0" 41 | serde_jcs = "0.1" 42 | sha2 = { version = "0.10.2", default-features = false } 43 | blake3 = "1.3.1" 44 | bs58 = "0.4" 45 | oberon = "1.1.1" 46 | rand = "0.8" 47 | subtle = "2.4" 48 | 49 | [lib] 50 | name = "okapi" 51 | crate-type = [ "lib", "cdylib", "staticlib" ] 52 | 53 | [features] 54 | default = ["ffi", "hashing"] 55 | ffi = [] 56 | hashing = [] 57 | 58 | [build-dependencies] 59 | prost-build = "0.11.1" 60 | cbindgen = "0.24.3" 61 | 62 | [dev-dependencies] 63 | fluid = "0.4" 64 | wasm-bindgen-test = "0.3.32" 65 | -------------------------------------------------------------------------------- /native/README.md: -------------------------------------------------------------------------------- 1 | ## Requirements 2 | 3 | - [protoc](https://grpc.io/docs/protoc-installation/) - Protocol Buffer compiler 4 | - [rustup](https://www.rust-lang.org/tools/install) - Rust toolchain 5 | - [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) - Rust WebAssembly tool (only required to build WASM library) 6 | - [cargo-lipo](https://github.com/TimNN/cargo-lipo) - `cargo` subcommand for creating universal libraries for iOS (only required to build iOS library) 7 | - Install using `cargo install cargo-lipo` 8 | 9 | ### Build for iOS 10 | 11 | 1. Add required Rust targets 12 | ``` 13 | rustup target add aarch64-apple-ios x86_64-apple-ios 14 | ``` 15 | 16 | 2. Compile to universal library (will output at `target/universal/release/didcommgrpc.a`) 17 | ``` 18 | cargo lipo --release 19 | ``` 20 | 21 | ### Build for WASM (node) 22 | 23 | ``` 24 | wasm-pack build --target nodejs --out-dir ../wasm/packages/didcomm-grpc-node/src 25 | ``` 26 | 27 | ## Testing 28 | 29 | ``` 30 | cargo test 31 | ``` -------------------------------------------------------------------------------- /native/rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 160 -------------------------------------------------------------------------------- /native/src/didcomm/aesgcm.rs: -------------------------------------------------------------------------------- 1 | #[allow(dead_code)] 2 | struct AesGcm; 3 | -------------------------------------------------------------------------------- /native/src/didcomm/xchacha.rs: -------------------------------------------------------------------------------- 1 | use super::{AeadSuite, EncryptResult}; 2 | use chacha20poly1305::{aead::AeadInPlace, Key, KeyInit, XChaCha20Poly1305, XNonce}; 3 | 4 | pub struct XChaCha { 5 | aead: XChaCha20Poly1305, 6 | } 7 | 8 | impl From<&[u8; 32]> for XChaCha { 9 | fn from(key: &[u8; 32]) -> Self { 10 | XChaCha { 11 | aead: XChaCha20Poly1305::new(Key::from_slice(key)), 12 | } 13 | } 14 | } 15 | 16 | impl From<&Vec> for XChaCha { 17 | fn from(key: &Vec) -> Self { 18 | XChaCha { 19 | aead: XChaCha20Poly1305::new(Key::from_slice(key.as_slice())), 20 | } 21 | } 22 | } 23 | 24 | impl AeadSuite for XChaCha { 25 | type Err = String; 26 | 27 | fn encrypt(&self, nonce: &[u8], associated_data: &[u8], plaintext: &[u8]) -> Result { 28 | let mut payload = plaintext.to_vec(); 29 | let iv = XNonce::from_slice(&nonce); 30 | 31 | match self.aead.encrypt_in_place_detached(iv, associated_data, &mut payload) { 32 | Ok(tag) => Ok(EncryptResult { 33 | ciphertext: payload.to_vec(), 34 | tag: tag.to_vec(), 35 | }), 36 | Err(_) => Err("encryption failed".to_string()), 37 | } 38 | } 39 | 40 | fn decrypt(&self, nonce: &[u8], associated_data: &[u8], ciphertext: &[u8], tag: &[u8]) -> Result, Self::Err> { 41 | let mut payload = ciphertext.to_vec(); 42 | let iv = XNonce::from_slice(nonce); 43 | 44 | match self.aead.decrypt_in_place_detached(iv, associated_data, &mut payload, tag.into()) { 45 | Ok(_) => Ok(payload.to_vec()), 46 | Err(_) => Err("decryption failure".to_string()), 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /native/src/ffi/didcomm.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto::transport::*, *}; 2 | use ffi_support::{ByteBuffer, ExternError}; 3 | 4 | #[no_mangle] 5 | pub extern "C" fn didcomm_pack(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 6 | c_impl!(PackRequest, DIDComm, pack, request, response, err) 7 | } 8 | 9 | #[no_mangle] 10 | pub extern "C" fn didcomm_unpack(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 11 | c_impl!(UnpackRequest, DIDComm, unpack, request, response, err) 12 | } 13 | 14 | #[no_mangle] 15 | pub extern "C" fn didcomm_sign(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 16 | c_impl!(SignRequest, DIDComm, sign, request, response, err) 17 | } 18 | 19 | #[no_mangle] 20 | pub extern "C" fn didcomm_verify(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 21 | c_impl!(VerifyRequest, DIDComm, verify, request, response, err) 22 | } 23 | -------------------------------------------------------------------------------- /native/src/ffi/didkey.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto::keys::*, *}; 2 | use ffi_support::{ByteBuffer, ExternError}; 3 | 4 | #[no_mangle] 5 | pub extern "C" fn didkey_generate(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 6 | c_impl!(GenerateKeyRequest, DIDKey, generate, request, response, err) 7 | } 8 | 9 | #[no_mangle] 10 | pub extern "C" fn didkey_resolve(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 11 | c_impl!(ResolveRequest, DIDKey, resolve, request, response, err) 12 | } 13 | -------------------------------------------------------------------------------- /native/src/ffi/hashing.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto::hashing::*, *}; 2 | use ffi_support::{ByteBuffer, ExternError}; 3 | 4 | #[no_mangle] 5 | pub extern "C" fn blake3_hash(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 6 | c_impl!(Blake3HashRequest, Hashing, blake3_hash, request, response, err) 7 | } 8 | 9 | #[no_mangle] 10 | pub extern "C" fn blake3_keyed_hash(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 11 | c_impl!(Blake3HashRequest, Hashing, blake3_keyed_hash, request, response, err) 12 | } 13 | 14 | #[no_mangle] 15 | pub extern "C" fn blake3_derive_key(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 16 | c_impl!(Blake3DeriveKeyRequest, Hashing, blake3_derive_key, request, response, err) 17 | } 18 | 19 | #[no_mangle] 20 | pub extern "C" fn sha256_hash(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 21 | c_impl!(Sha256HashRequest, Hashing, sha256_hash, request, response, err) 22 | } 23 | -------------------------------------------------------------------------------- /native/src/ffi/ldproofs.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto::proofs::*, *}; 2 | use ffi_support::{ByteBuffer, ExternError}; 3 | 4 | #[no_mangle] 5 | pub extern "C" fn ldproofs_create_proof(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 6 | c_impl!(CreateProofRequest, LdProofs, create_proof, request, response, err) 7 | } 8 | -------------------------------------------------------------------------------- /native/src/ffi/metadata.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto::metadata::*, *}; 2 | use ffi_support::{ByteBuffer, ExternError}; 3 | 4 | #[no_mangle] 5 | pub extern "C" fn okapi_metadata(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 6 | c_impl!(MetadataRequest, Metadata, get_metadata, request, response, err) 7 | } 8 | -------------------------------------------------------------------------------- /native/src/ffi/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod didcomm; 2 | pub mod didkey; 3 | pub mod hashing; 4 | pub mod ldproofs; 5 | pub mod metadata; 6 | pub mod oberon; 7 | pub mod utils; 8 | -------------------------------------------------------------------------------- /native/src/ffi/oberon.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto::security::*, *}; 2 | use ffi_support::{ByteBuffer, ExternError}; 3 | 4 | #[no_mangle] 5 | pub extern "C" fn oberon_create_key(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 6 | c_impl!(CreateOberonKeyRequest, Oberon, key, request, response, err) 7 | } 8 | 9 | #[no_mangle] 10 | pub extern "C" fn oberon_create_token(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 11 | c_impl!(CreateOberonTokenRequest, Oberon, token, request, response, err) 12 | } 13 | 14 | #[no_mangle] 15 | pub extern "C" fn oberon_blind_token(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 16 | c_impl!(BlindOberonTokenRequest, Oberon, blind, request, response, err) 17 | } 18 | 19 | #[no_mangle] 20 | pub extern "C" fn oberon_unblind_token(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 21 | c_impl!(UnBlindOberonTokenRequest, Oberon, unblind, request, response, err) 22 | } 23 | 24 | #[no_mangle] 25 | pub extern "C" fn oberon_verify_token(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 26 | c_impl!(VerifyOberonTokenRequest, Oberon, verify_token, request, response, err) 27 | } 28 | 29 | #[no_mangle] 30 | pub extern "C" fn oberon_create_proof(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 31 | c_impl!(CreateOberonProofRequest, Oberon, proof, request, response, err) 32 | } 33 | 34 | #[no_mangle] 35 | pub extern "C" fn oberon_verify_proof(request: ByteBuffer, response: &mut ByteBuffer, err: &mut ExternError) -> i32 { 36 | c_impl!(VerifyOberonProofRequest, Oberon, verify, request, response, err) 37 | } 38 | -------------------------------------------------------------------------------- /native/src/ffi/utils.rs: -------------------------------------------------------------------------------- 1 | use ffi_support::ByteBuffer; 2 | use std::os::raw::c_char; 3 | 4 | // TODO: Cargo build doesn't expand these correctly with cbindgen, manually expanded below. 5 | // define_string_destructor!(didcomm_string_free2); 6 | // define_bytebuffer_destructor!(didcomm_byte_buffer_free2); 7 | 8 | #[no_mangle] 9 | #[deprecated] 10 | pub extern "C" fn didcomm_byte_buffer_free(v: ByteBuffer) { 11 | // Note: This should never happen, but in the case of a bug aborting 12 | // here is better than the badness that happens if we unwind across 13 | // the FFI boundary. 14 | ffi_support::abort_on_panic::with_abort_on_panic(|| v.destroy()) 15 | } 16 | 17 | #[no_mangle] 18 | #[deprecated] 19 | pub unsafe extern "C" fn didcomm_string_free(s: *mut c_char) { 20 | // Note: This should never happen, but in the case of a bug aborting 21 | // here is better than the badness that happens if we unwind across 22 | // the FFI boundary. 23 | ffi_support::abort_on_panic::with_abort_on_panic(|| { 24 | if !s.is_null() { 25 | ffi_support::destroy_c_string(s) 26 | } 27 | }); 28 | } 29 | 30 | #[no_mangle] 31 | pub extern "C" fn okapi_bytebuffer_free(v: ByteBuffer) { 32 | // Note: This should never happen, but in the case of a bug aborting 33 | // here is better than the badness that happens if we unwind across 34 | // the FFI boundary. 35 | ffi_support::abort_on_panic::with_abort_on_panic(|| v.destroy()) 36 | } 37 | 38 | #[no_mangle] 39 | pub unsafe extern "C" fn okapi_string_free(s: *mut c_char) { 40 | // Note: This should never happen, but in the case of a bug aborting 41 | // here is better than the badness that happens if we unwind across 42 | // the FFI boundary. 43 | ffi_support::abort_on_panic::with_abort_on_panic(|| { 44 | if !s.is_null() { 45 | ffi_support::destroy_c_string(s) 46 | } 47 | }); 48 | } 49 | -------------------------------------------------------------------------------- /native/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate core; 2 | extern crate ffi_support; 3 | 4 | use prost::{DecodeError, Message}; 5 | 6 | pub struct DIDComm {} 7 | pub struct DIDKey {} 8 | pub struct LdProofs {} 9 | pub struct Oberon {} 10 | pub struct Hashing {} 11 | pub struct Metadata {} 12 | 13 | #[allow(clippy::ptr_arg)] 14 | pub trait MessageFormatter { 15 | fn to_vec(&self) -> Vec; 16 | fn from_vec(data: &Vec) -> Result 17 | where 18 | T: Message + Default; 19 | } 20 | 21 | impl MessageFormatter for T 22 | where 23 | T: Message + Default, 24 | { 25 | fn to_vec(&self) -> Vec { 26 | let mut data = vec![]; 27 | data.reserve(self.encoded_len()); 28 | self.encode(&mut data).unwrap(); 29 | data 30 | } 31 | 32 | fn from_vec(data: &Vec) -> Result 33 | where 34 | U: Message + Default, 35 | { 36 | U::decode(data.as_slice()) 37 | } 38 | } 39 | 40 | #[macro_use] 41 | mod macros; 42 | pub mod didcomm; 43 | pub mod didkey; 44 | #[cfg(feature = "ffi")] 45 | mod ffi; 46 | #[cfg(feature = "hashing")] 47 | pub mod hashing; 48 | pub mod ldproofs; 49 | pub mod metadata; 50 | pub mod oberon; 51 | pub mod proto; 52 | #[cfg(test)] 53 | mod tests; 54 | 55 | pub mod google { 56 | pub mod protobuf { 57 | pub use crate::proto::google_protobuf::*; 58 | } 59 | } 60 | 61 | pub mod pbmse { 62 | pub mod v1 { 63 | pub use crate::proto::pbmse::*; 64 | } 65 | pub use crate::proto::pbmse::*; 66 | } 67 | -------------------------------------------------------------------------------- /native/src/macros.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! base58_decode { 3 | ($name:expr) => { 4 | ::bs58::decode($name).into_vec().expect("invalid base58 string") 5 | }; 6 | } 7 | 8 | macro_rules! unwrap_or_return { 9 | ($name:expr,$err:expr) => { 10 | match $name { 11 | Some(a) => a, 12 | None => return Err($err), 13 | } 14 | }; 15 | } 16 | 17 | #[allow(unused_macros)] 18 | macro_rules! c_impl { 19 | ($message:ty,$struct:ident,$func:ident,$req:expr,$res:expr,$err:expr) => {{ 20 | // do not use `destroy_into_vec()`, it causes crash from callers 21 | let request = match <$message>::from_vec(&$req.as_slice().to_vec()) { 22 | Ok(request) => request, 23 | Err(_) => { 24 | *$err = ExternError::new_error(::ffi_support::ErrorCode::new(100), "failed to decode request"); 25 | return 1; 26 | } 27 | }; 28 | 29 | match crate::$struct::$func(&request) { 30 | Ok(request) => { 31 | *$res = ByteBuffer::from_vec(request.to_vec()); 32 | *$err = ExternError::success(); 33 | return 0; 34 | } 35 | Err(_) => { 36 | *$err = ExternError::new_error(::ffi_support::ErrorCode::new(100), "failed to execute function"); 37 | return 1; 38 | } 39 | } 40 | }}; 41 | } 42 | 43 | macro_rules! map_or_return { 44 | ($name:expr,$err:expr) => { 45 | match $name { 46 | Ok(a) => a, 47 | Err(_) => return Err($err), 48 | } 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /native/src/metadata/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::didcomm::Error; 2 | use crate::proto::okapi::okapi_metadata::{MetadataRequest, MetadataResponse}; 3 | 4 | impl crate::Metadata { 5 | pub fn get_metadata<'a>(_request: &MetadataRequest) -> Result> { 6 | Ok(MetadataResponse { 7 | version: option_env!("CARGO_PKG_VERSION").unwrap_or_default().to_string(), 8 | version_major: option_env!("CARGO_PKG_VERSION_MAJOR").unwrap_or_default().parse().unwrap_or_default(), 9 | version_minor: option_env!("CARGO_PKG_VERSION_MINOR").unwrap_or_default().parse().unwrap_or_default(), 10 | version_patch: option_env!("CARGO_PKG_VERSION_PATCH").unwrap_or_default().parse().unwrap_or_default(), 11 | 12 | target_family: option_env!("CARGO_CFG_TARGET_FAMILY").unwrap_or_default().to_string(), 13 | target_os: option_env!("CARGO_CFG_TARGET_OS").unwrap_or_default().to_string(), 14 | target_arch: option_env!("CARGO_CFG_TARGET_ARCH").unwrap_or_default().to_string(), 15 | target_vendor: option_env!("CARGO_CFG_TARGET_VENDOR").unwrap_or_default().to_string(), 16 | target_env: option_env!("CARGO_CFG_TARGET_ENV").unwrap_or_default().to_string(), 17 | }) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /native/src/proto/okapi/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod okapi_examples; 2 | pub mod okapi_hashing; 3 | pub mod okapi_keys; 4 | pub mod okapi_metadata; 5 | pub mod okapi_proofs; 6 | pub mod okapi_security; 7 | pub mod okapi_transport; 8 | -------------------------------------------------------------------------------- /native/src/proto/okapi/okapi_examples.rs: -------------------------------------------------------------------------------- 1 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 2 | pub struct BasicMessage { 3 | #[prost(string, tag = "1")] 4 | pub text: ::prost::alloc::string::String, 5 | } 6 | -------------------------------------------------------------------------------- /native/src/proto/okapi/okapi_hashing.rs: -------------------------------------------------------------------------------- 1 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 2 | pub struct Blake3HashRequest { 3 | #[prost(bytes = "vec", tag = "1")] 4 | pub data: ::prost::alloc::vec::Vec, 5 | } 6 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 7 | pub struct Blake3HashResponse { 8 | #[prost(bytes = "vec", tag = "1")] 9 | pub digest: ::prost::alloc::vec::Vec, 10 | } 11 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 12 | pub struct Blake3KeyedHashRequest { 13 | #[prost(bytes = "vec", tag = "1")] 14 | pub data: ::prost::alloc::vec::Vec, 15 | #[prost(bytes = "vec", tag = "2")] 16 | pub key: ::prost::alloc::vec::Vec, 17 | } 18 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 19 | pub struct Blake3KeyedHashResponse { 20 | #[prost(bytes = "vec", tag = "1")] 21 | pub digest: ::prost::alloc::vec::Vec, 22 | } 23 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 24 | pub struct Blake3DeriveKeyRequest { 25 | #[prost(bytes = "vec", tag = "1")] 26 | pub context: ::prost::alloc::vec::Vec, 27 | #[prost(bytes = "vec", tag = "2")] 28 | pub key_material: ::prost::alloc::vec::Vec, 29 | } 30 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 31 | pub struct Blake3DeriveKeyResponse { 32 | #[prost(bytes = "vec", tag = "1")] 33 | pub digest: ::prost::alloc::vec::Vec, 34 | } 35 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 36 | pub struct Sha256HashRequest { 37 | #[prost(bytes = "vec", tag = "1")] 38 | pub data: ::prost::alloc::vec::Vec, 39 | } 40 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 41 | pub struct Sha256HashResponse { 42 | #[prost(bytes = "vec", tag = "1")] 43 | pub digest: ::prost::alloc::vec::Vec, 44 | } 45 | -------------------------------------------------------------------------------- /native/src/proto/okapi/okapi_metadata.rs: -------------------------------------------------------------------------------- 1 | /// Request custom metadata about the native okapi binaries - cannot get cargo env vars at runtime 2 | /// 3 | /// repeated string variables = 1; // optional field, can contain any of the cargo env vars 4 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 5 | pub struct MetadataRequest {} 6 | /// Metadata information about the native okapi binaries. Always returns the version information 7 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 8 | pub struct MetadataResponse { 9 | /// The full version string from okapi 10 | #[prost(string, tag = "1")] 11 | pub version: ::prost::alloc::string::String, 12 | /// Major version 13 | #[prost(int32, tag = "2")] 14 | pub version_major: i32, 15 | /// Minor version 16 | #[prost(int32, tag = "3")] 17 | pub version_minor: i32, 18 | /// Patch release version 19 | #[prost(int32, tag = "4")] 20 | pub version_patch: i32, 21 | /// https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates 22 | #[prost(string, tag = "10")] 23 | pub target_family: ::prost::alloc::string::String, 24 | #[prost(string, tag = "11")] 25 | pub target_os: ::prost::alloc::string::String, 26 | #[prost(string, tag = "12")] 27 | pub target_arch: ::prost::alloc::string::String, 28 | #[prost(string, tag = "13")] 29 | pub target_vendor: ::prost::alloc::string::String, 30 | #[prost(string, tag = "14")] 31 | pub target_env: ::prost::alloc::string::String, 32 | } 33 | -------------------------------------------------------------------------------- /native/src/proto/okapi/okapi_proofs.rs: -------------------------------------------------------------------------------- 1 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 2 | pub struct CreateProofRequest { 3 | /// The input JSON document that will be used 4 | /// to create the LD Proof. This document must 5 | /// also contain a "proof" object, with the desired 6 | /// values filled in. 7 | #[prost(message, optional, tag = "1")] 8 | pub document: ::core::option::Option, 9 | /// The signer of the proof. This field must include 10 | /// the 'kid' in full URI format. 11 | /// Example: 12 | /// did:example:alice#key-1 13 | #[prost(message, optional, tag = "3")] 14 | pub key: ::core::option::Option, 15 | /// The LD Suite to use to produce this proof 16 | #[prost(enumeration = "LdSuite", tag = "4")] 17 | pub suite: i32, 18 | } 19 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 20 | pub struct CreateProofResponse { 21 | #[prost(message, optional, tag = "1")] 22 | pub signed_document: ::core::option::Option, 23 | } 24 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 25 | pub struct VerifyProofRequest {} 26 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, PartialEq, ::prost::Message)] 27 | pub struct VerifyProofResponse {} 28 | #[derive(::serde::Serialize, ::serde::Deserialize, Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] 29 | #[repr(i32)] 30 | pub enum LdSuite { 31 | Unspecified = 0, 32 | Jcsed25519signature2020 = 1, 33 | } 34 | -------------------------------------------------------------------------------- /native/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod keys; 2 | pub mod oberon; 3 | pub mod pack; 4 | pub mod sign; 5 | pub mod utils; 6 | -------------------------------------------------------------------------------- /native/src/tests/utils.rs: -------------------------------------------------------------------------------- 1 | use crate::proto::metadata::MetadataRequest; 2 | use crate::Metadata; 3 | 4 | #[test] 5 | fn test_return_version() { 6 | let version_metadata = Metadata::get_metadata(&MetadataRequest {}).unwrap(); 7 | assert_eq!(version_metadata.version, "0.1.0"); 8 | assert_eq!(version_metadata.version_major, 0); 9 | assert_eq!(version_metadata.version_minor, 1); 10 | assert_eq!(version_metadata.version_patch, 0); 11 | } 12 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "okapi", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /proto/README.md: -------------------------------------------------------------------------------- 1 | # Okapi Protobuf Files 2 | 3 | These files are synched with Buf repo at https://buf.build/trinsic/okapi. 4 | 5 | ## Working with Buf repo 6 | 7 | Requires Buf CLI. See intallation instructions - https://docs.buf.build/installation 8 | 9 | To update remote repository from local changes: 10 | 11 | ``` 12 | buf push 13 | ``` 14 | 15 | To pull remote changes to local repository: 16 | 17 | ``` 18 | buf mod update 19 | ``` -------------------------------------------------------------------------------- /proto/buf.md: -------------------------------------------------------------------------------- 1 | # Okapi Documentation 2 | 3 | TODO -------------------------------------------------------------------------------- /proto/buf.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | lint: 3 | use: 4 | - DEFAULT 5 | breaking: 6 | use: 7 | - FILE 8 | name: buf.build/trinsic/okapi -------------------------------------------------------------------------------- /proto/okapi/examples/v1/examples.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "pbmse/v1/pbmse.proto"; 4 | 5 | package okapi.examples.v1; 6 | 7 | option csharp_namespace = "Okapi.Examples.V1"; 8 | option go_package = "okapi/examples/v1/examples"; 9 | option java_package = "trinsic.okapi.examples.v1"; 10 | 11 | message BasicMessage { 12 | string text = 1; 13 | } 14 | 15 | service SecureExampleService { 16 | rpc Unary(pbmse.v1.EncryptedMessage) returns (pbmse.v1.EncryptedMessage); 17 | 18 | rpc ServerStreaming(pbmse.v1.EncryptedMessage) returns (stream pbmse.v1.EncryptedMessage); 19 | } -------------------------------------------------------------------------------- /proto/okapi/hashing/v1/hashing.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package okapi.hashing.v1; 4 | 5 | option csharp_namespace = "Okapi.Hashing.V1"; 6 | option go_package = "okapi/hashing/v1/hashing"; 7 | option java_package = "trinsic.okapi.hashing.v1"; 8 | 9 | 10 | message Blake3HashRequest { 11 | bytes data = 1; 12 | } 13 | 14 | message Blake3HashResponse { 15 | bytes digest = 1; 16 | } 17 | 18 | message Blake3KeyedHashRequest { 19 | bytes data = 1; 20 | bytes key = 2; 21 | } 22 | 23 | message Blake3KeyedHashResponse { 24 | bytes digest = 1; 25 | } 26 | 27 | message Blake3DeriveKeyRequest { 28 | bytes context = 1; 29 | bytes key_material = 2; 30 | } 31 | 32 | message Blake3DeriveKeyResponse { 33 | bytes digest = 1; 34 | } 35 | 36 | message SHA256HashRequest { 37 | bytes data = 1; 38 | } 39 | 40 | message SHA256HashResponse { 41 | bytes digest = 1; 42 | } -------------------------------------------------------------------------------- /proto/okapi/keys/v1/keys.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package okapi.keys.v1; 4 | 5 | option csharp_namespace = "Okapi.Keys.V1"; 6 | option go_package = "okapi/keys/v1/keys"; 7 | option java_package = "trinsic.okapi.keys.v1"; 8 | 9 | import "google/protobuf/struct.proto"; 10 | 11 | enum KeyType { 12 | KEY_TYPE_UNSPECIFIED = 0; 13 | KEY_TYPE_ED25519 = 1; 14 | KEY_TYPE_X25519 = 2; 15 | KEY_TYPE_P256 = 3; 16 | KEY_TYPE_BLS12381G1G2 = 4; 17 | KEY_TYPE_SECP256K1 = 5; 18 | } 19 | 20 | enum DocumentKeyFormat { 21 | DOCUMENT_KEY_FORMAT_UNSPECIFIED = 0; 22 | DOCUMENT_KEY_FORMAT_LD = 1; 23 | DOCUMENT_KEY_FORMAT_JOSE = 2; 24 | } 25 | 26 | message GenerateKeyRequest { 27 | bytes seed = 1; 28 | KeyType key_type = 2; 29 | DocumentKeyFormat key_format = 3; 30 | } 31 | 32 | message GenerateKeyResponse { 33 | repeated JsonWebKey key = 1; 34 | google.protobuf.Struct did_document = 2; 35 | } 36 | 37 | message ResolveRequest { 38 | string did = 1; 39 | } 40 | 41 | message ResolveResponse { 42 | google.protobuf.Struct did_document = 1; 43 | repeated JsonWebKey keys = 2; 44 | } 45 | 46 | message JsonWebKey { 47 | string kid = 1; 48 | string x = 2; // public_key 49 | string y = 3; // public_key 50 | string d = 4; // secret_key 51 | string crv = 5; 52 | string kty = 6; 53 | } -------------------------------------------------------------------------------- /proto/okapi/metadata/metadata.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package okapi.metadata; 4 | 5 | option csharp_namespace = "Okapi.Metadata"; 6 | option go_package = "okapi/metadata"; 7 | option java_package = "trinsic.okapi.metadata"; 8 | // Request custom metadata about the native okapi binaries - cannot get cargo env vars at runtime 9 | message MetadataRequest { 10 | // repeated string variables = 1; // optional field, can contain any of the cargo env vars 11 | } 12 | 13 | // Metadata information about the native okapi binaries. Always returns the version information 14 | message MetadataResponse { 15 | string version = 1; // The full version string from okapi 16 | int32 version_major = 2; // Major version 17 | int32 version_minor = 3; // Minor version 18 | int32 version_patch = 4; // Patch release version 19 | 20 | // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates 21 | string target_family = 10; 22 | string target_os = 11; 23 | string target_arch = 12; 24 | string target_vendor = 13; 25 | string target_env = 14; 26 | } -------------------------------------------------------------------------------- /proto/okapi/proofs/v1/proofs.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package okapi.proofs.v1; 4 | 5 | option csharp_namespace = "Okapi.Proofs.V1"; 6 | option go_package = "okapi/proofs/v1/proofs"; 7 | option java_package = "trinsic.okapi.proofs.v1"; 8 | 9 | import "okapi/keys/v1/keys.proto"; 10 | import "google/protobuf/struct.proto"; 11 | 12 | enum LdSuite { 13 | LD_SUITE_UNSPECIFIED = 0; 14 | LD_SUITE_JCSED25519SIGNATURE2020 = 1; 15 | } 16 | 17 | message CreateProofRequest { 18 | // The input JSON document that will be used 19 | // to create the LD Proof. This document must 20 | // also contain a "proof" object, with the desired 21 | // values filled in. 22 | google.protobuf.Struct document = 1; 23 | 24 | // The signer of the proof. This field must include 25 | // the 'kid' in full URI format. 26 | // Example: 27 | // did:example:alice#key-1 28 | okapi.keys.v1.JsonWebKey key = 3; 29 | 30 | // The LD Suite to use to produce this proof 31 | LdSuite suite = 4; 32 | } 33 | 34 | message CreateProofResponse { 35 | google.protobuf.Struct signed_document = 1; 36 | } 37 | 38 | message VerifyProofRequest { 39 | } 40 | 41 | message VerifyProofResponse { 42 | } -------------------------------------------------------------------------------- /proto/okapi/transport/v1/transport.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package okapi.transport.v1; 4 | 5 | option csharp_namespace = "Okapi.Transport.V1"; 6 | option go_package = "okapi/transport/v1/transport"; 7 | option java_package = "trinsic.okapi.transport.v1"; 8 | 9 | import "okapi/keys/v1/keys.proto"; 10 | import "pbmse/v1/pbmse.proto"; 11 | 12 | message SignRequest { 13 | bytes payload = 1; 14 | okapi.keys.v1.JsonWebKey key = 2; 15 | pbmse.v1.SignedMessage append_to = 3; 16 | } 17 | 18 | message SignResponse { 19 | pbmse.v1.SignedMessage message = 1; 20 | } 21 | 22 | message VerifyRequest { 23 | pbmse.v1.SignedMessage message = 1; 24 | okapi.keys.v1.JsonWebKey key = 2; 25 | } 26 | 27 | message VerifyResponse { 28 | bool is_valid = 1; 29 | } 30 | 31 | message PackRequest { 32 | okapi.keys.v1.JsonWebKey sender_key = 1; 33 | okapi.keys.v1.JsonWebKey receiver_key = 2; 34 | bytes associated_data = 3; 35 | bytes plaintext = 4; 36 | pbmse.v1.EncryptionMode mode = 5; 37 | pbmse.v1.EncryptionAlgorithm algorithm = 6; 38 | } 39 | 40 | message PackResponse { 41 | pbmse.v1.EncryptedMessage message = 1; 42 | } 43 | 44 | message UnpackRequest { 45 | okapi.keys.v1.JsonWebKey sender_key = 1; 46 | okapi.keys.v1.JsonWebKey receiver_key = 2; 47 | 48 | pbmse.v1.EncryptedMessage message = 3; 49 | } 50 | 51 | message UnpackResponse { 52 | bytes plaintext = 1; 53 | } 54 | 55 | message CoreMessage { 56 | string id = 1; 57 | string type = 2; 58 | bytes body = 3; 59 | repeated string to = 4; 60 | string from = 5; 61 | int64 created = 6 [json_name="created_time"]; 62 | int64 expires = 7 [json_name="expires_time"]; 63 | } 64 | -------------------------------------------------------------------------------- /proto/pbmse/v1/pbmse.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package pbmse.v1; 4 | 5 | option go_package = "pbmse/v1/pbmse"; 6 | option java_package = "trinsic.okapi.pbmse.v1"; 7 | 8 | // JWS 9 | // Protocol buffer message signing and encryption 10 | message SignedMessage { 11 | bytes payload = 1; 12 | repeated Signature signatures = 2; 13 | } 14 | message Signature { 15 | bytes header = 1; 16 | bytes signature = 3; 17 | } 18 | message SignatureHeader { 19 | string algorithm = 1; 20 | string key_id = 2; 21 | } 22 | 23 | // JWE 24 | 25 | message EncryptedMessage { 26 | bytes iv = 1 [json_name="iv"]; 27 | bytes aad = 2 [json_name="aad"]; 28 | bytes ciphertext = 3 [json_name="ciphertext"]; 29 | bytes tag = 4; 30 | repeated EncryptionRecipient recipients = 5; 31 | } 32 | 33 | message EncryptionHeader { 34 | EncryptionMode mode = 1 [json_name="enc"]; 35 | EncryptionAlgorithm algorithm = 2 [json_name="alg"]; 36 | string key_id = 3 [json_name="kid"]; 37 | string sender_key_id = 4 [json_name="skid"]; 38 | } 39 | 40 | message EncryptionRecipient { 41 | EncryptionHeader header = 1 [json_name="unprotected"]; 42 | bytes content_encryption_key = 2 [json_name="cek"]; 43 | } 44 | 45 | enum EncryptionMode { 46 | ENCRYPTION_MODE_UNSPECIFIED = 0; 47 | ENCRYPTION_MODE_DIRECT = 1; 48 | ENCRYPTION_MODE_CONTENT_ENCRYPTION_KEY = 2; 49 | } 50 | 51 | enum EncryptionAlgorithm { 52 | ENCRYPTION_ALGORITHM_UNSPECIFIED = 0; 53 | ENCRYPTION_ALGORITHM_XCHACHA20POLY1305 = 1; 54 | ENCRYPTION_ALGORITHM_AES_GCM = 2; 55 | } 56 | -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | *.dylib 2 | *.so 3 | *.dll 4 | /.idea 5 | /venv -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | # Trinsic Okapi SDK 2 | 3 | Python3 bindings for the Trinsic Okapi SDK: 4 | 5 | 1. didcomm implementation in `trinsic-okapi` 6 | 3. Unit tests and examples are in `tests` 7 | 8 | ## Installation 9 | 10 | 1. `pip3 install --upgrade pip` 11 | 2. `pip3 install -r requirements.txt` 12 | 3. To find the latest binary packages, run `okapi_utils.download_binaries()`. For rate-limit increases, set the 13 | environment variable `API_GITHUB_TOKEN`. This will download the os/architecture binaries and install them. 14 | 15 | ## Development 16 | 1. We use [black](https://pypi.org/project/black/) to format. `pip install black`, then `black ./` in this directory 17 | 2. We use [flake8](https://flake8.pycqa.org/en/latest/user/configuration.html) to lint. `pip install flake8`, then `flake8` in this directory -------------------------------------------------------------------------------- /python/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel", 5 | "black", 6 | "flake8" 7 | ] 8 | build-backend = "setuptools.build_meta" 9 | 10 | [tool.black] 11 | skip-string-normalization = true -------------------------------------------------------------------------------- /python/requirements.txt: -------------------------------------------------------------------------------- 1 | base58==2.1.1 2 | betterproto~=2.0.0b4 3 | grpcio-tools==1.47.0 4 | grpclib==0.4.3 5 | requests==2.31.0 6 | setuptools==65.5.1 7 | black 8 | flake8 9 | pytest 10 | pytest-cov 11 | build -------------------------------------------------------------------------------- /python/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = trinsic-okapi 3 | version = 1.6.1 4 | author = Scott Phillips 5 | author_email = scott.phillips@trinsic.id 6 | description = Trinsic okapi SDK bindings 7 | long_description = file: README.md 8 | long_description_content_type = text/markdown 9 | url = https://github.com/trinsic-id/okapi/python 10 | project_urls = 11 | Bug Tracker = https://github.com/trinsic-id/okapi/issues 12 | classifiers = 13 | Programming Language :: Python :: 3 14 | License :: OSI Approved :: Apache Software License 15 | Operating System :: OS Independent 16 | 17 | [options] 18 | include_package_data = True 19 | python_requires = >=3.7 20 | install_requires = 21 | protobuf>=3.17.3 22 | betterproto>=2.0.0b4 23 | requests>=2.27.1 24 | 25 | [flake8] 26 | # Recommend matching the black line length (default 88), 27 | # rather than using the flake8 default of 79: 28 | max-line-length = 88 29 | doctests = True 30 | extend-ignore = 31 | # See https://github.com/PyCQA/pycodestyle/issues/373 32 | E203, 33 | exclude = 34 | # Generated code from betterproto 35 | trinsicokapi/proto, 36 | per-file-ignores = 37 | # Ignore line too long because it's a base16 constant string 38 | tests/test_hash.py: E501 39 | tests/test_keys.py: E501 40 | 41 | [options.data_files] 42 | libs/windows = trinsicokapi/libs/windows/okapi.dll 43 | libs/linux = trinsicokapi/libs/linux/libokapi.so 44 | libs/macos = trinsicokapi/libs/macos/libokapi.dylib 45 | libs/linux-aarch64 = trinsicokapi/libs/linux-aarch64/libokapi.so 46 | libs/linux-armv7 = trinsicokapi/libs/linux-armv7/libokapi.so -------------------------------------------------------------------------------- /python/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/tests/__init__.py -------------------------------------------------------------------------------- /python/tests/okapi_demo.py: -------------------------------------------------------------------------------- 1 | def run(): 2 | import trinsicokapi.__main__ as m 3 | 4 | m.run() 5 | 6 | 7 | if __name__ == "__main__": 8 | run() 9 | -------------------------------------------------------------------------------- /python/tests/test_ldproofs.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import unittest 3 | 4 | from trinsicokapi import didkey, ldproofs 5 | from trinsicokapi.okapi_utils import dictionary_to_struct 6 | from trinsicokapi.proto.okapi.keys.v1 import GenerateKeyRequest, KeyType, JsonWebKey 7 | from trinsicokapi.proto.okapi.proofs.v1 import CreateProofRequest, LdSuite 8 | 9 | 10 | class LdProofsTests(unittest.TestCase): 11 | def test_generate_capability_invocation_proof_with_jcs(self): 12 | capability_dict = { 13 | "@context": "https://w3id.org/security/v2", 14 | "target": "urn:trinsic:wallets:noop", 15 | "proof": {"created": datetime.datetime.now().isoformat()}, 16 | } 17 | 18 | capability = dictionary_to_struct(capability_dict) 19 | print(capability) 20 | 21 | request = GenerateKeyRequest() 22 | request.key_type = KeyType.KEY_TYPE_ED25519 23 | response = didkey.generate(request) 24 | signing_key: JsonWebKey = [key for key in response.key if key.crv == "Ed25519"][ 25 | 0 26 | ] 27 | 28 | proof_request = CreateProofRequest( 29 | document=capability, 30 | key=signing_key, 31 | suite=LdSuite.LD_SUITE_JCSED25519SIGNATURE2020, 32 | ) 33 | 34 | signed_capability = ldproofs.create(proof_request) 35 | self.assertIsNotNone(signed_capability) 36 | self.assertIsNotNone(signed_capability.signed_document) 37 | 38 | 39 | if __name__ == "__main__": 40 | unittest.main() 41 | -------------------------------------------------------------------------------- /python/trinsicokapi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/__main__.py: -------------------------------------------------------------------------------- 1 | from trinsicokapi import metadata, didkey 2 | from trinsicokapi.proto.okapi.keys.v1 import KeyType, GenerateKeyRequest 3 | 4 | 5 | def run(): 6 | request = GenerateKeyRequest() 7 | request.key_type = KeyType.KEY_TYPE_ED25519 8 | request.seed = bytes(bytearray([1, 2, 3])) 9 | 10 | key_response = didkey.generate(request) 11 | print(key_response.key) 12 | print(f"version={metadata.get_metadata().version}") 13 | 14 | 15 | if __name__ == "__main__": 16 | run() 17 | -------------------------------------------------------------------------------- /python/trinsicokapi/didcomm.py: -------------------------------------------------------------------------------- 1 | from trinsicokapi.proto.okapi.transport.v1 import ( 2 | VerifyRequest, 3 | SignRequest, 4 | UnpackRequest, 5 | PackRequest, 6 | PackResponse, 7 | UnpackResponse, 8 | SignResponse, 9 | VerifyResponse, 10 | ) 11 | from trinsicokapi.wrapper import _typed_wrap_and_call 12 | 13 | 14 | def pack(request: PackRequest) -> PackResponse: 15 | response = _typed_wrap_and_call("didcomm_pack", request, PackResponse) 16 | return response 17 | 18 | 19 | def unpack(request: UnpackRequest) -> UnpackResponse: 20 | response = _typed_wrap_and_call("didcomm_unpack", request, UnpackResponse) 21 | return response 22 | 23 | 24 | def sign(request: SignRequest) -> SignResponse: 25 | response = _typed_wrap_and_call("didcomm_sign", request, SignResponse) 26 | return response 27 | 28 | 29 | def verify(request: VerifyRequest) -> VerifyResponse: 30 | response = _typed_wrap_and_call("didcomm_verify", request, VerifyResponse) 31 | return response 32 | -------------------------------------------------------------------------------- /python/trinsicokapi/didkey.py: -------------------------------------------------------------------------------- 1 | from trinsicokapi.proto.okapi.keys.v1 import ( 2 | GenerateKeyRequest, 3 | GenerateKeyResponse, 4 | ResolveResponse, 5 | ResolveRequest, 6 | ) 7 | from trinsicokapi.wrapper import _typed_wrap_and_call 8 | 9 | 10 | def generate(request: GenerateKeyRequest) -> GenerateKeyResponse: 11 | response = _typed_wrap_and_call("didkey_generate", request, GenerateKeyResponse) 12 | return response 13 | 14 | 15 | def resolve(request: ResolveRequest) -> ResolveResponse: 16 | response = _typed_wrap_and_call("didkey_resolve", request, ResolveResponse) 17 | return response 18 | -------------------------------------------------------------------------------- /python/trinsicokapi/hashing.py: -------------------------------------------------------------------------------- 1 | from trinsicokapi.proto.okapi.hashing.v1 import ( 2 | Sha256HashResponse, 3 | Sha256HashRequest, 4 | Blake3HashRequest, 5 | Blake3HashResponse, 6 | Blake3KeyedHashRequest, 7 | Blake3KeyedHashResponse, 8 | Blake3DeriveKeyRequest, 9 | Blake3DeriveKeyResponse, 10 | ) 11 | from trinsicokapi.wrapper import _typed_wrap_and_call 12 | 13 | 14 | def sha256_hash(request: Sha256HashRequest) -> Sha256HashResponse: 15 | response = _typed_wrap_and_call("sha256_hash", request, Sha256HashResponse) 16 | return response 17 | 18 | 19 | def blake3_hash(request: Blake3HashRequest) -> Blake3HashResponse: 20 | response = _typed_wrap_and_call("blake3_hash", request, Blake3HashResponse) 21 | return response 22 | 23 | 24 | def blake3_keyed_hash(request: Blake3KeyedHashRequest) -> Blake3KeyedHashResponse: 25 | response = _typed_wrap_and_call( 26 | "blake3_keyed_hash", request, Blake3KeyedHashResponse 27 | ) 28 | return response 29 | 30 | 31 | def blake3_derive_key(request: Blake3DeriveKeyRequest) -> Blake3DeriveKeyResponse: 32 | response = _typed_wrap_and_call( 33 | "blake3_derive_key", request, Blake3DeriveKeyResponse 34 | ) 35 | return response 36 | -------------------------------------------------------------------------------- /python/trinsicokapi/ldproofs.py: -------------------------------------------------------------------------------- 1 | from trinsicokapi.proto.okapi.proofs.v1 import ( 2 | CreateProofRequest, 3 | CreateProofResponse, 4 | ) 5 | from trinsicokapi.wrapper import _typed_wrap_and_call 6 | 7 | 8 | def create(request: CreateProofRequest) -> CreateProofResponse: 9 | response = _typed_wrap_and_call( 10 | "ldproofs_create_proof", request, CreateProofResponse 11 | ) 12 | return response 13 | -------------------------------------------------------------------------------- /python/trinsicokapi/metadata.py: -------------------------------------------------------------------------------- 1 | from trinsicokapi.proto.okapi.metadata import MetadataResponse, MetadataRequest 2 | from trinsicokapi.wrapper import _typed_wrap_and_call 3 | 4 | 5 | def get_metadata() -> MetadataResponse: 6 | response = _typed_wrap_and_call( 7 | "okapi_metadata", MetadataRequest(), MetadataResponse 8 | ) 9 | return response 10 | -------------------------------------------------------------------------------- /python/trinsicokapi/oberon.py: -------------------------------------------------------------------------------- 1 | from trinsicokapi.proto.okapi.security.v1 import ( 2 | CreateOberonKeyRequest, 3 | CreateOberonKeyResponse, 4 | CreateOberonProofRequest, 5 | CreateOberonProofResponse, 6 | CreateOberonTokenRequest, 7 | CreateOberonTokenResponse, 8 | BlindOberonTokenResponse, 9 | BlindOberonTokenRequest, 10 | UnBlindOberonTokenRequest, 11 | UnBlindOberonTokenResponse, 12 | VerifyOberonProofResponse, 13 | VerifyOberonProofRequest, 14 | VerifyOberonTokenRequest, 15 | VerifyOberonTokenResponse, 16 | ) 17 | from trinsicokapi.wrapper import _typed_wrap_and_call 18 | 19 | 20 | def create_key(request: CreateOberonKeyRequest) -> CreateOberonKeyResponse: 21 | return _typed_wrap_and_call("oberon_create_key", request, CreateOberonKeyResponse) 22 | 23 | 24 | def create_proof(request: CreateOberonProofRequest) -> CreateOberonProofResponse: 25 | return _typed_wrap_and_call( 26 | "oberon_create_proof", request, CreateOberonProofResponse 27 | ) 28 | 29 | 30 | def create_token(request: CreateOberonTokenRequest) -> CreateOberonTokenResponse: 31 | return _typed_wrap_and_call( 32 | "oberon_create_token", request, CreateOberonTokenResponse 33 | ) 34 | 35 | 36 | def blind_token(request: BlindOberonTokenRequest) -> BlindOberonTokenResponse: 37 | return _typed_wrap_and_call("oberon_blind_token", request, BlindOberonTokenResponse) 38 | 39 | 40 | def verify_token(request: VerifyOberonTokenRequest) -> VerifyOberonTokenResponse: 41 | return _typed_wrap_and_call( 42 | "oberon_verify_token", request, VerifyOberonTokenResponse 43 | ) 44 | 45 | 46 | def unblind_token(request: UnBlindOberonTokenRequest) -> UnBlindOberonTokenResponse: 47 | return _typed_wrap_and_call( 48 | "oberon_unblind_token", request, UnBlindOberonTokenResponse 49 | ) 50 | 51 | 52 | def verify_proof(request: VerifyOberonProofRequest) -> VerifyOberonProofResponse: 53 | return _typed_wrap_and_call( 54 | "oberon_verify_proof", request, VerifyOberonProofResponse 55 | ) 56 | -------------------------------------------------------------------------------- /python/trinsicokapi/okapi_utils.py: -------------------------------------------------------------------------------- 1 | from typing import Any, List, Dict, Union 2 | 3 | from betterproto.lib.google.protobuf import Struct, Value, ListValue 4 | 5 | 6 | def value_to_proto_value(obj: Any) -> Value: 7 | value = Value() 8 | if isinstance(obj, str): 9 | value = Value(string_value=str(obj)) 10 | elif isinstance(obj, int) or isinstance(obj, float): 11 | value = Value(number_value=float(obj)) 12 | elif isinstance(obj, bool): 13 | value = Value(bool_value=obj) 14 | elif isinstance(obj, dict): 15 | value = Value(struct_value=dictionary_to_struct(obj)) 16 | elif isinstance(obj, list): 17 | value = Value(list_value=list_to_proto_list(obj)) 18 | 19 | return value 20 | 21 | 22 | def proto_value_to_value(obj: Value) -> Union[str, float, bool, dict, list]: 23 | if obj.string_value: 24 | return str(obj.string_value) 25 | elif obj.bool_value: 26 | return bool(obj.bool_value) 27 | elif obj.number_value: 28 | return float(obj.number_value) 29 | elif obj.list_value: 30 | return [proto_value_to_value(x) for x in obj.list_value.values] 31 | elif obj.struct_value: 32 | return struct_to_dictionary(obj.struct_value) 33 | 34 | 35 | def list_to_proto_list(obj: List) -> ListValue: 36 | return ListValue(values=[value_to_proto_value(item) for item in obj]) 37 | 38 | 39 | def dictionary_to_struct(obj: Dict[str, Any]) -> Struct: 40 | return Struct(fields=dict([(k, value_to_proto_value(v)) for k, v in obj.items()])) 41 | 42 | 43 | def struct_to_dictionary(obj: Struct) -> Dict[str, Any]: 44 | return dict([(k, proto_value_to_value(v)) for k, v in obj.fields.items()]) 45 | -------------------------------------------------------------------------------- /python/trinsicokapi/proto/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/okapi/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/examples/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/okapi/examples/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/hashing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/okapi/hashing/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/hashing/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: okapi/hashing/v1/hashing.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Blake3HashRequest(betterproto.Message): 13 | data: bytes = betterproto.bytes_field(1) 14 | 15 | 16 | @dataclass(eq=False, repr=False) 17 | class Blake3HashResponse(betterproto.Message): 18 | digest: bytes = betterproto.bytes_field(1) 19 | 20 | 21 | @dataclass(eq=False, repr=False) 22 | class Blake3KeyedHashRequest(betterproto.Message): 23 | data: bytes = betterproto.bytes_field(1) 24 | key: bytes = betterproto.bytes_field(2) 25 | 26 | 27 | @dataclass(eq=False, repr=False) 28 | class Blake3KeyedHashResponse(betterproto.Message): 29 | digest: bytes = betterproto.bytes_field(1) 30 | 31 | 32 | @dataclass(eq=False, repr=False) 33 | class Blake3DeriveKeyRequest(betterproto.Message): 34 | context: bytes = betterproto.bytes_field(1) 35 | key_material: bytes = betterproto.bytes_field(2) 36 | 37 | 38 | @dataclass(eq=False, repr=False) 39 | class Blake3DeriveKeyResponse(betterproto.Message): 40 | digest: bytes = betterproto.bytes_field(1) 41 | 42 | 43 | @dataclass(eq=False, repr=False) 44 | class Sha256HashRequest(betterproto.Message): 45 | data: bytes = betterproto.bytes_field(1) 46 | 47 | 48 | @dataclass(eq=False, repr=False) 49 | class Sha256HashResponse(betterproto.Message): 50 | digest: bytes = betterproto.bytes_field(1) 51 | -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/keys/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/okapi/keys/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/keys/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: okapi/keys/v1/keys.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf 11 | 12 | 13 | class KeyType(betterproto.Enum): 14 | KEY_TYPE_UNSPECIFIED = 0 15 | KEY_TYPE_ED25519 = 1 16 | KEY_TYPE_X25519 = 2 17 | KEY_TYPE_P256 = 3 18 | KEY_TYPE_BLS12381G1G2 = 4 19 | KEY_TYPE_SECP256K1 = 5 20 | 21 | 22 | class DocumentKeyFormat(betterproto.Enum): 23 | DOCUMENT_KEY_FORMAT_UNSPECIFIED = 0 24 | DOCUMENT_KEY_FORMAT_LD = 1 25 | DOCUMENT_KEY_FORMAT_JOSE = 2 26 | 27 | 28 | @dataclass(eq=False, repr=False) 29 | class GenerateKeyRequest(betterproto.Message): 30 | seed: bytes = betterproto.bytes_field(1) 31 | key_type: "KeyType" = betterproto.enum_field(2) 32 | key_format: "DocumentKeyFormat" = betterproto.enum_field(3) 33 | 34 | 35 | @dataclass(eq=False, repr=False) 36 | class GenerateKeyResponse(betterproto.Message): 37 | key: List["JsonWebKey"] = betterproto.message_field(1) 38 | did_document: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field( 39 | 2 40 | ) 41 | 42 | 43 | @dataclass(eq=False, repr=False) 44 | class ResolveRequest(betterproto.Message): 45 | did: str = betterproto.string_field(1) 46 | 47 | 48 | @dataclass(eq=False, repr=False) 49 | class ResolveResponse(betterproto.Message): 50 | did_document: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field( 51 | 1 52 | ) 53 | keys: List["JsonWebKey"] = betterproto.message_field(2) 54 | 55 | 56 | @dataclass(eq=False, repr=False) 57 | class JsonWebKey(betterproto.Message): 58 | kid: str = betterproto.string_field(1) 59 | x: str = betterproto.string_field(2) 60 | y: str = betterproto.string_field(3) 61 | d: str = betterproto.string_field(4) 62 | crv: str = betterproto.string_field(5) 63 | kty: str = betterproto.string_field(6) 64 | -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/metadata/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: okapi/metadata/metadata.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class MetadataRequest(betterproto.Message): 13 | """ 14 | Request custom metadata about the native okapi binaries - cannot get cargo 15 | env vars at runtime 16 | """ 17 | 18 | pass 19 | 20 | 21 | @dataclass(eq=False, repr=False) 22 | class MetadataResponse(betterproto.Message): 23 | """ 24 | Metadata information about the native okapi binaries. Always returns the 25 | version information 26 | """ 27 | 28 | version: str = betterproto.string_field(1) 29 | version_major: int = betterproto.int32_field(2) 30 | version_minor: int = betterproto.int32_field(3) 31 | version_patch: int = betterproto.int32_field(4) 32 | target_family: str = betterproto.string_field(10) 33 | """ 34 | https://doc.rust-lang.org/cargo/reference/environment- 35 | variables.html#environment-variables-cargo-sets-for-crates 36 | """ 37 | 38 | target_os: str = betterproto.string_field(11) 39 | target_arch: str = betterproto.string_field(12) 40 | target_vendor: str = betterproto.string_field(13) 41 | target_env: str = betterproto.string_field(14) 42 | -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/proofs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/okapi/proofs/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/proofs/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: okapi/proofs/v1/proofs.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf 10 | 11 | from ...keys import v1 as __keys_v1__ 12 | 13 | 14 | class LdSuite(betterproto.Enum): 15 | LD_SUITE_UNSPECIFIED = 0 16 | LD_SUITE_JCSED25519SIGNATURE2020 = 1 17 | 18 | 19 | @dataclass(eq=False, repr=False) 20 | class CreateProofRequest(betterproto.Message): 21 | document: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(1) 22 | """ 23 | The input JSON document that will be used to create the LD Proof. This 24 | document must also contain a "proof" object, with the desired values filled 25 | in. 26 | """ 27 | 28 | key: "__keys_v1__.JsonWebKey" = betterproto.message_field(3) 29 | """ 30 | The signer of the proof. This field must include the 'kid' in full URI 31 | format. Example: did:example:alice#key-1 32 | """ 33 | 34 | suite: "LdSuite" = betterproto.enum_field(4) 35 | """The LD Suite to use to produce this proof""" 36 | 37 | 38 | @dataclass(eq=False, repr=False) 39 | class CreateProofResponse(betterproto.Message): 40 | signed_document: "betterproto_lib_google_protobuf.Struct" = ( 41 | betterproto.message_field(1) 42 | ) 43 | 44 | 45 | @dataclass(eq=False, repr=False) 46 | class VerifyProofRequest(betterproto.Message): 47 | pass 48 | 49 | 50 | @dataclass(eq=False, repr=False) 51 | class VerifyProofResponse(betterproto.Message): 52 | pass 53 | -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/security/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/okapi/security/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/okapi/transport/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/okapi/transport/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/pbmse/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/python/trinsicokapi/proto/pbmse/__init__.py -------------------------------------------------------------------------------- /python/trinsicokapi/proto/pbmse/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: pbmse/v1/pbmse.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | class EncryptionMode(betterproto.Enum): 13 | ENCRYPTION_MODE_UNSPECIFIED = 0 14 | ENCRYPTION_MODE_DIRECT = 1 15 | ENCRYPTION_MODE_CONTENT_ENCRYPTION_KEY = 2 16 | 17 | 18 | class EncryptionAlgorithm(betterproto.Enum): 19 | ENCRYPTION_ALGORITHM_UNSPECIFIED = 0 20 | ENCRYPTION_ALGORITHM_XCHACHA20POLY1305 = 1 21 | ENCRYPTION_ALGORITHM_AES_GCM = 2 22 | 23 | 24 | @dataclass(eq=False, repr=False) 25 | class SignedMessage(betterproto.Message): 26 | """JWS Protocol buffer message signing and encryption""" 27 | 28 | payload: bytes = betterproto.bytes_field(1) 29 | signatures: List["Signature"] = betterproto.message_field(2) 30 | 31 | 32 | @dataclass(eq=False, repr=False) 33 | class Signature(betterproto.Message): 34 | header: bytes = betterproto.bytes_field(1) 35 | signature: bytes = betterproto.bytes_field(3) 36 | 37 | 38 | @dataclass(eq=False, repr=False) 39 | class SignatureHeader(betterproto.Message): 40 | algorithm: str = betterproto.string_field(1) 41 | key_id: str = betterproto.string_field(2) 42 | 43 | 44 | @dataclass(eq=False, repr=False) 45 | class EncryptedMessage(betterproto.Message): 46 | iv: bytes = betterproto.bytes_field(1) 47 | aad: bytes = betterproto.bytes_field(2) 48 | ciphertext: bytes = betterproto.bytes_field(3) 49 | tag: bytes = betterproto.bytes_field(4) 50 | recipients: List["EncryptionRecipient"] = betterproto.message_field(5) 51 | 52 | 53 | @dataclass(eq=False, repr=False) 54 | class EncryptionHeader(betterproto.Message): 55 | mode: "EncryptionMode" = betterproto.enum_field(1) 56 | algorithm: "EncryptionAlgorithm" = betterproto.enum_field(2) 57 | key_id: str = betterproto.string_field(3) 58 | sender_key_id: str = betterproto.string_field(4) 59 | 60 | 61 | @dataclass(eq=False, repr=False) 62 | class EncryptionRecipient(betterproto.Message): 63 | header: "EncryptionHeader" = betterproto.message_field(1) 64 | content_encryption_key: bytes = betterproto.bytes_field(2) 65 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["config:base"], 4 | "branchPrefix": "mewmba/renovate/", 5 | "username": "mewmba-renovate", 6 | "gitAuthor": "mewmba Renovate Bot ", 7 | "onboarding": false, 8 | "platform": "github", 9 | "forkProcessing": "disabled", 10 | "packageRules": [ 11 | { 12 | "matchPackageNames": ["*"], 13 | "matchUpdateTypes": ["major", "minor", "patch", "pin", "digest"], 14 | "groupName": "{{dep.manager}}", 15 | "groupNameTemplate": "${dep.manager}", 16 | "enabled": true 17 | } 18 | ], 19 | "additionalBranchPrefix": "{{parentDir}}-", 20 | "automergeType": "pr", 21 | "assignees": ["janpieterz"], 22 | "reviewers": ["janpieterz"], 23 | "separateMajorMinor": false 24 | } 25 | -------------------------------------------------------------------------------- /wasm/.eslintignore: -------------------------------------------------------------------------------- 1 | # don't ever lint node_modules 2 | node_modules 3 | # don't lint build output (make sure it's set to your correct build folder name) 4 | dist 5 | target -------------------------------------------------------------------------------- /wasm/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: '@typescript-eslint/parser', 4 | plugins: [ 5 | '@typescript-eslint', 6 | ], 7 | extends: [ 8 | 'eslint:recommended', 9 | 'plugin:@typescript-eslint/recommended', 10 | ], 11 | }; -------------------------------------------------------------------------------- /wasm/.gitignore: -------------------------------------------------------------------------------- 1 | !packages/* 2 | dist/ 3 | 4 | packages/okapi/lib 5 | packages/okapi-proto/lib 6 | packages/okapi-node/lib 7 | packages/okapi-web/lib 8 | packages/okapi-proto/src/proto/**/* 9 | !packages/okapi-proto/src/proto/index.ts -------------------------------------------------------------------------------- /wasm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "okapi-wasm" 3 | version = "0.1.0" 4 | authors = ["Tomislav Markovski "] 5 | edition = "2018" 6 | description = "WASM Bindings for Okapi" 7 | repository = "https://github.com/trinsic-id/okapi/tree/main/wasm" 8 | license = "Apache 2.0" 9 | 10 | [lib] 11 | name = "okapi_wasm" 12 | crate-type = ["cdylib", "rlib"] 13 | 14 | [dependencies] 15 | wasm-bindgen = "0.2.82" 16 | js-sys = "0.3" 17 | okapi = { path = "../native", default-features = false, features = ["hashing"] } 18 | -------------------------------------------------------------------------------- /wasm/README.md: -------------------------------------------------------------------------------- 1 | # Okapi for JavaScript 2 | 3 | ## Usage 4 | 5 | ``` 6 | npm install @trinsic/okapi 7 | ``` 8 | 9 | ## Samples 10 | 11 | These sample projects show how Okapi can be used in your Node or Web project. Check the individual READMEs for instructions on running the sample code. 12 | 13 | - [Okapi for Node.js](examples/node-sample/) 14 | - [Okapi for Browser w/ Webpack](examples/browser-sample/) 15 | 16 | ## Build Requirements 17 | 18 | - Node.js 19 | - [Rust](https://www.rust-lang.org/tools/install) 20 | - [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) 21 | 22 | ## Build All Packages 23 | 24 | From this directory, run: 25 | 26 | ``` 27 | npm run start 28 | npm run build 29 | ``` 30 | 31 | ## Run tests 32 | 33 | ``` 34 | npm run test 35 | ``` 36 | 37 | ## Generate updated protobuf types 38 | 39 | This step is required if there have been changes to the proto files. 40 | 41 | ```powershell 42 | PS> ./Generate-Proto.ps1 43 | ``` -------------------------------------------------------------------------------- /wasm/packages/okapi/.config/jest.config.cjs: -------------------------------------------------------------------------------- 1 | // sync object 2 | module.exports = { 3 | verbose: true, 4 | collectCoverage: true, 5 | collectCoverageFrom: ['**/src/**/*.ts', '!**/node_modules/**'], 6 | testMatch: [ 7 | '**/test/*.spec.ts' 8 | ], 9 | globals: { 10 | 'ts-jest': { 11 | useESM: true, 12 | }, 13 | }, 14 | transform: {}, 15 | preset: 'ts-jest', 16 | testEnvironment: 'node', 17 | roots: ['../test'] 18 | } -------------------------------------------------------------------------------- /wasm/packages/okapi/Generate-Proto.ps1: -------------------------------------------------------------------------------- 1 | # Generate protobuf files for JS and TS 2 | param($OutDir = "$PSScriptRoot/src/proto") 3 | 4 | $PROTOC_GEN_TS_PATH = Resolve-Path "$PSScriptRoot/node_modules/.bin/protoc-gen-ts_proto$(If ($IsWindows) {'.cmd'} Else {''})" 5 | # For mac, `brew install protobuf` 6 | # for windows, download and install to PATH 7 | # for linux, `apt-get install protobuf` 8 | $PROTOC = "protoc" 9 | $OUTPUT_DIR = $OutDir 10 | $PROTO_DIR = Resolve-Path "$PSScriptRoot/../../../proto" 11 | Write-Output $PROTO_DIR 12 | 13 | if ((Get-Command "$PROTOC" -ErrorAction SilentlyContinue) -eq $null) 14 | { 15 | Write-Host "Unable to find $PROTOC in your PATH" 16 | Return 17 | } 18 | 19 | foreach ($Item in Get-ChildItem -Path $PROTO_DIR -Include *.proto -Recurse) 20 | { 21 | $File = $Item.FullName 22 | $Expr = "$PROTOC --plugin=protoc-gen-ts_proto=$PROTOC_GEN_TS_PATH --ts_proto_out=$OUTPUT_DIR --ts_proto_opt=esModuleInterop=true,outputServices=generic-definitions,useExactTypes=false,exportCommonSymbols=false -I $PROTO_DIR $File" 23 | Write-Output $Expr 24 | Invoke-Expression $Expr 25 | } 26 | -------------------------------------------------------------------------------- /wasm/packages/okapi/README.md: -------------------------------------------------------------------------------- 1 | ### Developer Notes 2 | * [Install wasm pack](https://rustwasm.github.io/wasm-pack/book/quickstart.html) 3 | * On windows you may have to replace the local `wasm-pack.exe` due to a version conflict. 4 | * From the download above, replace `./node_modules/binary-install/bin/wasm-pack.exe` with the version in `C:/users/[name]/.cargo/wasm-pack.exe` 5 | * We publish two NPM packages from this source code: `@trinsic-id/okapi-node` and `@trinsic-id/okapi-web`. We rename the package from `@trinsic-id/okapi` to each of these names at release time. -------------------------------------------------------------------------------- /wasm/packages/okapi/spec/support/jasmine-browser.json: -------------------------------------------------------------------------------- 1 | { 2 | "srcDir": "./src", 3 | "specDir": "./test", 4 | "specFiles": ["**/*.spec.ts"], 5 | "helpers": ["./test/helpers/jasmine-helper.ts"], 6 | "env": { 7 | "stopSpecOnExpectationFailure": false, 8 | "stopOnSpecFailure": false, 9 | "random": true 10 | }, 11 | "browser": { 12 | "name": "chrome" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /wasm/packages/okapi/src/README.md: -------------------------------------------------------------------------------- 1 | Okapi wasm files will be copied here -------------------------------------------------------------------------------- /wasm/packages/okapi/src/proto/google/index.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/wasm/packages/okapi/src/proto/google/index.d.ts -------------------------------------------------------------------------------- /wasm/packages/okapi/src/proto/index.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/wasm/packages/okapi/src/proto/index.d.ts -------------------------------------------------------------------------------- /wasm/packages/okapi/src/proto/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./okapi/examples/v1/examples"; 2 | export * from "./okapi/hashing/v1/hashing"; 3 | export * from "./okapi/keys/v1/keys"; 4 | export * from "./okapi/proofs/v1/proofs"; 5 | export * from "./okapi/security/v1/security"; 6 | export * from "./okapi/transport/v1/transport"; 7 | export * from "./okapi/metadata/metadata"; 8 | export * from "./pbmse/v1/pbmse"; 9 | -------------------------------------------------------------------------------- /wasm/packages/okapi/src/proto/pbmse/index.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dentity-Development/okapi/d4faa62a056caa08a406fd67c4b766747a2326e6/wasm/packages/okapi/src/proto/pbmse/index.d.ts -------------------------------------------------------------------------------- /wasm/packages/okapi/test/helpers/jasmine-helper.ts: -------------------------------------------------------------------------------- 1 | import "jasmine-core" 2 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; // 20 sec -------------------------------------------------------------------------------- /wasm/packages/okapi/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "declaration": true, 7 | "sourceMap": true, 8 | "outDir": "./lib", 9 | "strict": true, 10 | "esModuleInterop": true, 11 | "skipLibCheck": true, 12 | "forceConsistentCasingInFileNames": true 13 | }, 14 | "include": [ 15 | "./src/index.ts" 16 | ], 17 | "exclude": ["node_modules", "lib", "test"] 18 | } 19 | -------------------------------------------------------------------------------- /wasm/packages/okapi/tsconfig.web.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "es2020", 5 | }, 6 | "exclude": ["node_modules", "lib", "test", "src/native_node"] 7 | } 8 | -------------------------------------------------------------------------------- /wasm/src/didcomm.rs: -------------------------------------------------------------------------------- 1 | use js_sys::Uint8Array; 2 | use okapi::{proto::transport::*, DIDComm, MessageFormatter}; 3 | use wasm_bindgen::prelude::*; 4 | 5 | #[wasm_bindgen] 6 | pub fn didcomm_pack(request: Uint8Array) -> Result { 7 | impl_invoke!(PackRequest, DIDComm, pack, request) 8 | } 9 | 10 | #[wasm_bindgen] 11 | pub fn didcomm_unpack(request: Uint8Array) -> Result { 12 | impl_invoke!(UnpackRequest, DIDComm, unpack, request) 13 | } 14 | 15 | #[wasm_bindgen] 16 | pub fn didcomm_sign(request: Uint8Array) -> Result { 17 | impl_invoke!(SignRequest, DIDComm, sign, request) 18 | } 19 | 20 | #[wasm_bindgen] 21 | pub fn didcomm_verify(request: Uint8Array) -> Result { 22 | impl_invoke!(VerifyRequest, DIDComm, verify, request) 23 | } 24 | -------------------------------------------------------------------------------- /wasm/src/didkey.rs: -------------------------------------------------------------------------------- 1 | use js_sys::Uint8Array; 2 | use okapi::{proto::keys::*, DIDKey, MessageFormatter}; 3 | use wasm_bindgen::prelude::*; 4 | 5 | #[wasm_bindgen] 6 | pub fn didkey_generate(request: Uint8Array) -> Result { 7 | impl_invoke!(GenerateKeyRequest, DIDKey, generate, request) 8 | } 9 | 10 | #[wasm_bindgen] 11 | pub fn didkey_resolve(request: Uint8Array) -> Result { 12 | impl_invoke!(ResolveRequest, DIDKey, resolve, request) 13 | } 14 | -------------------------------------------------------------------------------- /wasm/src/hashing.rs: -------------------------------------------------------------------------------- 1 | use js_sys::Uint8Array; 2 | use okapi::{proto::hashing::*, Hashing, MessageFormatter}; 3 | use wasm_bindgen::prelude::*; 4 | 5 | #[wasm_bindgen] 6 | pub fn blake3_hash(request: Uint8Array) -> Result { 7 | impl_invoke!(Blake3HashRequest, Hashing, blake3_hash, request) 8 | } 9 | 10 | #[wasm_bindgen] 11 | pub fn blake3_keyed_hash(request: Uint8Array) -> Result { 12 | impl_invoke!(Blake3KeyedHashRequest, Hashing, blake3_keyed_hash, request) 13 | } 14 | 15 | #[wasm_bindgen] 16 | pub fn blake3_derive_key(request: Uint8Array) -> Result { 17 | impl_invoke!(Blake3DeriveKeyRequest, Hashing, blake3_derive_key, request) 18 | } 19 | 20 | #[wasm_bindgen] 21 | pub fn sha256_hash(request: Uint8Array) -> Result { 22 | impl_invoke!(Sha256HashRequest, Hashing, sha256_hash, request) 23 | } 24 | -------------------------------------------------------------------------------- /wasm/src/ldproofs.rs: -------------------------------------------------------------------------------- 1 | use js_sys::Uint8Array; 2 | use okapi::{proto::proofs::*, LdProofs, MessageFormatter}; 3 | use wasm_bindgen::prelude::*; 4 | 5 | #[wasm_bindgen] 6 | pub fn ldproofs_create_proof(request: Uint8Array) -> Result { 7 | impl_invoke!(CreateProofRequest, LdProofs, create_proof, request) 8 | } 9 | -------------------------------------------------------------------------------- /wasm/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros { 3 | macro_rules! impl_invoke { 4 | ($message:ty,$struct:ident,$func:ident,$request:expr) => { 5 | match <$message>::from_vec(&$request.to_vec()) { 6 | Ok(req) => $struct::$func(&req) 7 | .map(|v| v.to_vec().as_slice().into()) 8 | .map_err(|e| JsValue::from_str(format!("error packing {:?}", e).as_str())), 9 | Err(e) => Err(JsValue::from_str( 10 | format!("invalid request: {:?}", e).as_str(), 11 | )), 12 | } 13 | }; 14 | } 15 | } 16 | pub mod didcomm; 17 | pub mod didkey; 18 | pub mod hashing; 19 | pub mod ldproofs; 20 | pub mod metadata; 21 | pub mod oberon; 22 | -------------------------------------------------------------------------------- /wasm/src/metadata.rs: -------------------------------------------------------------------------------- 1 | use js_sys::Uint8Array; 2 | use okapi::{proto::metadata::*, MessageFormatter, Metadata}; 3 | use wasm_bindgen::prelude::*; 4 | 5 | #[wasm_bindgen] 6 | pub fn okapi_metadata(request: Uint8Array) -> Result { 7 | impl_invoke!(MetadataRequest, Metadata, get_metadata, request) 8 | } 9 | -------------------------------------------------------------------------------- /wasm/src/oberon.rs: -------------------------------------------------------------------------------- 1 | use js_sys::Uint8Array; 2 | use okapi::{proto::security::*, MessageFormatter, Oberon}; 3 | use wasm_bindgen::prelude::*; 4 | 5 | #[wasm_bindgen] 6 | pub fn oberon_create_key(request: Uint8Array) -> Result { 7 | impl_invoke!(CreateOberonKeyRequest, Oberon, key, request) 8 | } 9 | 10 | #[wasm_bindgen] 11 | pub fn oberon_create_token(request: Uint8Array) -> Result { 12 | impl_invoke!(CreateOberonTokenRequest, Oberon, token, request) 13 | } 14 | 15 | #[wasm_bindgen] 16 | pub fn oberon_create_proof(request: Uint8Array) -> Result { 17 | impl_invoke!(CreateOberonProofRequest, Oberon, proof, request) 18 | } 19 | 20 | #[wasm_bindgen] 21 | pub fn oberon_verify_proof(request: Uint8Array) -> Result { 22 | impl_invoke!(VerifyOberonProofRequest, Oberon, verify, request) 23 | } 24 | 25 | #[wasm_bindgen] 26 | pub fn oberon_blind_token(request: Uint8Array) -> Result { 27 | impl_invoke!(BlindOberonTokenRequest, Oberon, blind, request) 28 | } 29 | 30 | #[wasm_bindgen] 31 | pub fn oberon_unblind_token(request: Uint8Array) -> Result { 32 | impl_invoke!(UnBlindOberonTokenRequest, Oberon, unblind, request) 33 | } 34 | 35 | #[wasm_bindgen] 36 | pub fn oberon_verify_token(request: Uint8Array) -> Result { 37 | impl_invoke!(VerifyOberonTokenRequest, Oberon, verify_token, request) 38 | } 39 | --------------------------------------------------------------------------------